I am automating a website with Selenium, however click() is not working. It returns an element that can not be scrolled into view.
I used Javascript Executor to invoke click(), the code is written to find an element on the page clicked on after click(). However, Selenium attempts to find the element before it clicks on the website.
I checked the website while the script was running, and it attempts to find the element and then clicks on the page it's on. How do I fix this?
(code below)
I have tried waiting for the element to be clickable using WebDriver. However, it times out every time, so I am out of ideas. Any help is appreciated.
Find_Section = Driver.find_element_by_xpath('//div[contains(text()="Text"]')
Driver.execute_script("arguments[0].click();", Find_Section)
Tester = Driver.find_element_by_partial_link_text('Test19')
Tester.click()
Edit:
I believe i have figured out what the problem is according to WebDriver click() vs JavaScript click() click() behaves like a actual user does and execute_script does not and just calls the event so what i believe is happening is the execute_script is clicking on the event but not doing the same as click() so it isn't loading the page correctly.
The reason why i am using execute_script is because the click() method is throwing can not scroll element into view each time.
I may be wrong about the reason why i think it is not working if so correct me