I got this error:
FAILED: beforeTest
LaunchApp
org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot navigate to invalid URL"}
(Session info: chrome=60.0.3112.113)
(Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a),platform=Windows NT 10.0.10586 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 12 milliseconds
Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700'
System info: host: 'CCUISIA-PC', ip: '192.168.1.19', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_141'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a), userDataDir=C:\Users\SARAHC~2\AppData\Local\Temp\scoped_dir13080_2082}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=60.0.3112.113, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: dcfe08a69ade5c94942a1a67529f5c70
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:631)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:323)
at sibs.sibs.loginTest.beforeTest(loginTest.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:773)
at org.testng.TestRunner.run(TestRunner.java:623)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1018)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@f6c48ac: 149 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@6a41eaa2: 246 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@204f30ec: 18 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 10 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@57fffcd7: 58 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@5622fdf: 169 ms
Chrome Driver : 2.32 Chrome Browser: Version 60.0.3112.113 (Official Build) (64-bit) Selenium: 3.0 OS: 64 Bit
My code:
package sibs.sibs;
import org.testng.annotations.Test; import org.testng.annotations.BeforeClass; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterTest;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.NoAlertPresentException; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; //import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.DesiredCapabilities; //import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.Assert;
public class loginTest { public static WebDriver driver; private String baseUrl; private boolean acceptNextAlert = true; private StringBuffer verificationErrors = new StringBuffer();
@BeforeClass public void beforeClass() { }
@AfterClass public void afterClass() { }
@BeforeTest public void setUp() throws Exception { //System.setProperty("webdriver.gecko.driver","C:/geckodriver/geckodriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); options.addArguments("start-maximized"); options.addArguments("--js-flags=--expose-gc");
options.addArguments("--enable-precise-memory-info"); options.addArguments("--disable-popup-blocking"); options.addArguments("--disable-default-apps"); options.addArguments("test-type=browser"); options.addArguments("disable-infobars"); options.addArguments ("no-sandbox"); options.addArguments ("disable-extensions"); options.addArguments("load-extensions=C:/Java/ChromeExtensions"); System.setProperty("webdriver.chrome.driver","C:/chromedriver/chromedriver.exe"); DesiredCapabilities cap = DesiredCapabilities.chrome(); cap.setCapability("marionette", true); //WebDriver driver = new ChromeDriver(); driver = new ChromeDriver(options) ; //WebDriver driver = new RemoteWebDriver("http://localhost:9515", DesiredCapabilities.chrome()); //driver = new ChromeDriver(); //WebDriver driver = new FirefoxDriver(cap); //driver = new FirefoxDriver(); driver.get("http://newtours.demoaut.com/"); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@AfterTest (alwaysRun = true) public void tearDown() throws Exception { driver.close(); String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { Assert.fail(verificationErrorString); } }
@Test (description = "LaunchApp") public void beforeTest() { driver.get(baseUrl + "/mercurysignon.php"); driver.findElement(By.linkText("Home")).click(); driver.findElement(By.name("userName")).clear(); driver.findElement(By.name("userName")).sendKeys("yshaun"); driver.findElement(By.name("password")).clear(); driver.findElement(By.name("password")).sendKeys("12345"); driver.findElement(By.name("login")).click(); }
private boolean isElementPresent(By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; } } private boolean isAlertPresent() { try { driver.switchTo().alert(); return true; } catch (NoAlertPresentException e) { return false; }
} private String closeAlertAndGetItsText() { try { Alert alert = driver.switchTo().alert(); String alertText = alert.getText(); if (acceptNextAlert) { alert.accept(); } else { alert.dismiss(); } return alertText; } finally { acceptNextAlert = true; } } }
I got this error: FAILED: beforeTest LaunchApp org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot navigate to invalid URL"} (Session info: chrome=60.0.3112.113) (Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a),platform=Windows NT 10.0.10586 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 12 milliseconds Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700' System info: host: 'CCUISIA-PC', ip: '192.168.1.19', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_141' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a), userDataDir=C:\Users\SARAHC~2\AppData\Local\Temp\scoped_dir13080_2082}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=60.0.3112.113, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}] Session ID: dcfe08a69ade5c94942a1a67529f5c70 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:631) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:323) at sibs.sibs.loginTest.beforeTest(loginTest.java:77) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85) at org.testng.internal.Invoker.invokeMethod(Invoker.java:639) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108) at org.testng.TestRunner.privateRun(TestRunner.java:773) at org.testng.TestRunner.run(TestRunner.java:623) at org.testng.SuiteRunner.runTest(SuiteRunner.java:357) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310) at org.testng.SuiteRunner.run(SuiteRunner.java:259) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185) at org.testng.TestNG.runSuitesLocally(TestNG.java:1110) at org.testng.TestNG.run(TestNG.java:1018) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
=============================================== Default test Tests run: 1, Failures: 1, Skips: 0
=============================================== Default suite Total tests run: 1, Failures: 1, Skips: 0
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@f6c48ac: 149 ms [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@6a41eaa2: 246 ms [TestNG] Time taken by org.testng.reporters.XMLReporter@204f30ec: 18 ms [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 10 ms [TestNG] Time taken by org.testng.reporters.JUnitReportReporter@57fffcd7: 58 ms [TestNG] Time taken by org.testng.reporters.jq.Main@5622fdf: 169 ms
The problem is the browser exited abnormally.
Can someone help me on this. Thank you!