Selenium“chrome not reachable”错误,并且在测试杀死现有浏览器并启动新浏览器后无法访问浏览器Web元素

时间:2016-08-28 11:29:18

标签: google-chrome selenium selenium-webdriver webdriver

Selenium“chrome notachable”错误,并且在测试杀死现有浏览器并启动新的

之后无法访问浏览器Web元素

我正在使用最新的java,chrome驱动程序和selenium 3.0最新jar用于自动化Web应用程序,除了测试失败外,一切都很好用;它根据我的要求杀死浏览器,新测试使用新的浏览器,但Chrome显示无法访问。

现在有没有绑定到上一个会话?后续浏览器如何启动无法识别Web对象,它只适用于首次首次启动?有没有人有这方面的解决方案,或者任何人都可以在杀死现有浏览器之后尝试在您的框架中使用最新的GA或beta网络驱动程序版本在测试之间启动新的?

步骤:

 - Write below code and launch chrome using web driver
 - Navigate to your web application
 - Login to it (WORKS FINE)
 - Assume test fails, so it kills existing chrome browser
 - Again hits below code and opens new browser
 - Navigate to application again
 - Login to it (DOESN'T WORK - because it can't identify web objects for newly launched browser due to "chrome not reachable" error).

代码:

ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");
options.addArguments("--start-maximized");
System.setProperty("webdriver.chrome.driver", chromedriverPath);
webDriver = new ChromeDriver(options);
webDriver.navigate().to(myURL);
WebDriver.findElement(By.cssSelector(input[class=LoginButton]))

错误:

Build info: version: 'unknown', revision: '2aa21c1', time: '2016-08-02 14:59:43 -0700'
System info: host: 'abc', ip: '12.116.61.2', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129), userDataDir=C:\Users\abc\AppData\Local\Temp\scoped_dir7360_5203}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=52.0.2743.116, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 4d9e503ddb4ae1506b1592a0426bb7ff
*** Element info: {Using=css selector, value=input[class=LoginButton]}
129615 [main] INFO com.util.SleepUtil  - Sleep: 1000 milliseconds ... (0/1000)
130615 [main] INFO com.util.SleepMetrics  - Entry: com.selenium.functions.Login.NavigateTo() - Sleep: 1000/2000
130615 [main] INFO com.framework - ...WebDriver...findElement()
130615 [main] INFO com.framework - ...WebDriver...elementPresent()
130615 [main] INFO com.framework - ...WebDriver...getElementOrNull()
130615 [main] INFO com.framework - ...WebDriver...getElementByCss()
130615 [main] INFO com.framework - ...WebDriver...configureCssLocator()
132629 [main] INFO com.framework - ...WebDriver.findElement(By.cssSelector(input[class=LoginButton]))
135651 [main] INFO com.framework - ...getElementByCss()...org.openqa.selenium.WebDriverException: chrome not reachable

0 个答案:

没有答案
相关问题