Search code examples
javaseleniumfindelement

how to find element button in div using selenium?


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


Solution

  • 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')]