Selenium WebDriver by xpath: search by text in child elements -


i using selenium webdriver. (java, if matters).

i need find element, searching, among other things, text under subordinate element. looping through list of elements , comparing gettext() value want, suspect better let browser through xpath.

for example, here element want find:

<span role="button" class="mbltoolbarbutton mbltoolbarbuttonhasleftarrow" tabindex="0" id="dojox_mobile_toolbarbutton_3" dir="ltr" widgetid="dojox_mobile_toolbarbutton_3"><span class="mbltoolbarbuttonarrow mbltoolbarbuttonleftarrow mblcolordefault mblcolordefault45"></span><span class="mbltoolbarbuttonbody mblcolordefault"><table cellpadding="0" cellspacing="0" border="0" role="presentation" class="mbltoolbarbuttontext"><tbody><tr><td class="mbltoolbarbuttonicon"></td><td class="mbltoolbarbuttonlabel">back</td></tr></tbody></table></span></span> 

after searching online tried following selector:

//*[contains(@class,'mbltoolbarbuttonhasleftarrow') , text()[contains(.,'back')]] 

but did not work.

ideally search entire text, not substring, element text "back" found, similar element text "backup" not found. don't need concatenate text in different child elements.

what selector should write? thanks!

are looking below?

//*[text()='back']/ancestor::*[@class='mbltoolbarbutton mbltoolbarbuttonhasleftarrow']


Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -