How can I pass/use a parameter1 value into another parameter2 xpath?



  • How can I pass/use a parameter1 value into another parameter2 xpath ?



  • XPath is basically a function which takes string as an argument. You can use the concatenate multiple strings functionality of the language you are using.

    For example in Java, you can concatenate multiple strings using +. You can do the same thing here with XPath.

    WebElement element1 = driver.findElement(By.xpath("//td[normalize-space(text())='test']/a"));
    String value = element1.getAttribute("value")
    WebElement element2 = driver.findElement(By.xpath("//td[normalize-space(text())='" + value + "']/a"));
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2