(I am a bit of a StackOverflow newbie, so please forgive any beginner mistakes and let me know what to improve in the future)
I am trying to select the highlighted button in the appended picture.
Problem:
There are many buttons of this kind all using the same description and XPath. So as far as I can tell there is no way of telling them apart by their cssSelector or XPath
Possible solution:
The h2 above the button contains a differentiable description of the button I need to select. So can I basically navigate to said h2 and then select the specific button belonging to it?
-> How to code it?
Are there easier ways to do this?
So far I know basic element selection as seen in this code sample:
WebElement loginElement = driver.findElement(By.xpath(“//*[@id=’login-submitBtn’]”));
loginElement.click();
Source: Read More