Created
July 6, 2016 15:09
-
-
Save jdelafon/9c64b5c7a21cce31f2c036f3cc35d7a9 to your computer and use it in GitHub Desktop.
When Selenium's click() method fails, use JS instead.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# elt: WebElement | |
def robust_click(self, elt): | |
"""Click on the element, for the click() method is bugged half of the time""" | |
self.driver.execute_script("arguments[0].scrollIntoView(true);", elt) | |
action = ActionChains(self.driver) | |
action.move_to_element(elt).click().perform() | |
def js_click(self, elt): | |
"""Click on an element using javascript, because the selenium method sucks.""" | |
self.driver.execute_script("arguments[0].click();", elt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment