0

How to create dynamic xpath using for loop in nodejs(selenium), for example:

List<WebElement>colHeader= rowVals.get(0).findElements(By.tagName("th"));
System.out.println("Header values:");
for(int i=0; i<colHeader.size(); i++){
    driver.findElement(By.xpath("//tbody[@id='se-tbody-result']//tr["+ i + //a"));
}

I would like to convert above mentioned code in nodejs for fething data using xpath

1 Answers1

0

avoid formatting literals using

 driver.findElement(By.xpath(`//tbody[@id='se-tbody-result']//tr[${i}]//a`));

now you dont want to include ",+ for formatting

enter image description here

Bharath Kumar S
  • 1,410
  • 2
  • 10
  • 29