Testing express

Testing express

Friday, May 22, 2015

Selenium tips: Locate elements that have same attributes for all elements

Some times a group of elements have same attributes for all elements, in that case if I want to click or select any specific element from that group, it will be hard using any location strategies. Here is one solution that I came up with

WebDriver driver = new FirefoxDriver();
List<WebElement> cbox = driver.findElements(By.name("chk"));

In the above code we are getting all elements using locator name and value "chk" into a List
Then we are calling the get method on the list object by passing the index value and the performing the action.

No comments:

Post a Comment