【发布时间】:2021-06-09 12:45:59
【问题描述】:
我有一个 Angular 应用程序,我想使用 Java 和 Selenium Web 驱动程序实现自动化。在我的情况下,我有一个显示在进度条之后的选项卡:
// Wait Progress bar to finish
new WebDriverWait(driver, 30).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[@class='ngx-loading-text center-center' and starts-with(., 'Loading')]")));
// Listener to click on the tab:
WebDriverWait webDriverWait = new WebDriverWait(driver, 25);
System.out.println("Click on Tab " + name + " using id locator " + tabId);
WebElement webElement = webDriverWait.until(ExpectedConditions.elementToBeClickable(By.id(tabId)));
webElement.click();
在图形模式下它工作正常。但是当我尝试将它运行到无头 Chrome 模式的后台时,我得到了异常:
element click intercepted: Element <div cdkmonitorelementfocus="" class="mat-tab-label mat-ripple mat-tab-label-active ng-star-inserted" mat-ripple="" mattablabelwrapper="" role="tab" id="mat-tab-label-0-0" tabindex="0" aria-posinset="1" aria-setsize="3" aria-controls="mat-tab-content-0-0" aria-selected="true" aria-disabled="false">...</div> is not clickable at point (80, 82). Other element would receive the click: <video width="240" height="320" controls="">...</video>
(Session info: chrome=90.0.4430.212)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DTXA-ENVTEST01', ip: 'xxxxxxxx', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_291'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 90.0.4430.212, chrome: {chromedriverVersion: 90.0.4430.24 (4c6d850f087da..., userDataDir: C:\Users\devadmin\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:51589}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 27f7f44c1429bbda4e137629c2f9ae52
堆栈跟踪
org.openqa.selenium.ElementClickInterceptedException:
element click intercepted: Element <div cdkmonitorelementfocus="" class="mat-tab-label mat-ripple mat-tab-label-active ng-star-inserted" mat-ripple="" mattablabelwrapper="" role="tab" id="mat-tab-label-0-0" tabindex="0" aria-posinset="1" aria-setsize="3" aria-controls="mat-tab-content-0-0" aria-selected="true" aria-disabled="false">...</div> is not clickable at point (80, 82). Other element would receive the click: <video width="240" height="320" controls="">...</video>
(Session info: chrome=90.0.4430.212)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DTXA-ENVTEST01', ip: 'xxxxxxxx', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_291'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 90.0.4430.212, chrome: {chromedriverVersion: 90.0.4430.24 (4c6d850f087da..., userDataDir: C:\Users\devadmin\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:51589}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 27f7f44c1429bbda4e137629c2f9ae52
at org.mobile.LoginScreenTest.verifyMainMenuLandingScreenTest(LoginScreenTest.java:411)
可能是什么问题?在这种情况下,有没有比elementToBeClickable 更合适的ExpectedConditions?
看起来进入无头模式,进度动画不会暂停,并且会产生不可变的点击。能给个建议吗?
【问题讨论】:
-
你用来点击的定位器对吗?
-
@PeterPenzov :将其更新为答案。谢谢!
标签: selenium selenium-webdriver selenium-chromedriver