I am trying to create a simple test, just open the page and verify its title. I thought it could not be simpler, but... my test opens a new tab in a currently opened Chrome browser and fails on driver.get(myUrl);
with the org.openqa.selenium.NoSuchSessionException
I tried upgrading and downgrading chromedriver and upgrading downgrading selenium, but no luck so far. Currently I'm on selenium-java 3.3.1, chromedriver 2.28 and chrome 57.0.2987.98. Any help appreciated.
Bonus question, last time I used chromedriver it opened a new browser window, any way to get back to that? I'd prefer my tests in a new window instead of a new tab.
public class MyExampleTest { private String baseUrl; private WebDriver driver; @Before public void openBrowser() { baseUrl = "http://myurl/"; System.setProperty("webdriver.chrome.driver", "C:\\Projects\\chromedriver.exe"); driver = new ChromeDriver(); driver.get(baseUrl); } @Test public void pageTitleAfterSearchShouldBeThere() throws IOException { assertEquals("The page title should be this at the start of the test.", "my title", driver.getTitle()); } }
Stacktrace:
org.openqa.selenium.NoSuchSessionException: no such session (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 13 milliseconds Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000' System info: host: 'XXXXXXXXXXXXXXX', ip: 'xxx.xxx.xxx.xx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{message=unknown error: Chrome failed to start: crashed (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64), platform=ANY}] Session ID: 359ce80c1b82e53fffae055451228404 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:216) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:325) at ec_selenium.CapExampleTest.openBrowser(CapExampleTest.java:58) 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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)