python selenium 点击按钮_如何使用Selenium Python单击按钮

I'm new to Python and Selenium and I want to click the button "Afficher plus" in this url.

i've tried this code :

plus = driver.find_element_by_css_selector("button[class='b-btn b-

ghost']")

plus.click()

but it doesn't work and i get this error:

selenium.common.exceptions.WebDriverException: Message: unknown error: Element ... is not clickable at point (390, 581). Other element would receive the click: ...

解决方案

Element you are trying to click is not clickable, or might be overlapped.

Try to click specified element, by executing java script click function.

driver.execute_script("arguments[0].click();", element)

On another hand, your page might not yet be fully loaded, so element might not be clickable yet, you can use wait for condition:

from selenium.webdriver.common.by import By

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

element = WebDriverWait(driver, 20).until(

EC.element_to_be_clickable(By...)) //change selector

element.click();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值