您的位置: 网站首页> 大家问> 当前文章

Element is not clickable at point,Other element would receive the click

老董2020-04-01178围观,115赞

  Element is not clickable at point,Other element would receive the click。今天点击提交的时候遇到了这个报错,原因是click时候被一个弹出的div给遮住了。原来的提交代码如下:

button = WebDriverWait(driver, 20).until(
            EC.visibility_of_element_located((By.XPATH, '//*[@id="tb_rich_poster"]/div[3]/div[5]/div/button[1]'))
        )
button.click()

  鄙人灵机一动决定用执行js的方式来提交,果然可以避免这个问题,js代码用了两种写法,均测试OK。

  第一种:

button = WebDriverWait(driver, 20).until(
            EC.visibility_of_element_located((By.XPATH, '//*[@id="tb_rich_poster"]/div[3]/div[5]/div/button[1]'))
        )
driver.execute_script("arguments[0].click();", button)

  第二种(通过js操作xpath的方式):

button_js = 'document.querySelector("#tb_rich_poster > div.poster_body.editor_wrapper > div.poster_component.editor_bottom_panel.clearfix > div > button.btn_default.btn_middle.j_submit.poster_submit").click()'
driver.execute_script(button_js)

  js操作xpath直接在谷歌浏览器审查元素那里复制出来即可!如图:(有些浏览器是没有jspath这个选项的)

很赞哦!

python编程网提示:转载请注明来源www.python66.com。
有宝贵意见可添加站长微信(底部),获取技术资料请到公众号(底部)。同行交流请加群 python学习会

文章评论

    Element is not clickable at point,Other element would receive the click文章写得不错,值得赞赏

站点信息

  • 网站程序:Laravel
  • 客服微信:a772483200