Home > Net >  Click on a link based on text
Click on a link based on text

Time:04-09

working on python I need your help on how to click on a link based on the text value inside

<div  style="">
<div >
<div ></div>
</div>
<span>Football</span>
</div>

I've tried with this one but it doesn't work at all

driver.find_element(By.XPATH, "//span[text()='Football']")

Can you support me guys?

CodePudding user response:

In your code you are just searching for the element. You need to call .click() to actually click it:

driver.find_element(By.XPATH, "//span[text()='Football']").click()

If that doesn't work, you can try to click one of the div elements instead.

  • Related