【发布时间】:2020-02-23 00:51:58
【问题描述】:
我在 selenium 中等待时遇到问题。 我想按下一个元素并得到关于被拦截的错误。 我尝试了所有解决方案,例如 element is wait element is clickable and more,但是没有任何效果。
我怎样才能解决这个异常,并告诉 selenium 等待这个元素将被删除/不可见/消失?
Sun Oct 27 14:03:53 IST 2019:INFO: WebDriver: Click on [[ChromeDriver: chrome on XP (bf4a41cbd3e7f6cfedb2f70301ed0512)] -> id: header-account]
Sun Oct 27 14:03:53 IST 2019:ERROR: element click intercepted: Element <button _ngcontent-egd-c11="" class="avatar-style ant-btn ant-btn-default ant-btn-circle" id="header-account" nz-button="" nz-popover="" nzplacement="bottomRight" nzshape="circle" nztrigger="click" ng-reflect-nz-shape="circle" ng-reflect-nz-content="[object Object]" ng-reflect-nz-trigger="click" ng-reflect-nz-placement="bottomRight" ng-reflect-directive-name-title="" nz-wave="[object Object]">...</button> is not clickable at point (1888, 31). Other element would receive the click: <path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path>
(Session info: chrome=78.0.3904.70)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'PC', ip: '10.3.3', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 78.0.3904.70, chrome: {chromedriverVersion: 77.0.3865.40 (f484704e052e0..., userDataDir: C:\Users\Sagi\AppData\Local...}, goog:chromeOptions: {debuggerAddress: localhost:56066}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: bf4a41cbd3e7f6cfedb2f70301ed0512
我只想让 selenium 等到它可以点击,然后我可以按下元素。 我怎样才能克服它?因为没有获得点击的元素的 Id 而不是 Class 只是:
Other element would receive the click: <path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path>
这是可以改变的 (会话信息:chrome=78.0.3904.70)
【问题讨论】:
-
我可以看到您正在使用 Angular。这个框架和其他一些框架一样,在嵌套的框架周围放置了许多与设计相关的元素,并且这些元素具有自定义元素。例如。如果您想选择一个具有圆形边框或类似内容的输入字段,它将呈现在一个巨大的片段中。在这种情况下,许多元素被放置在所需的元素上,因此最终您不会单击所选元素,而是单击已结束的元素。所以点击事件会被其他元素拦截。您必须获得鼠标控制,移动到选定的元素,然后用鼠标单击。
-
是的,这很令人沮丧,一切都需要修改。我有 19 种等待硒等待元素的方法。我想关闭 DEV 从 (ng.ant.design/components/notification/en) 使用的通知并且无法关闭它,因此该元素被此通知阻止,我试图等待元素可见等待它将是可点击的,因为它是部分可见的失败的。我仍然不明白如何破解这个问题,如何关闭通知。唯一的解决办法是硬编码睡眠,
标签: selenium selenium-webdriver selenium-chromedriver webdriverwait