如何解决预期条件失败:等待元素可点击:By.id以 500 毫秒的间隔尝试了 25 秒
我有一个 Angular 应用程序,我想使用 Java 和 Selenium Web Driver 将其自动化。我使用此代码验证按钮标签:
webdriverwait webdriverwait = new webdriverwait(driver,25);
System.out.println("Validate Button " + name + " label using id locator " + buttonId);
WebElement webDriverElement = webdriverwait.until(ExpectedConditions.elementToBeClickable(By.id(buttonId)));
assertEquals(webDriverElement.getText(),name);
在图形模式下它工作正常。但是当我尝试将它运行到后台进入 Headless Chrome 模式时,我得到了异常:
Expected condition Failed: waiting for element to be clickable: By.id: warehouse.all.accessorial-charge.image (tried for 25 second(s) with 500 milliseconds interval)
堆栈跟踪
org.openqa.selenium.TimeoutException: Expected condition Failed: waiting for element to be clickable: By.id: warehouse.all.accessorial-charge.image (tried for 25 second(s) with 500 milliseconds interval)
at org.mobile.LoginScreenTest.verifyMainMenuLandingScreenTest(LoginScreenTest.java:453)
Caused by: org.openqa.selenium.NoSuchElementException:
no such element: Unable to locate element: {"method":"css selector","selector":"#warehouse\.all\.accessorial\-charge\.image"}
(Session info: chrome=90.0.4430.212)
For documentation on this error,please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59',revision: 'e82be7d358',time: '2018-11-14T08:17:03'
System info: host: 'DTXA-ENVTEST01',ip: 'xxxxxxx',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:64771},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: 6a8fcf1bb88ab7730d0a674104a846d6
*** Element info: {Using=id,value=warehouse.all.accessorial-charge.image}
at org.mobile.LoginScreenTest.verifyMainMenuLandingScreenTest(LoginScreenTest.java:453)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。