0

I have been testing some code today and it has been working totally fine. It has now just stopped working, I haven't changed anything.

action.move_to_element(text_box)
action.click(text_box)
action.send_keys(index)
action.perform()

sleep(1)
driver.find_element_by_xpath('//*[@id="AC_tRes"]/li[1]').click()

sleep(10) 

link = driver.find_element_by_link_text('Financials')
link.click()

This code enters a name into a search box and then goes to that page. It should then click on the Finance page.

It has been working totally fine. I haven't changed anything and now I get the following error:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a class="link3" href="foo" </a> is not clickable at point (505, 509)

But I don't understand why it would just stop when I haven't even edited the code.

https://www.marketscreener.com/MICROSOFT-CORPORATION-4835/

I land on this page and it should go to the Financial link. but it is sometimes working sometimes giving me the above error.

Mathlearner
  • 107
  • 7
  • From the exception, looks like, the element you are trying to click is getting obscured by an other element. Make sure that you're running automation on 100% screen size and the element is not getting overlapped with any other element. – Kshetra Mohan Prusty May 23 '20 at 19:15

1 Answers1

0

Sometimes site can take a while to load, way exceeding your sleep(10) call. Hence, the element might not be available for clicking when the line is executed.

You will want to read the docs on Waits, particularly around Expected Conditions, and rebuild your navigation with that mindset.

r.ook
  • 13,466
  • 2
  • 22
  • 39
  • I've tried changing it to sleep(100) to see if that solves it as a test – Mathlearner May 23 '20 at 18:56
  • That will not solve your problem. If the page is hung up on loading the element will still not be clickable. `selenium` gives you plenty of `Wait` methods, it's probably best to use those instead. – r.ook May 23 '20 at 19:00
  • I will have a look. I found the implicitly_wait method. I will also look at the others you suggested. – Mathlearner May 23 '20 at 19:08