Could not contact Selenium Server; have you started it on 'localhost:4444'? - selenium

I am using selenium standalone version 2.33.0 to run the automated test cases. It was running fine until last month. The firefox version then was 21.x. Now it is upgraded to ver-22.
I figured out that selenium 2.33 does not work with the latest firefox browser. So I changed the value of 'maxVersion' to 23.0.* in the below files:
./customProfileDirCUSTFF/extensions/readystate#openqa.org/install.rdf
./customProfileDirCUSTFF/extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf
./customProfileDirCUSTFFCHROME/extensions/readystate#openqa.org/install.rdf
./customProfileDirCUSTFFCHROME/extensions/{503A0CD4-EDC8-489b-853B-19E0BAA8F0A4}/install.rdf
./customProfileDirCUSTFFCHROME/extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf
After this when I try to run selenium, I get the below error:
Could not contact Selenium Server; have you started it on 'localhost:4444' ? Read more at http://seleniumhq.org/projects/remote-control/not-started.html Connection refused
com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:86)
at qa.apigee.common.ApigeeOnlineUITestBase.launchBrowser(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:640)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:503)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:193)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:123)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:183)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:115)
at org.testng.TestRunner.runWorkers(TestRunner.java:1098)
at org.testng.TestRunner.privateRun(TestRunner.java:727)
at org.testng.TestRunner.run(TestRunner.java:581)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:315)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:310)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:272)
at org.testng.SuiteRunner.run(SuiteRunner.java:221)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:40)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:83)
at org.testng.internal.thread.ThreadUtil$CountDownLatchedRunnable.run(ThreadUtil.java:151)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
Please help!

Try to add the below code to start the server.
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.com/");
selenium.start();
}
Hope this will solve your problem.

You can try this one. You can change the port number as follows:
Goto run-> ExternalTools ->ExternalToolsConfiguration->update the "arguments" as below:
-jar selenium-server-standalone-2.42.2 jar -port 1234 ->apply-> run
After making this, change the port num as 1234 in your program, save the program and run.

