'failed to lookup address information' 在 Mac OS 上使用 Gecko 驱动程序执行 selenium 测试时显示错误
'failed to lookup address information' error is displayed on executing selenium test using Gecko driver on Mac OS
我正在使用 Gecko 驱动程序在 Mac OS 中执行 Selenium 测试。我正在使用 Firefox 56。
这是我用来初始化网络驱动程序的代码。
System.setProperty("webdriver.gecko.driver", "/Users/<username>/Documents/Tools/geckodriver");
DesiredCapabilities capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
现在,当我执行测试时,Gecko 驱动程序似乎已初始化,但显示下面提到的错误并且浏览器未初始化。
1507662170977 geckodriver INFO geckodriver 0.19.0
1507662170983 geckodriver INFO Listening on 127.0.0.1:42748
FAILED CONFIGURATION: @BeforeClass initializeDriver
org.openqa.selenium.WebDriverException: failed to lookup address information: nodename nor servname provided, or not known
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: '<username>s-MacBook-Pro.local', ip: '192.168.1.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144'
Driver info: driver.version: FirefoxDriver
remote stacktrace: stack backtrace:
0: 0x10d96ca8e - backtrace::backtrace::trace::h69682bcb53decaf6
1: 0x10d96cacc - backtrace::capture::Backtrace::new::hdc9d731a957304a6
2: 0x10d8ce8e3 - webdriver::error::WebDriverError::new::h4c6ae7c4aac049c6
3: 0x10d8cf352 - _$LT$webdriver..error..WebDriverError$u20$as$u20$core..convert..From$LT$std..io..error..Error$GT$$GT$::from::ha068e680ab4e1954
4: 0x10d8a221e - geckodriver::marionette::MarionetteHandler::create_connection::hc09196342b760e35
5: 0x10d8847d4 - _$LT$webdriver..server..Dispatcher$LT$T$C$$u20$U$GT$$GT$::run::hfda25a6dc0b512aa
6: 0x10d85c645 - std::sys_common::backtrace::__rust_begin_short_backtrace::h95009c1d3a320838
7: 0x10d86411d - std::panicking::try::do_call::h8c5f07f1fc714fb2
8: 0x10da1d9cc - __rust_maybe_catch_panic
9: 0x10d879f55 - _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h6a96e09ff4d37bff
10: 0x10da19c3b - std::sys::imp::thread::Thread::new::thread_start::h823686b907c11c46
11: 0x7fffdf79f93a - _pthread_body
12: 0x7fffdf79f886 - _pthread_start
您的解决方案将不胜感激。
您需要将功能传递给驱动程序:
WebDriver driver = new FirefoxDriver(capabilities);
显然存在主机名无法识别本地主机的问题with the JDK and OSX。
解决方法是将localhost添加到/etc/hosts
我正在使用 Gecko 驱动程序在 Mac OS 中执行 Selenium 测试。我正在使用 Firefox 56。
这是我用来初始化网络驱动程序的代码。
System.setProperty("webdriver.gecko.driver", "/Users/<username>/Documents/Tools/geckodriver");
DesiredCapabilities capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
现在,当我执行测试时,Gecko 驱动程序似乎已初始化,但显示下面提到的错误并且浏览器未初始化。
1507662170977 geckodriver INFO geckodriver 0.19.0
1507662170983 geckodriver INFO Listening on 127.0.0.1:42748
FAILED CONFIGURATION: @BeforeClass initializeDriver
org.openqa.selenium.WebDriverException: failed to lookup address information: nodename nor servname provided, or not known
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: '<username>s-MacBook-Pro.local', ip: '192.168.1.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144'
Driver info: driver.version: FirefoxDriver
remote stacktrace: stack backtrace:
0: 0x10d96ca8e - backtrace::backtrace::trace::h69682bcb53decaf6
1: 0x10d96cacc - backtrace::capture::Backtrace::new::hdc9d731a957304a6
2: 0x10d8ce8e3 - webdriver::error::WebDriverError::new::h4c6ae7c4aac049c6
3: 0x10d8cf352 - _$LT$webdriver..error..WebDriverError$u20$as$u20$core..convert..From$LT$std..io..error..Error$GT$$GT$::from::ha068e680ab4e1954
4: 0x10d8a221e - geckodriver::marionette::MarionetteHandler::create_connection::hc09196342b760e35
5: 0x10d8847d4 - _$LT$webdriver..server..Dispatcher$LT$T$C$$u20$U$GT$$GT$::run::hfda25a6dc0b512aa
6: 0x10d85c645 - std::sys_common::backtrace::__rust_begin_short_backtrace::h95009c1d3a320838
7: 0x10d86411d - std::panicking::try::do_call::h8c5f07f1fc714fb2
8: 0x10da1d9cc - __rust_maybe_catch_panic
9: 0x10d879f55 - _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h6a96e09ff4d37bff
10: 0x10da19c3b - std::sys::imp::thread::Thread::new::thread_start::h823686b907c11c46
11: 0x7fffdf79f93a - _pthread_body
12: 0x7fffdf79f886 - _pthread_start
您的解决方案将不胜感激。
您需要将功能传递给驱动程序:
WebDriver driver = new FirefoxDriver(capabilities);
显然存在主机名无法识别本地主机的问题with the JDK and OSX。
解决方法是将localhost添加到/etc/hosts