简体   繁体   中英

How to find the Selenium Xpath locator

I'm trying to find out the xpath for selenium for the below mentioned html. There is no id for link its directing to .action. Please help me to find the xpath locator

 <a class="ajax-link" href="SMLogin.action"><i class=""></i><span class="hidden-tablet">Login by SM</span></a> 

假设您要使用“通过SM登录”的 xpath,请尝试以下xpath:

//span[@class='hidden-tablet' and contains(text(),'Login by SM')]

I am a fan of XPath text based search

.//*[.='Login by SM']

With . you can easily point to parent node. I found this much cleaner

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM