python selenium click on button python selenium click on button selenium selenium

python selenium click on button


Remove space between classes in css selector:

driver.find_element_by_css_selector('.button .c_button .s_button').click()#                                           ^         ^

=>

driver.find_element_by_css_selector('.button.c_button.s_button').click()


try this:

download firefox, add the plugin "firebug" and "firepath"; after install them go to your webpage, start firebug and find the xpath of the element, it unique in the page so you can't make any mistake.

See picture:instruction

browser.find_element_by_xpath('just copy and paste the Xpath').click()


For python, use the

from selenium.webdriver import ActionChains

and

ActionChains(browser).click(element).perform()