0

I am trying to write some code to automate the bets that I make. I am using Python 3 with Selenium and the Chrome Driver.

I am using the following website.

www.bet365.com

I have managed to make a script to log into the site but I cannot make it select the 'Horse Racing' link. The code I have is as follows:

browser.find_element_by_link_text("Horse Racing").click()

It gives me the following error message:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"link text","selector":"Horse Racing"} (Session info: chrome=80.0.3987.122)

Does anyone have any advice? I have searched online but can't find a solution.

Thanks.

1 Answers1

0

You have to use the xpath to find elements by text:

driver.find_element_by_xpath("//a[text()=\"Horse Racing\"]").click()

Change the tag "a" to the right one.

Hope this helps.

guren
  • 122
  • 2
  • 9