It's necessary to start the server:
You should go to the directory where Selenium RC’s server is located and run the following from a command-line console:
java -jar selenium-server-standalone-<version-number>.jar
You can also create a .bat on Windows o .sh on Linux
Source: Running selenium server (http://www.seleniumhq.org/docs/05_selenium_rc.jsp)

Related

Cannot find Chrome binary when executing a selenium (testng) test in jenkins on windows 7

I have a basic login test with selenium and testng. When executed from eclipse, it works as expected and invoke Google Chrome. If executed from TESTNG command line, it works fine too.
This is my #Before:
#BeforeMethod
public void setUp() throws Exception {
File file = new File("C:/Selenium-driver/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
However, if I execute the same test thru Jenkins it says:
Building in workspace C:\EclipsePortable\Data\workspace\GS_TESTNG
[G_TESTNG] $ cmd /c call C:\Windows\TEMP\hudson9049518275115936054.bat
C:\EclipsePortable\Data\workspace\G_TESTNG>_test_login_cmd.bat
C:\EclipsePortable\Data\workspace\G_TESTNG>cd C:\EclipsePortable\Data\workspace\G_TESTNG
C:\EclipsePortable\Data\workspace\G_TESTNG>java -cp C:\EclipsePortable\Data\workspace\G_TESTNG\lib\*;C:\EclipsePortable\Data\workspace\G_TESTNG\bin org.testng.TestNG testng.xml
...
... TestNG 6.9.9 by Cédric Beust (cedric#beust.com)
...
[TestNG] Running:
C:\EclipsePortable\Data\workspace\G_TESTNG\testng.xml
Starting ChromeDriver 2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30) on port 36257
Only local connections are allowed.
FAILED CONFIGURATION: #BeforeMethod setUp
org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 664 milliseconds
Build info: version: '2.51.0', revision: '1af067d', time: '2016-02-05 19:15:17'
System info: host: 'NMTLA12810', ip: '192.168.0.179', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
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:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at com.test.TestA.setUp(TestA.java:33)
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.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:585)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.TestNG.privateMain(TestNG.java:1355)
at org.testng.TestNG.main(TestNG.java:1324)
SKIPPED CONFIGURATION: #AfterClass tearDown
SKIPPED: testGooglePageTitleInChrome
===============================================
TestNG Test Group
Tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
===============================================
Main Test Suite
Total tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter#7fbe847c: 16 ms
[TestNG] Time taken by org.testng.reporters.jq.Main#759ebb3d: 78 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter#ba8a1dc: 59 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter#1c655221: 5 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2#1edf1c96: 16 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
Build step 'Exécuter une ligne de commande batch Windows' marked build as failure
Finished: FAILURE
I think you need to install chrome in your instance. for that you follow this basic commands
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
sudo yum install ./google-chrome-stable_current_*.rpm
google-chrome &
It is possible that chrome is installed on your AppData (especially if your are on Windows 7). I am guessing Jenkins could not access the binary from your user directory. Make sure the directory you have Chrome on, is accessible to Jenkins, or try reinstalling chrome again to program files directory.
On the other hand, you can simply instruct Chromedriver where to look for Chrome Binary,
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\\ThePAthtoChrome.exe");
ChromeDriver driver = new ChromeDriver(chromeOptions);
The problem is these lines in your code:
File file = new File("C:/Selenium-driver/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
This is a massive anti-pattern that I regularly see. The webdriver.chrome.driver environmental variable was designed so that you could install your chromedriver binaries on multiple systems in different places, and then set the environmental variable on each system so that if a selenium test is ever run on that system it will automatically pick up the location of the binary.
By hard coding this environmental variable via code you are ignoring any preconfigured environmental variable that was set up when the build agent was built, you are not using it in the way it was intended.
If you insist on doing it this way you should always check to see if the env variable is already set before you set it, this way you will not overwrite the existing env variable. You will also need to make sure that the file path you have hard coded exists on your build agent (the secondary cause of your error is that it doesn't) so that if the env variable isn't set, you are actually setting a valid path to the chromedriver binary.
I just check my chrome version (chrome://settings/help(85.0.4183.83 )) and then downloaded chromedriver.exe accordingly (https://chromedriver.chromium.org/downloads)and given new chrome driver.exe path...-This solves my same issue
I had the same problem, I was able to execute selenium scripts through local but when tried executing on Jenkins got error "unknown error: cannot find Chrome binary".
Here is my solution which worked on Jenkins server:
1. Download and enable Xvfb before start of selenium script on jenkins. For more info read here https://wiki.jenkins.io/display/JENKINS/Xvfb+Plugin
2. I am having ubuntu 16.xx os on local and jenkins server.
3. Try to keep chromedriver in "usr/bin" folder only otherwise you may get error.
try {
if(service == null){
service = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("/usr/bin/chromedriver"))// set the chromedriver path
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY", ":15"))
.withSilent(true)
.build();
service.start();
}
System.out.println("Reading chrome driver");
System.setProperty("webdriver.chrome.driver","/usr/bin/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://google.com");
driver.quit();
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
This code i tried it solved my one week unresolved problem,
Thanks to Aastha Chopra..
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver","C:\\STUDY\\Selenium\\CHROMEDRIVERS\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://newtours.demoaut.com/");
Mac users, Please make sure that chromeBinary file is placed at bin folder and chrome if it is in downloads move it to application.
Check the OS of the Agent Node.
Check how Jenkins Access the agent Node.
if its via JNLP and the OS is below Window 7, through Admin right install the Chrome in C:/Program Files(x86) where Jenkins can access the chrome.exe and set binaries using below code:
ChromeOptions options = new ChromeOptions();
if(System.getProperty("os.name").equals("Windows Server 2012 R2")){
File ChromeExePath =new File("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
if (ChromeExePath.exists()){
options.setBinary(ChromeExePath);
}
}
ChromeDriver driver = new ChromeDriver(options);
I was having similar issue in JS, it got fixed after installing npm i chromedriver
Please check your binary path if still not works then
you should have installed chrome in your machine
and your chromedriver.exe version should accordingly (like if you have chrome 87.0 ver then download chromedriver.exe for ver 87.0)
download form it from
https://chromedriver.chromium.org/downloads
and given new chromedriver.exe path to your script.
This works fine for me
ChromeOptions options = new ChromeOptions();
options.BinaryLocation="C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(ChromeOptions.Capability, options);
ChromeDriver driver = new ChromeDriver("C:\\test3", options);
This worked for me in C#. my chromedriver.exe is in test3 folder. Also my issue was that version of chrome was not same of chromedriver. This will definitely work:)
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver","C:\\STUDY\\Selenium\\CHROMEDRIVERS\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://newtours.demoaut.com/");
It worked for me. I have coded as below
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\\Users\\kannanu\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver",ChromeExePath);
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://newtours.demoaut.com/");
I ran the following command to install chromedriver and it worked:
brew cask install chromedriver

Selenium Video Node api

I am using selenium video node api for recording remote machine screen but when I run server or hub it run perfectly but it give error when I start node or client.
Hub Run
java -cp selenium-video-node-1.4.jar;selenium-server-standalone-2.44.0.jar org.openqa.grid.selenium.GridLauncher -servlets com.aimmac23.hub.servlet.HubVideoDownloadServlet -role hub
Node Run
java -cp selenium-video-node-1.4.jar;selenium-server-standalone-2.44.0.jar org.openqa.grid.selenium.GridLauncher -servlets com.aimmac23.node.servlet.VideoRecordingControlServlet -proxy com.aimmac23.hub.proxy.VideoProxy -role webdriver -hub http://192.168.2.245:4444/grid/register -port 6666
It give error like
11:51:30.817 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:6666/wd/hub
11:51:31.254 INFO - Could not load 64 bit native libraries - attempting 32 bit i
nstead Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'vpx': The specified module could not be found.
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at com.aimmac23.node.jna.JnaLibraryLoader.tryLoadLibraries(JnaLibraryLoader.java:125)
at com.aimmac23.node.jna.JnaLibraryLoader.tryBitDepth(JnaLibraryLoader.java:150)
at com.aimmac23.node.jna.JnaLibraryLoader.init(JnaLibraryLoader.java:110)
at com.aimmac23.node.RecordVideoCallable.<clinit>(RecordVideoCallable.java:26)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.aimmac23.node.servlet.VideoRecordingControlServlet.<clinit>(VideoRecordingControlServlet.java:40)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.openqa.grid.web.utils.ExtraServletUtil.createServlet(ExtraServletUtil.java:38)
at org.openqa.grid.internal.utils.SelfRegisteringRemote.startRemoteServer(SelfRegisteringRemote.java:123)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:115)
Please Help me.
Thank you in advance
Try using the latest video node which at 2015-02-06 is https://aimmac23.com/public/maven-repository/com/aimmac23/selenium-video-node/1.6/
I'm running on a 64 bit machines - it may be that if the 64 bit native libraries don't load then the 32 bit libraries are loaded and the exception you're seeing the exception from the first attempt. You can check for yourself, the code is at: https://github.com/aimmac23/selenium-video-node
-Anton

Exception by using SafariDriver

I'm trying to run selenium safari driver.
My code is: driver = new SafariDriver();
But I get the following exception:
Caused by: java.lang.NoClassDefFoundError: org/jboss/netty/channel/ChannelFactory
at org.openqa.selenium.safari.SafariDriverCommandExecutor.<init>(SafariDriverCommandExecutor.java:76)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:58)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:42)
at com.ca.automation.utils.WebDriverFactory.initWebDriver(WebDriverFactory.java:168)
at com.ca.automation.utils.WebDriverFactory.getWebDriver(WebDriverFactory.java:210)
at com.ca.automation.utils.BaseSelenium.<init>(BaseSelenium.java:43)
at com.ca.automation.pb.strategicPlanning.CrudDriversBTest.<init>(CrudDriversBTest.java:20)
There could be a solution: Selenium 2 WebDriver NoClassDefFoundErrorS. You just need to use the standalone version or add all the jars to the build path.

Selenium Grid 2 from mac hub to windows node

I am setting up selenium grid to be able to test IE in a Virtual Machine. I am running into:
geb.driver.DriverCreationException: failed to create driver from callback
which generally means the driver is not being found. I'm pointing it to the correct location, however something isn't working. FYI refers to my hub machine's intranet IP address.
Here are my files/commands:
From Mac hub terminal:
java -jar selenium-server-standalone-2.39.0.jar -role hub
From Windows node terminal:
C:\selenium-server>java -jar selenium-server-standalone-2.39.0.jar -role node -hub http://:4444/grid/register -browser browserName="internet explorer",version=10.0,platform=WINDOWS -Dwebdriver.ie.driver=C:\IEDriverServer.exe
My GebConfig.groovy file where the drivers are instantiated:
ie {
driver = {
DesiredCapabilities capabilities = new DesiredCapabilities().internetExplorer().
new RemoteWebDriver(new URI("http://<IP>:4444/wd/hub"), capabilities)
}
}
My stack trace is as follows:
geb.driver.DriverCreationException: failed to create driver from callback 'script13923985022291935133551$_run_closure2_closure5_closure9#557c6200'
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:80)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
at geb.Configuration.createDriver(Configuration.groovy:354)
at geb.Configuration.getDriver(Configuration.groovy:343)
at geb.Browser.getDriver(Browser.groovy:105)
at geb.Browser.go(Browser.groovy:394)
at geb.Page.to(Page.groovy:184)
at geb.Browser.via(Browser.groovy:475)
at geb.Browser.to(Browser.groovy:434)
at geb.Browser.to(Browser.groovy:412)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at com.bloomhealthco.functional.LoginTestSpec.User is able to login as an administrator(LoginTestSpec.groovy:12)
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.openqa.selenium.remote.RemoteWebDriver(java.net.URI, groovy.util.ConfigObject)
at script13923985022291935133551.run_closure2_closure5_closure9(script13923985022291935133551.groovy:44)
at script13923985022291935133551.run_closure2_closure5_closure9(script13923985022291935133551.groovy)
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
... 14 more
geb.driver.DriverCreationException: failed to create driver from callback 'script13923985022291935133551$_run_closure2_closure5_closure9#557c6200'
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:80)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
at geb.Configuration.createDriver(Configuration.groovy:354)
at geb.Configuration.getDriver(Configuration.groovy:343)
at geb.Browser.getDriver(Browser.groovy:105)
at geb.report.PageSourceReporter.getPageSource(PageSourceReporter.groovy:42)
at geb.report.PageSourceReporter.writePageSource(PageSourceReporter.groovy:38)
at geb.report.PageSourceReporter.writeReport(PageSourceReporter.groovy:29)
at geb.report.CompositeReporter.writeReport(CompositeReporter.groovy:31)
at geb.Browser.report(Browser.groovy:775)
at geb.spock.GebReportingSpec.report(GebReportingSpec.groovy:44)
at geb.spock.GebReportingSpec.cleanup(GebReportingSpec.groovy:39)
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.openqa.selenium.remote.RemoteWebDriver(java.net.URI, groovy.util.ConfigObject)
at script13923985022291935133551.run_closure2_closure5_closure9(script13923985022291935133551.groovy:44)
at script13923985022291935133551.run_closure2_closure5_closure9(script13923985022291935133551.groovy)
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
... 14 more
geb.driver.DriverCreationException: failed to create driver from callback 'script13923985022291935133551$_run_closure2_closure5_closure9#557c6200'
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:80)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
at geb.Configuration.createDriver(Configuration.groovy:354)
at geb.Configuration.getDriver(Configuration.groovy:343)
at geb.Browser.getDriver(Browser.groovy:105)
at geb.Browser.clearCookies(Browser.groovy:483)
at geb.Browser.clearCookiesQuietly(Browser.groovy:491)
at geb.spock.GebSpec.resetBrowser(GebSpec.groovy:45)
at geb.spock.GebSpec.cleanup(GebSpec.groovy:67)
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.openqa.selenium.remote.RemoteWebDriver(java.net.URI, groovy.util.ConfigObject)
at script13923985022291935133551.run_closure2_closure5_closure9(script13923985022291935133551.groovy:44)
at script13923985022291935133551.run_closure2_closure5_closure9(script13923985022291935133551.groovy)
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:29)
... 11 more
Additionally the node can be registered with the hub:
ip:4444/grid/console screenshot
I've been searching all day and it seems this should work. Does anyone have any suggestions or know what's wrong?
Thank you in advanced.
From your stacktrace I can see that the real reason for not being able to create the driver is:
Could not find matching constructor for: org.openqa.selenium.remote.RemoteWebDriver(java.net.URI, groovy.util.ConfigObject)
Is the snipped of your GebConfig.groovy exactly the same as you have it in your file? I see that capabilities is defined as an instance of DesiredCapabilities in your snippet so I don't understand why would a config object be passed as the second parameter... I can't see it but maybe you have a typo somewhere? With Groovy config scripts you'll have issues if you mistype something as you will get a new empty ConfigObject instance instead of an error.
The second thing is that the first parameter should be an URL and not a URI if you're after using this constructor.

