Selenium xpath text() - simple selection seemingly not working -


i use selenium webdriver 2.53.1 on java, chrome.

i find element , save in webelement variable named dropdownmenulist . here outerhtml, formatted.

<ul tabindex="-1" class="dropdownmenu apmurldropdownmenu thing menu" role="menu" aria-label="menu region">     <li class="menuitem apmurldropdownmenu" tabindex="-1" role="menuitem">         <div class="thing text">cardnamewebpage</div>     </li>     <li class="menuitem apmurldropdownmenu" tabindex="-1" role="menuitem">         <div class="thing text">cardnamewebpage</div>     </li>     <li class="menuitem apmurldropdownmenu" tabindex="-1" role="menuitem">         <div class="thing text">cardnamewebpage</div>     </li>     <!-- react-text: 9 -->     <!-- /react-text --> </ul> 

then search in xpath:

dropdownmenulist.findelement(by.xpath("*[text()='cardnamewebpage']")); 

and nosuchelementexception. html has of 3 elements text. doing wrong?

you should put 2 slashes (//) before because elements looking not on top level

"//*[text()='cardnamewebpage']" 

to find descendant element of current 1 (paul tremberth absolutely right :)), add point @ start of xpath

".//*[text()='cardnamewebpage']" 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -