Below is my code which I am using to pass browser, node and hub port to launch browser and execute the tests but i get exception although I am able to set up selenium server. I paste error below of the code too. I use mac book, Selenium 3.4, Firefox 55 and Gecko 0.18.0
public synchronized WebDriver setUp(String browser, String
nodePort, String hubPort) throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setPlatform(Platform.MAC);
capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
capabilities.setCapability(ForSeleniumServer.PROXYING_EVERYTHING,
true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true);
capabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT,
true);
if(browser.equals("firefox"))
System.setProperty("webdriver.gecko.driver",
System.getProperty("user.dir")+"//geckoDriver//geckodriver");
else if(browser.equals("chrome"))
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")+"//chromeDriver//chromeDriver");
driver = new RemoteWebDriver(new
URL("http://localhost:"+nodePort+"/wd/hub"), capabilities);
driver.get("https://www.bookbaby.com");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
System.out.println(driver.toString());
return driver;
Error is
org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
Command duration or timeout: 1.41 seconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'Refaques-MacBook-Pro.local', ip: '192.168.108.206', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144'
Driver info: driver.version: Driver
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.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$22(ProtocolHandshake.java:365)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:368)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:174)
at com.bookbaby.driver.Driver.setUp(Driver.java:55)
at com.bookbaby.executor.RunCukesByFeatureForFirefox.setUpClass(RunCukesByFeatureForFirefox.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:178)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:400)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:738)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:115)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:330)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:108)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:137)
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.server.FirefoxDriverProvider.callConstructor(FirefoxDriverProvider.java:81)
at org.openqa.selenium.remote.server.FirefoxDriverProvider.newInstance(FirefoxDriverProvider.java:63)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:209)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
... 3 more
Below is my log from command prompt
13:25:14.249 INFO - Selenium build
info: version: '3.4.0', revision: 'unknown'
13:25:14.249 INFO - Launching a Selenium Grid node
2017-09-12 13:25:14.814:INFO::main: Logging initialized #833ms to
org.seleniumhq.jetty9.util.log.StdErrLog
13:25:14.864 INFO - Driver provider
org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true,
browserName=internet explorer, version=, platform=WINDOWS}] does not
match the current platform MAC
13:25:14.864 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver
registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge,
version=, platform=WINDOWS}] does not match the current platform MAC
13:25:14.864 INFO - Driver class not found:
com.opera.core.systems.OperaDriver
13:25:14.864 INFO - Driver provider com.opera.core.systems.OperaDriver
registration is skipped:
Unable to create new instances on this machine.
13:25:14.865 INFO - Driver class not found:
com.opera.core.systems.OperaDriver
13:25:14.865 INFO - Driver provider com.opera.core.systems.OperaDriver
is not registered
2017-09-12 13:25:14.899:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-09-12 13:25:14.938:INFO:osjsh.ContextHandler:main: Started
o.s.j.s.ServletContextHandler#e056f20{/,null,AVAILABLE}
2017-09-12 13:25:14.963:INFO:osjs.AbstractConnector:main: Started
ServerConnector#39529185{HTTP/1.1,[http/1.1]}{0.0.0.0:5556}
2017-09-12 13:25:14.963:INFO:osjs.Server:main: Started #982ms
13:25:14.963 INFO - Selenium Grid node is up and ready to register to
the hub
13:25:14.983 INFO - Starting auto registration thread. Will try to
register every 5000 ms.
13:25:14.983 INFO - Registering the node to the hub:
http://localhost:4445/grid/register
13:25:15.044 INFO - The node is registered to the hub and ready to use
13:25:20.205 INFO - SessionCleaner initialized with
insideBrowserTimeout 0 and clientGoneTimeout 1800000 polling every
180000
13:26:11.724 INFO - Executing: [new session: Capabilities
[{proxyEverything=true, acceptSslCerts=true, marionette=true,
acceptInsecureCerts=true, browserName=firefox, javascriptEnabled=true,
handlesAlerts=true, version=, platform=MAC}]])
13:26:11.738 INFO - Creating a new session for Capabilities
[{proxyEverything=true, acceptSslCerts=true, marionette=true,
acceptInsecureCerts=true, browserName=firefox, javascriptEnabled=true,
handlesAlerts=true, version=, platform=MAC}]
13:26:11.770 WARN - Exception thrown
java.util.concurrent.ExecutionException:
org.openqa.selenium.WebDriverException:
java.lang.reflect.InvocationTargetException
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'XXXXXX-MacBook-Pro.local', ip: '192.168.108.206',
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6',
java.version: '1.8.0_144'
Driver info: driver.version: unknown
13:26:11.777 WARN - Exception: The path to the driver executable must
be set by the webdriver.gecko.driver system property; for more
information, see https://github.com/mozilla/geckodriver. The latest
version can be downloaded from
https://github.com/mozilla/geckodriver/releases
please set environment variable webdriver.gecko.driver in your machine and its value.
or you can pass the parameter webdriver.gecko.driver while starting your hub or registering your node. like
java -Dwebdriver.gecko.driver="path to the gecko driver" {jar} -role node/hub
Firstly say the issue in your code, if you want to use the selenium server/grid please specify the webdriver path in command line when start selenium server,rather than specify by code. so below code is unnecessary, they are only necessary when you choose run test not using selenium server/grid, we call it 'directConnect' (your script communicate directly with webdriver.exe)
if(browser.equals("firefox"))
System.setProperty("webdriver.gecko.driver",
System.getProperty("user.dir")+"//geckoDriver//geckodriver");
else if(browser.equals("chrome"))
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")+"//chromeDriver//chromeDriver");
register node to hub argument example to specify webdriver.exe path:
java
-Dwebdriver.chrome.driver=C:\selenium\chromedriver_2.32.exe
-Dwebdriver.gecko.driver=C:\selenium\geckodriver-v0.18.0.exe
-jar C:\selenium\selenium-server-standalone-3.4.0.jar
-role node
-port 4446
Reminder: please check the standalone.jar, specified webdriver.exe and browser on node are compatible with each other, otherwise the node will fail to launch browser in testing.
Related
I am trying to use Selenium Grid in order to automate some tests. In order to optimize the tests' time, I created some VMs working on LINUX Platform (one VM works as a Selenium hub and the other VMs work as Selenium nodes). There is no problem while starting the standalone server neither in the hub nor in the nodes (All worked as well as supposed: the node has been successfully connected to the hub). But when trying to execute a java code that tests the remoteWebDriver (using chrome) I got a window full of warnings and errors! I think that the chromedriver is not happy... Does someone know how to solve this problem?
Below is the java code I am using:
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class GithubTest {
public static void main(String[] args) throws MalformedURLException{
String toBeTestedUrl = "https://github.com";
String nodeUrl = "http:172.20.10.13:5555/wd/hub";
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
desiredCapabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
desiredCapabilities.setPlatform(Platform.LINUX);
WebDriver driver = new RemoteWebDriver(new URL(nodeUrl), desiredCapabilities);
driver.get(toBeTestedUrl);
if(driver.getTitle().equalsIgnoreCase("The world’s leading software development platform · GitHub"))
System.out.println("OK!");
else
System.out.println("ERROR!");
driver.quit();
}
}
And below is the log file in the selenium node:
16:48:24.098 INFO - Selenium build info: version: '3.9.1', revision: '63f7b50'
16:48:24.108 INFO - Launching a Selenium Grid node on port 5555
16:48:26.313 INFO - Selenium Server is up and running on port 5555
16:48:26.313 INFO - Selenium Grid node is up and ready to register to the hub
16:48:26.344 INFO - Starting auto registration thread. Will try to register every 5000 ms.
16:48:26.345 INFO - Registering the node to the hub: http://172.20.10.10:4444/grid/register
16:48:26.442 INFO - Updating the node configuration from the hub
16:48:26.483 INFO - The node is registered to the hub and ready to use
16:49:08.370 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#cdb1ecc
16:49:08.374 INFO - /session: Executing POST on /session (handler: BeginSession)
16:49:08.503 INFO - Capabilities are: Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, platform: LINUX}
16:49:08.505 INFO - Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, platform: LINUX} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
The errors log while executing the java class:
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 5.0.0-36-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 112 milliseconds
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
System info: host: 'SeleniumNode1', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.0.0-36-generic', java.version: '11.0.4'
Driver info: driver.version: unknown
Command duration or timeout: 288 milliseconds
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:138)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at GitTest.main(GitTest.java:19)
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 5.0.0-36-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 112 milliseconds
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
System info: host: 'SeleniumNode1', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.0.0-36-generic', java.version: '11.0.4'
Driver info: driver.version: unknown
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
System info: host: 'SeleniumHub', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.0.0-36-generic', java.version: '11.0.4'
Driver info: driver.version: unknown
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.server.RemoteSession$Factory.performHandshake(RemoteSession.java:145)
at org.openqa.selenium.remote.server.ServicedSession$Factory.apply(ServicedSession.java:154)
at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$12(ActiveSessionFactory.java:176)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:442)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.ActiveSessionFactory.apply(ActiveSessionFactory.java:179)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$null$2(NewSessionPipeline.java:65)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.util.Collections$2.tryAdvance(Collections.java:4747)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.NewSessionPipeline.lambda$createNewSession$3(NewSessionPipeline.java:68)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.util.stream.DistinctOps$1$2.accept(DistinctOps.java:175)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
at java.util.stream.Streams$ConcatSpliterator.tryAdvance(Streams.java:720)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession(NewSessionPipeline.java:71)
at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute(BeginSession.java:65)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:242)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:834) ```
First thing to check is that you're using the correct Chrome driver to drive your Chrome Browser. If you're not sure, check your Chrome version and download the driver again from http://chromedriver.chromium.org/downloads . As far as i can see your ChromeDriver is 2.41 , which supports Chrome v67-69 only so it could be the compatibility reason.
If it does not help , you might need to add extra arguments into your driver initialization
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('/path/to/your_chrome_driver_dir/chromedriver',chrome_options=chrome_options)
I wanted some help on running my automation scripts on Safari.
Im running my selenium webdriver scripts on Mac OS(High Sierra) and Safari 11.1.2
I have WebDriver Extension has been added to safari browser and I have enabled the 'Allow Remote Automation'
Here is the way i'm trying to invoke selenium webdriver:
SafariOptions safariOptions = new SafariOptions();
safariOptions.useCleanSession(true);
safariOptions.setUseTechnologyPreview(true);
WebDriver driver = new SafariDriver(safariOptions);
I have also installed Safari technology preview on my machine.
When I run my scripts, it throws below error:
org.openqa.selenium.SessionNotCreatedException: Could not create a session: A browser with name 'safari' version '(null)' could not be found on the system.
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'Meghas-MacBook-Pro.local', ip: 'fe80:0:0:0:1c74:d309:2877:bd09%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_171'
Driver info: driver.version: InitiateWebDriver
remote stacktrace:
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.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:78)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:60)
So when I uninstall the Safari technology preview, and change the code to
org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:24147
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'Meghas-MacBook-Pro.local', ip: 'fe80:0:0:0:1c74:d309:2877:bd09%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_171'
Driver info: driver.version: InitiateWebDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:78)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:60)
Inbetween it also said that "Safari driver requires safari 10 running on OSX EL Capitan or greater"
As occurs with other selenium webdrivers you should specify where is the binary of Safari to run it.
System.setProperty("webdriver.safari.driver", "/mypath/binary");
The path usually is /System/Library/CoreServices/SafariSupport.bundle/Contents/MacOS/safaridriver. And do it before your example lines.
And activate the Safari automation:
I am using Selenium with Chromedriver in Java (1.8) to do some automated web crawling:
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("someurl.com");
I am attempting to migrate to an Ubuntu 16.04 Server. On the server I have installed the Ubuntu chromedriver version 2.37, chrome version 65. According to the chromedriver documentation these versions are compatible. I have changed the code specifying the location of the chromedriver in Ubuntu:
System.setProperty("webdriver.chrome.driver", "/usr/lib/local/chromedriver");
Prior to running my program I start up xvfb:
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
Then execute my program:
java -jar myprogram.jar
The following is printed to the console:
Starting ChromeDriver 2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7) on port 10574
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux 4.4.0-112-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.35 seconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'ubuntu-s-1vcpu-1gb-nyc1-01', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-112-generic', java.version: '1.8.0_151'
Driver info: driver.version: ChromeDriver
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.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at RHio.Test.main(Test.java:39)
The error does gives us some idea about whats wrong happening :
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
As you are trying to initiate Chromedriver and Chrome on Ubuntu Server headless you have to pass a couple of Options as follows :
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=options, executable_path='/path/to/chromedriver')
driver.get('http://google.com/')
driver.quit()
Additional Notes
As per the mandatory Requirements and #1341 ensure the following :
Chromedriver is within /usr/local/bin/
Chrome Browser is within /usr/bin/google-chrome
tl;dr
The story of Sandbox
I'm using Selenium version 3.4.0 and geckodriver version 0.16.1. My firfox version is 52.0.1.
I have started Jenkins server through command line java -jar jenkins.war
Jenkins server is working fine. But when I tried to execute Jenkins parameterized job (maven test) firefox opens for a moment and closes immediately.
Here is my trace log:
Running TestSuite
Before Test::com.sample.jenkins_demo.LoginTest
1495542214304 geckodriver INFO Listening on 127.0.0.1:20563
1495542215003 mozprofile::profile INFO Using profile path C:\Users\X--TM\AppData\Local\Temp\rust_mozprofile.Ec9pWyDHao34
1495542215020 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
1495542215057 geckodriver::marionette INFO Connecting to Marionette on localhost:60423
1495542216346 Marionette INFO Listening on port 60423
1495542216787 Marionette WARN TLS certificate errors will be ignored for this session
May 23, 2017 5:53:37 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
org.openqa.selenium.InvalidArgumentException: Missing 'type' parameter
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'X-TM', ip: '192.168.139.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\X--TM\AppData\Local\Temp\rust_mozprofile.Ec9pWyDHao34, rotatable=false, timeouts={implicit=0.0, page load=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=52.0.1, platformVersion=10.0, moz:processID=10620.0, browserName=firefox, javascriptEnabled=true, platformName=windows_nt}]
Session ID: ec7c23fa-a0b3-4f54-b017-bd192830db16
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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:150)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:115)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:868)
at com.sample.jenkins_demo.Base.setUp(Base.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:517)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140)
at org.testng.TestRunner.beforeRun(TestRunner.java:645)
at org.testng.TestRunner.run(TestRunner.java:613)
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:1199)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1032)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:295)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:90)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Before Method::com.sample.jenkins_demo.LoginTest
If I use chrome browser it is working fine in Jenkins.
NOTE: Same test is executing locally fine on firefox and chrome browser both.
My firefox configuration:
public static WebDriver driver = null;
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver = new FirefoxDriver(capabilities);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.google.co.in");
Can anyone help me to resolve this issue ?
Here is the Answer to your Question:
The error says it all Missing 'type' parameter
It was a known issue on Missing 'type' parameter Build info: version: '3.4.0' on Selenium with Mozilla Firefox. You can find the discussion here.
Upgrading to Mozilla Firefox 53.x will solve your issue.
Let me know if this Answers your Question.
Currently I was able to upload the file using selenium webdriver version 2.42.00 with browser chrome while I couldn't able to do it the same with Internet Explorer version 11.
driver.findElement(By.id("fileUpload")).sendKeys(filePath);
where id = fileUpload is for input element with type=file and this field is a hidden field.
Any thoughts on it:
org.openqa.selenium.ElementNotVisibleException: Element is not displayed (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 30 milliseconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'XXXXXXX', ip: '192.168.12.24', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=false, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=true, browserName=internet explorer, initialBrowserUrl=http://localhost:7704/ takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: cfa81fae-4ea2-43b9-9e3a-69135462fe82
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_40]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]
It is a known issue with IEDriver which is going to be resolved in next release. Hidden file input tag will not work on IE as it does on other browsers. See the issue logged here. I have answered a similar question here
EDIT
Here is the good news. Just confirmed the Selenium version 2.46 has the changes. See changelog. So upgrade and it should work