本文介绍了INFO:HTTP状态:"404"->通过Java使用GeckoDriver,Firefox和Selenium为“未知错误"提供不正确的JSON状态映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行selenium WebDriver驱动程序= new FirefoxDriver()显示错误时,它将导入所需的所有库,但仍会重现错误

when I run selenium WebDriver driver = new FirefoxDriver () shows error, it imports all the libraries it requires but it still reproduces the error

 package prueba;

    import org.openqa.selenium.WebDriver;

    import org.openqa.selenium.firefox.FirefoxDriver;

    public class Prueba {

        public static void main(String[] args) {
        WebDriver driver= new FirefoxDriver();
        driver.get("https://www.google.com/");
    }

}

当我使用Firefox驱动程序()运行时,它显示以下错误

when I run with Firefox driver () it shows the following error

1541445238209   Marionette  DEBUG   Remote service is active
1541445238216   Marionette  DEBUG   Accepted connection 0 from 127.0.0.1:51066
1541445238238   Marionette  TRACE   0 -> [0,1,"newSession",{"acceptInsecureCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptInsecureCerts":true,"browserName":"firefox"}}}]
1541445238238   Marionette  TRACE   0 <- [1,1,{"error":"unknown command","message":"newSession","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178: ... et@chrome://marionette/content/server.js:245:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:490:9\n"},null]
Nov 05, 2018 3:13:58 PM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown error' (500 expected)
Exception in thread "main" org.openqa.selenium.WebDriverException: newSession
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z'
System info: host: 'Mac-mini-QE-Gustavo.local', ip: '192.168.1.73', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_131'
Driver info: driver.version: FirefoxDriver
remote stacktrace: stack backtrace:
   0:        0x10a952f64 - backtrace::backtrace::trace::h381bd5461b44fdf8
   1:        0x10a95331e - backtrace::capture::Backtrace::new::hbc1a12654c8fdba8
   2:        0x10a87f2ad - webdriver::error::WebDriverError::new::h482125abced50b28
   3:        0x10a88b11f - geckodriver::marionette::MarionetteSession::response::hc90b9b3424fb8183
   4:        0x10a89828b - geckodriver::marionette::MarionetteConnection::send_command::he82b7344fb11a670
   5:        0x10a889d38 - _$LT$geckodriver..marionette..MarionetteHandler$u20$as$u20$webdriver..server..WebDriverHandler$LT$geckodriver..marionette..GeckoExtensionRoute$GT$$GT$::handle_command::hf2128d0e5b79de64
   6:        0x10a829be8 - _$LT$webdriver..server..Dispatcher$LT$T$C$$u20$U$GT$$GT$::run::h03cbe31ad3bffc79
   7:        0x10a88004a - webdriver::server::start::_$u7b$$u7b$closure$u7d$$u7d$::h39b3aa32dda07c86
   8:        0x10a87434a - _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::hdf61d260d4895572
   9:        0x10a7b8399 - std::panicking::try::do_call::h7b2d8948e219fc68
  10:        0x10ade901a - __rust_maybe_catch_panic
  11:        0x10a7b7eac - std::panicking::try::h91913aec898bbfef
  12:        0x10a7b53c5 - std::panic::catch_unwind::h3ab5cba0644d3617
  13:        0x10a7b717c - std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::h27cd13f9efbf7439
  14:        0x10a812686 - _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hc399e39818c3f4d8
  15:        0x10ade51e4 - std::sys::imp::thread::Thread::new::thread_start::h36f6d218784ec55f
  16:     0x7fff58dfa660 - _pthread_body
  17:     0x7fff58dfa50c - _pthread_start
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at (RemoteWebDriver.java:142)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98)
    at prueba.Prueba.main(Prueba.java:23)
/Users/macminidev2/Library/Caches/NetBeans/8.2/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 4 seconds)

您能帮我解决这个问题吗,:D

could you help me with this problem please :D

推荐答案

此错误消息...

org.openqa.selenium.remote.ErrorCodes toStatus INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown error' (500 expected) 
Exception in thread "main" org.openqa.selenium.WebDriverException: newSession 
 Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z' 
 System info: host: 'Mac-mini-QE-Gustavo.local', ip: '192.168.1.73', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_131' 
 Driver info: driver.version: FirefoxDriver

...表示 GeckoDriver 无法启动/产生新的 WebBrowsing会话,即 Firefox浏览器会话.

...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowsing Session i.e. Firefox Browser session.

在使用 Selenium v​​3.x 时,最好从 mozilla/geckodriver ,提取并通过System.setProperty()行提供 GeckoDriver 的绝对路径,如下所示:

As you are using Selenium v3.x, ideally you should download the latest version of GeckoDriver from mozilla/geckodriver, extract and provide the absolute path of the GeckoDriver through the line System.setProperty() as follows:

System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");

但是,您的主要问题是正在使用的二进制文件版本之间的不兼容性:

However, your main issue is the incompatibility between the version of the binaries you are using as follows:

  • 您的 Selenium Client 版本是 2017-12-01T19:05:14.666Z 3.8.1 ,几乎是 a年.
  • 您的 JDK版本 1.8.0_131 ,这是古老的.
  • 您不知道您的 GeckoDriver 版本.
  • 您不知道您的 Firefox 版本.
  • Your Selenium Client version is 3.8.1 of 2017-12-01T19:05:14.666Z which is almost a year older.
  • Your JDK version is 1.8.0_131 which is pretty ancient.
  • Your GeckoDriver version is unknown to us.
  • Your Firefox version is unknown to us.

因此 JDK v8u131 Selenium Client v3.8.1 之间存在明显的不匹配.

So there is a clear mismatch between the JDK v8u131 , Selenium Client v3.8.1.

  • JDK 升级到最新级别 JDK 8u191 .
  • 升级到当前级别 版本3.14.0 > .
  • GeckoDriver 升级到 GeckoDriver v0.23.0 级.
  • GeckoDriver位于指定位置.
  • GeckoDriver对非root用户具有可执行权限.
  • Firefox 版本升级到 Firefox vv63.0.1 级别.
  • 通过 IDE
  • 清理您的项目工作区重建您的项目,并且仅具有必需的依赖项.
  • 如果您的基本 Web客户端版本太旧,请通过来卸载. Revo Uninstaller 并安装最新版本的 Web客户端 GA和发行版.
  • 进行系统重启.
  • 以非root用户身份执行Test.
  • 始终在tearDown(){}方法中调用driver.quit()以关闭&优雅地销毁 WebDriver Web Client 实例.
  • Upgrade JDK to recent levels JDK 8u191.
  • Upgrade Selenium to current levels Version 3.14.0.
  • Upgrade GeckoDriver to GeckoDriver v0.23.0 level.
  • GeckoDriver is present in the specified location.
  • GeckoDriver is having executable permission for non-root users.
  • Upgrade Firefox version to Firefox vv63.0.1 levels.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your Test as a non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

这篇关于INFO:HTTP状态:"404"-&gt;通过Java使用GeckoDriver,Firefox和Selenium为“未知错误"提供不正确的JSON状态映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 07:18