1

I have three <div class= emploBox "> and each has a button. Buttons do not have unique names. How can I find this particular button? I want to use class=cutTooLongTest and test 'automated tester' but I don't know how. wants to find the button marked in yellow.

enter image description here

I have no idea for a solution

2 Answers2

1

this should work for you:

webDriver.findElement(By.xpath("//h2[@class = 'cutTooLongTest' and text() = 'automated tester']/following-sibling::div/button[1]"));
Marek
  • 438
  • 5
  • 10
-1

If I understood you right, you need to find the XPath for the button using the text 'automated tester'.

The XPath expression should be like this:

//h2[text() = 'automated tester']//..//button[contains(@class, 'standard Button--icon')]
Norayr Sargsyan
  • 1,737
  • 1
  • 12
  • 26