简体   繁体   中英

Selenium click on button

On web-page there is button, which describe by code below:

<button onclick="getListRating(1); return false;" class="button is-gray pagination__more">Open</button>

Need to click by use selenium lib - first i tried to find as "css_celector" but it didn't work:

allm=driver.find_element(By.CSS_SELECTOR, 'button is-gray pagination__more')  # Find button
allm.click() # Click!

What find class i need to use to click this button?

I'd find the button by the onclick attr. Here is a solution with xpath.

button = driver.find_element_by_xpath('//button[@onclick="getListRating(1); return false;"]')
button.click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM