How to properly click an element in Selenium using Python?
I am trying to click an element like "AH" on this page. I am using the following code.
from selenium import webdriver
url = "http://www.oddsportal.com/soccer/brazil/serie-a/internacional-santos-vcGTTAKH/"
driver = webdriver.Firefox()
driver.get(url)
element_to_click = driver.find_element_by_link_text("AH")
element_to_click.click()
The problem is that after the element is clicked and a new page is loaded, it goes back to the first page.
+3
source to share
2 answers
alecxe that works.
Just to add to the discussion here
So when the mouse is clicked, it calls onClick for uid (4), when we do a normal click on the element, we donβt realize that it was working on mouse down
not on mouse click
.
That's why when we use webdriver to execute element.click () it doesn't work, and when we use Action class to simulate mouse using click_and_hold
it works !!
+1
source to share