首页 > 代码库 > selenium在chrome上运行报 Element is not clickable at point (1096, 26)
selenium在chrome上运行报 Element is not clickable at point (1096, 26)
Firefox上正常运行的脚本在chrome上提示Element is not clickable at point (1096, 26).分析原因,首先肯定不是因为页面元素不存在而无法点击。也不是要点击的button不在预览范围内。
后来发现,是被前一步的操作的一个弹出层挡住了。因为前几步是弹出了一个modal,在关闭modal的时候webdriver就立刻执行下一步点击某个link,而这时modal可能还没完全关闭掉。
解决办法是等待那个弹出层完全关闭掉,link可以点击的时候再执行
WebDriverWait wait = new WebDriverWait(driver, 15);wait.until(ExpectedConditions.elementToBeClickable(By.id("ID of the element")));//等待直到定位的元素可以点击打算用上面的方法来解决,结果坑爹的不起作用,实在闹不明白为啥不起作用。最后直接在两步之间加了个简单的thread.sleep(2000)命令解决了···至于为啥FF上可以正常运行,就不清楚了··可能selenium支持的更好些吧
另外一种情况是元素在视图之外,可以用调用JS这种方法解决,不过还没尝试,做个记录:
(JavascriptExecutor) driver).executeScript( "arguments[0].scrollIntoView(true);", webElement);
webElement.click();
selenium在chrome上运行报 Element is not clickable at point (1096, 26)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。