获取异常:org.openqa.selenium.WebDriverException:未知错误:net::ERR\u NAME\u未解析
我正在从事selenium Cumber Gradle项目,我看到当我使用chrome浏览器执行UI自动化脚本时,它只需打开浏览器,甚至我也可以看到url显示在浏览器地址栏中,但在2秒内,它退出,出现如下所示的异常。如有任何建议,将不胜感激。我正在使用最新的chrome浏览器和chrome驱动程序 输出结果 ================获取异常:org.openqa.selenium.WebDriverException:未知错误:net::ERR\u NAME\u未解析,selenium,gradle,selenium-chromedriver,Selenium,Gradle,Selenium Chromedriver,我正在从事selenium Cumber Gradle项目,我看到当我使用chrome浏览器执行UI自动化脚本时,它只需打开浏览器,甚至我也可以看到url显示在浏览器地址栏中,但在2秒内,它退出,出现如下所示的异常。如有任何建议,将不胜感激。我正在使用最新的chrome浏览器和chrome驱动程序 输出结果 ================ Given User navigates to the Rlbs website # RLbys_CardPage_Ui_Step_Test.nav
Given User navigates to the Rlbs website # RLbys_CardPage_Ui_Step_Test.navigates_to_the_RLby_s_website()
org.openqa.selenium.WebDriverException: unknown error: net::ERR_NAME_NOT_RESOLVED
(Session info: chrome=85.0.4183.83)
Build info: version: '4.0.0-alpha-4', revision: 'c2d955b49e'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 85.0.4183.83, chrome: {chromedriverVersion: 85.0.4183.87 (cd6713ebf92fa..., userDataDir: C:\Users\xxx~1\AppData\L...}, goog:chromeOption
s: {debuggerAddress: localhost:61816}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileIntera
ctability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: e88071b72a89d636e000150881ccb44a
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 org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:196)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:129)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:161)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:582)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:282)
at com.pros.HALbrands.test.stepdefinition.HALCardPage_Ui_Step_Test.user_navigates_to_the_HALRLby_s_website(HALRLbyCardPage_Ui_Step_Test.java:40)
at ?.User navigates to the HALRLby website(file:src/test/resources/featurefile/HALRLbyCardPage_Ui.feature:5)
我可以知道引发异常的原因是什么吗
请在下面查找代码段:
特征文件代码
功能:谷歌搜索功能
场景:验证谷歌搜索功能
给定用户导航到谷歌网站
当用户在搜索文本字段中以卡片形式输入文本时
台阶防御
------------------------------调用下面的浏览器--------------------------
public WebDriver standAloneStepUp(BrowserType bType) throws Exception {
WebDriver driver;
try {
oLog.info(bType);
switch (bType) {
case CHROME:
//ChromeBrowser chrome = ChromeBrowser.class.newInstance();
//WebDriverManager.chromedriver().setup();
System. setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"\\src\\main\\resources\\driver\\chromedriver.exe");
driver = new ChromeDriver();
return driver;
case FIREFOX:
// FirefoxBrowser firefox = FirefoxBrowser.class.newInstance();
// WebDriverManager.firefoxdriver().setup();
System. setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"\\src\\main\\resources\\driver\\geckodriver.exe");
driver = new FirefoxDriver();
//driver = new FirefoxDriver(firefox.getFirefoxOptions());
return driver;
default:
throw new NoSutiableDriverFoundException(" Driver Not Found : " + ObjectRepo.reader.getBrowser());
}
} catch (Exception e) {
oLog.equals(e);
throw e;
}
}
我知道问题出在哪里了。实际上,当您访问尚未对公众开放的站点时,就会发生这种情况。 因此,我们分两步解决了这个问题:
- 首先,我连接到客户端VPN
- 虽然连接到客户端VPN,但我还是遇到了同样的问题,所以在主机文件中添加了几行与clinet url和ip地址相关的内容
10.104.0.38 ida-oa.dev.dp-prv.halproducts.eastus.cloudapp.azure.com
10.104.0.38 order-inte-service-dev.dev.dp-prv.halproducts.astus.cloudapp.azure.com
<ip adress > <client env url >
10.104.0.38 ida-oa.dev.dp-prv.halproducts.eastus.cloudapp.azure.com
10.104.0.38订单-inte-service-dev.dev.dp-prv.halproducts.astus.cloudapp.azure.com
您至少应该提供正在执行的代码。根据提供的错误,我们只能假设问题是什么。但是,根据错误net::ERR\u NAME\u NOT\u RESOLVED
我假设您的页面地址不正确。有关此错误的更多详细信息,请访问internet,您可能会找到一个可能的解决方案。
10.104.0.38 ida-oa.dev.dp-prv.halproducts.eastus.cloudapp.azure.com
10.104.0.38 order-inte-service-dev.dev.dp-prv.halproducts.astus.cloudapp.azure.com
<ip adress > <client env url >