Can't use RemoteWebDriver(Ghost,Phantom) via Selenium Grid2

I tried GhostDriver and Phantomjs today.
When I use GhostDriver, it works well.
start like this
phantomjs --webdriver=8910
then
new RemoteWebDriver(new URL("http://localhost:8910"), sCaps);
My selenium test case can pass.
Then I tried to use Selenium2Grid,
so I start selenium standalone server as a hub:
D:\_Try\selenium>java -jar selenium-server-standalone-2.31.0.jar -role hub
2013-3-20 14:13:49 org.openqa.grid.selenium.GridLauncher main
信息: Launching a selenium grid server
2013-03-20 14:13:50.026:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2013-03-20 14:13:50.060:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
2013-03-20 14:13:50.068:INFO:osjs.AbstractConnector:Started SocketConnector#0.0.0.0:4444
then register GhostDriver to the hub
C:\Users\administrator>phantomjs --webdriver=8910 --webdriver-selenium-grid-hub=http://localhost:4444
PhantomJS is launching GhostDriver...
Ghost Driver running on port 8910
Registered with grid hub: http://localhost:4444/ (ok)
then I checked the registration via the Grid console: http://localhost:4444/grid/console and found phantomjs has already registered.
so I modified the code, the client should visit the grid:
new RemoteWebDriver(new URL("http://localhost:4444"), sCaps);
re-run the selenium test case,
I thought it would work well, but exception throws:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at net.pipitest.selenium.trial.ghost.BaseTest.prepareDriver(BaseTest.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
I debugged into the code,
found that in RemoteWebDriver.class, the response is the source code of Selenium Grid Page (http://localhost:4444)
which should be a MAP Object like this(the below is what I get When using GhostDriver directly):
[platform=windows-7-32bit, acceptSslCerts=false, javascriptEnabled=true, browserName=phantomjs, rotatable=false, locationContextEnabled=false, version=phantomjs-1.8.1+ghostdriver-1.0.2, databaseEnabled=false, cssSelectorsEnabled=true, handlesAlerts=false, browserConnectionEnabled=false, webStorageEnabled=false, proxy={proxyType=direct}, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=false]
Does anyone meet this problem before?
Or any suggestions?
Thanks in advance.
java -jar selenium-server-standalone-2.31.0.jar -role hub - run selenium grid hub
phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http ://localhost:4444 - run webdriver on port 8080 and integration with selenium grid
new RemoteWebDriver(new URL("http://{lh or remote ip}:8080"), dCap); run PhanomJSDriver in dCap must be phantomjs capability
I had a similar problem, and the solution was simply to use
URL("http://localhost:4444/wd/hub")
instead of
URL("http://localhost:4444/")