0

With selenium webdriver it is possible to write

driver.findElement(By.id('div-id')).click();

How does it work with multiple elements? For example, following script gives an error 'Cannot read property click of undefined':

var rows = driver.findElements(By.css('#table-body tr'));
rows[2].click();

Is there any other way but to write

driver.findElements(By.css('#table-body tr')).then( function(rows) {
    rows[2].click();
});
eko
  • 369
  • 4
  • 15

1 Answers1

0

If you need to find few elements, you could try FindElement individually, also i'd try for-loop to select them.

Here are good suggestions for your situation, visit these threads:

How to find multiple elements on a page in selenium?

Selecting multiple elements with Selenium

Community
  • 1
  • 1