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

Time:05-11

Here is the image button source:

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

CodePudding user response:

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()
  • Related