简体   繁体   English

硒点击按钮

[英]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:需要通过使用 selenium lib 单击 - 首先我试图找到“css_celector”,但它没有用:

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.我会通过 onclick attr 找到按钮。 Here is a solution with xpath.这是xpath的解决方案。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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