简体   繁体   中英

Selenium Web driver: how do I click on image button without ID, NAME

Here is the image button source:

 <div class="btn"> <a href="javascript:fncLogin();"><img src="/image/btn_login.jpg" alt="A_LOGIN"></a> </div>

driver.find_element(By.XPATH,"//a[@href='javascript:fncLogin();']").click()

You can use it's href.

If it's button class is unique you can do

driver.find_element(By.XPATH,"//div[@class='btn']/a").click()

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