SHARE
TWEET

example 3 – Locating dynamic elements – variable class name

SeleniumETrainR Dec 23rd, 2012 36 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         import java.util.List;
  2. import java.util.concurrent.TimeUnit;
  3.  
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.WebDriver;
  6. import org.openqa.selenium.WebElement;
  7. import org.openqa.selenium.firefox.FirefoxDriver;
  8.  
  9.  
  10. public class TestLocatingDynamicElementsbutton {
  11.  
  12.          
  13.         public static void main(String[] args) {
  14.                 WebDriver myTestDriver = new FirefoxDriver();
  15.                  myTestDriver.get("http://tinyurl.com/buxk9dg");
  16.                  myTestDriver.manage().window().maximize();
  17.                  myTestDriver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
  18.  
  19.                  List<WebElement> ButtonNamelist = myTestDriver
  20.                                  .findElements(By
  21.                                  .cssSelector("span[class^='z-button']"));
  22.  
  23.                 System.out.println(ButtonNamelist.size());
  24.  
  25.                  
  26.                 for(int i=0;i<ButtonNamelist.size();i++){
  27.                                  System.out.println(ButtonNamelist.get(i).getText());
  28.                 }
  29.                                  
  30.                
  31.                 myTestDriver.quit();
  32.                                  
  33.         }
  34.  
  35.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top