简体   繁体   English

线程“主”org.openqa.selenium.WebDriverException 中的异常:未知错误:使用 Selenium Java 的意外命令响应

[英]Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unexpected command response using Selenium Java

I am using Selenium in Eclipse and I am getting these error very often.我在 Eclipse 中使用 Selenium,我经常收到这些错误。

Before I was getting error due to loading status which I downgraded to chrome 102.Now I am facing this error which I can't understand.在由于加载状态而出现错误之前,我降级到 chrome 102。现在我面临这个我无法理解的错误。 I am sharing my console and script:我正在共享我的控制台和脚本:

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unexpected command response
  (Session info: chrome=103.0.5060.114)
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'AWAIS-PC', ip: '192.168.1.62', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [b494462d4f7752feaa9aeeb67f469204, findElement {using=id, value=wzrk-cancel}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 103.0.5060.114, chrome: {chromedriverVersion: 102.0.5005.61 (0e59bcc00cc4..., userDataDir: C:\Users\WRP\AppData\Local\...}, goog:chromeOptions: {debuggerAddress: localhost:54170}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:54170/devtoo..., se:cdpVersion: 103.0.5060.114, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: b494462d4f7752feaa9aeeb67f469204
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
    at org.openqa.selenium.remote.ElementLocation$ElementFinder$2.findElement(ElementLocation.java:162)
    at org.openqa.selenium.remote.ElementLocation.findElement(ElementLocation.java:60)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:387)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:379)
    at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:197)
    at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:193)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
    at First_Test.Practice_First.main(Practice_First.java:52)
WebDriverManager.chromedriver().driverVersion("102.0.5005.61").setup();
WebDriver driver = new ChromeDriver();
WebDriverWait waits=new WebDriverWait (driver, Duration.ofSeconds(13));
//driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
driver.get("https://www.ounass.ae/");
//Thread.sleep(3000);
driver.manage().window().maximize();
//Thread.sleep(3000);
//  String originalWindow=  driver.getWindowHandle();
// Thread.sleep(5000);
waits.until(ExpectedConditions.visibilityOfElementLocated(By.id("wzrk-cancel")));
driver.findElement(By.id("wzrk-cancel")).click();
// driver.findElement(By.xpath("//button[@id='wzrk-cancel']")).click();
waits.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a[href*='/men']")));
driver.findElement(By.cssSelector("a[href*='/men']")).click();
JavascriptExecutor Js1 = (JavascriptExecutor) driver;
Js1.executeScript("window.scrollBy(0,2500)"); 

To click on the element No thanks instead of visibilityOfElementLocated() you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following locator strategy :要单击元素不,谢谢,而不是visibilityOfElementLocated() ,您需要为elementToBeClickable()诱导WebDriverWait ,您可以使用以下任一定位器策略

  • Using id :使用id

     new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.id("birtviewer"))).click();
  • Using cssSelector :使用cssSelector

     new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button#wzrk-cancel"))).click();
  • Using xpath :使用xpath

     new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id='wzrk-cancel']"))).click();

Looks like a bug has been introduced - https://chromedriver.chromium.org/downloads看起来已经引入了一个错误 - https://chromedriver.chromium.org/downloads

Resolved issue 4121: WebDriver command sometimes fails with "unexpected command response"

Fixed in Chrome Driver version 104已在 Chrome 驱动程序版本 104 中修复

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 线程“主”org.openqa.selenium.WebDriverException 中的异常:未知错误:使用 Selenium 单击时无法确定加载状态错误 - Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status error while clicking using Selenium 线程“ main” org.openqa.selenium.WebDriverException中的异常:未知错误:Chrome无法启动:正常退出 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally 线程“主” org.openqa.selenium.WebDriverException中的异常:未知错误:无法聚焦元素 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot focus element 线程“main” org.openqa.selenium.WebDriverException 中的异常:未知错误:无法获得自动化扩展 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension 线程“主” org.openqa.selenium.WebDriverException中的异常:未定义$ - Exception in thread “main” org.openqa.selenium.WebDriverException: $ is not defined 线程“主” org.openqa.selenium.WebDriverException中的异常:无法访问Chrome - Exception in thread “main” org.openqa.selenium.WebDriverException: chrome not reachable 线程“主”org.openqa.selenium.WebDriverException 中的异常:权限被拒绝 - Exception in thread “main” org.openqa.selenium.WebDriverException: permission denied 如何修复线程“主”org.openqa.selenium.WebDriverException 中的异常? - How to fix Exception in thread “main” org.openqa.selenium.WebDriverException? 线程“ main”中的异常org.openqa.selenium.WebDriverException - Exception in thread “main” org.openqa.selenium.WebDriverException org.openqa.selenium.WebDriverException:未知错误:Runtime.evaluate 抛出异常:SyntaxError:无效或意外的令牌 - org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: Invalid or unexpected token
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM