4

I am trying to click an element, for example "AH", in this page. I use 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 the new page is loaded, it goes back to the first page.

2 Answers 2

1

Focus the element and call click_and_hold action (worked for me):

from selenium.webdriver import ActionChains

actions = ActionChains(driver)
actions.move_to_element(element_to_click).click_and_hold(element_to_click).perform()
Sign up to request clarification or add additional context in comments.

Comments

1

alecxe , that works.

Just to add to the discussion here

enter image description here

So on mouse down it is invoking onClick for the uid(4), when we do a normal click on the element we do not realize that it worked on mouse down not on mouse click.

Thats why when we are using webdriver to do element.click() on it, this does not work and when we use Actions class to simulate mouse down using click_and_hold, It works !!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.