Skip to content Skip to sidebar Skip to footer

Python: Selenium To Simulate Onclick

I am trying to use python to play a simple javagame that I made for a class assignment. I am trying to make python open up a webpage and use the form buttons to input numbers. I t

Solution 1:

You CSS selector is not valid. Try this one instead:

li = browser.find_element_by_css_selector('#button-five')

Note that you can get a CSS selector in your browser by inspecting the element and clicking on "Copy unique selector" in the context menu.

Solution 2:

try:

li = browser.find_element_by_css_selector('input#button-one[onclick="predict.input.value += 1"]')

or without element name "input":

li = browser.find_element_by_css_selector('#button-one[onclick="predict.input.value += 1"]')

or if there is only element whose "id" is "button-one", simply write:

li = browser.find_element_by_css_selector('#button-one')

Post a Comment for "Python: Selenium To Simulate Onclick"