Search code examples
selenium-webdriverxpath

Unable to find element on child div xpath


<div class="gwt-Label WLFP WEEP" data-automation-id="promptOption" id="promptOption-gwt-uid-2" data-automation-label="Start" title="Start" aria-label="Start" role="link" tabindex="0">Start</div>

In our application after search we get bunch of search results which are basically clicable links, i am trying to find out search text like "Start" in above example and click on it. My xpath //div[@data-automation-id='promptOption']/ highlight the area but after that when i provide required text path it doesn't find that.

//div[@data-automation-id='promptOption']//span[contains(@text, 'Start')]
//div[@data-automation-id='promptOption' and text()='Start']
//div[@data-automation-id="promptOption"]//a[.='Start']

Solution

  • You need:

    //div[@data-automation-label="Start" and text()="Start"][1]