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.
Related
Is there any specific reason why we use GridlauncherV3, Currently doing a project where I use custom servlets for executing some task
For launching node:
java -Dwebdriver.chrome.driver=chromedriver -cp testservlet.jar:selenium-server-standalone.jar org.openqa.grid.selenium.GridLauncherV3 -role node -maxSession 10 -port 4444 -host localhost -hub http://localhost:4444/grid/register -browser browserName=chrome,version=103,platform=LINUX,maxInstances=10 -servlets testservlet.copies.DemoServlet,testservlet.copies.Demo2Servlet
Couldn't find any reason but if removed it throws an error, Were it needs a params
Unrecognized option: -role
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Thanks in advance.
As you are using are using java -cp, it is a requirement to specify the class that contains the main() method.
In the case of creating a jvm to run as selenium grid, you require the class that contains the main() method, in this case that is org.openqa.grid.selenium.GridLauncherV3.
This method is used to initiate the grid with all the required configuration in your cli command.
See the method here: GridLauncherV3
I've been using the selenium-server-standalone-2.53.0.jar and recently tried to upgrade to version 3.0.0-beta3.
I'm attempting to spin-up a hub using the maxInstances parameter with the following command:
java -jar %~dp0DriverRepo\selenium-server-standalone-3.0.0-beta3.jar -role hub -port 5555 -maxInstances 9
This was working in 2.53.0, but in 3.0.0-beta3 I'm met with the following exception:
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -maxInstances
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$2.setConfiguration(GridLauncherV3.java:224)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:138)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:67)
Apparently maxInstances is no longer a valid argument. I've searched for documentation regarding any changes that may have been made for use of the maxInstances parameter but I've had no luck. Has anyone else run into this issue, or is anyone aware of the proper way to spin-up a hub in 3.0.0-beta3 in a comparable way?
I don't remember ever using an argument called maxInstances. I think that earlier there was no validation for invalid command line arguments but with Selenium 3, they perhaps enabled it.
Here's an example of why I feel my theory is true
Selenium 2.53.1 output wherein I am providing an invalid argument named krishnan
selenium-server -role hub -krishnan 100
22:28:37.762 INFO - Launching Selenium Grid hub
2016-09-26 22:28:38.366:INFO::main: Logging initialized #758ms
22:28:38.378 INFO - Will listen on 4444
22:28:38.421 INFO - Will listen on 4444
2016-09-26 22:28:38.424:INFO:osjs.Server:main: jetty-9.2.z-SNAPSHOT
2016-09-26 22:28:38.452:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#32eebfca{/,null,AVAILABLE}
2016-09-26 22:28:38.479:INFO:osjs.ServerConnector:main: Started ServerConnector#6ec8211c{HTTP/1.1}{0.0.0.0:4444}
And here's how Selenium 3 beta version behaves for the same command line.
java -jar selenium-server-standalone-3.0.0-beta2.jar -role hub -krishnan 100
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -krishnan
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.openqa.grid.selenium.GridLauncherV3$2.setConfiguration(GridLauncherV3.java:216)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:130)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:67)
Selenium has never had any argument named maxInstances. It only had something called maxSession`.
The only usage for maxInstances has been within a node configuration file as shown here which is passed to a Selenium node via the -nodeConfig argument. This represents the number of concurrent browser instances per browser flavor that can be opened up in a node.
Plese Help me
How do I instantiate the Safari in selenium grid
capabilities = new DesiredCapabilities();
// Version browser
capabilities.setVersion(versaoBrowser);
capabilities.setBrowserName("safari");
capabilities.setJavascriptEnabled(true);
// Platform test runner
capabilities.setPlatform(platform);
On the server is weel
-browser "browserName=safari,version=5,platform=WINDOWS,javascriptEnable=true"
If the question is about using Safari the new way, with SafariDriver over Grid2, then this would be the typical method I believe (more or less):
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import java.net.*;
DesiredCapabilities c = new DesiredCapabilities();
c.setBrowserName("safari");
/* you can then set version & platform as well, but the minimum is just browser. Maybe for Grid2 you need the others, but for remote web driver only, you don't.
*/
WebDriver d = new RemoteWebDriver(new URL("http://hubIpOrHostname:hubPort/wd/hub"),c);
and that should work. On the server side, I believe you just instantiate normally for Grid2 per the wiki docs (last I check, could be diff now):
//start hub
java -jar selenium-server-standalone-2.21.0.jar -role hub -port theHubPort
//start the node
java -jar selenium-server-standalone-2.21.0.jar -role node -hub http:
//172.22.6.198:4446/wd/hub -port theNodePort
however, seems that the current Grid2 doesn't offer Safari support. When I looked up the console for the registered node in hub, it didn't show icon for Safari. Maybe I missed something. I'll try adding platform and version next time to see if that makes a diff but think not.
Here's a snippet of the error I get for Grid2 with SafariDriver:
May 11, 2012 6:01:11 PM org.openqa.selenium.remote.RemoteWebDriver execute
INFO: Executing: [null, newSession {"desiredCapabilities":"Capabilities [{browse
rName=safari}]"}]
// Error: // Uncaught Exception: Typed variable declaration : Object constructor
: at Line: 7 : in file: : new RemoteWebDriver ( new URL ( "http:
//172.22.6.198:4446/wd/hub" ) , c )
Target exception: org.openqa.selenium.WebDriverException: Error forwarding the n
ew session cannot find : {browserName=safari}
Command duration or timeout: 109 milliseconds
To note: with webdriver, same code can be used for (standalone) remote webdriver execution vs grid, difference is that for remote you use remote server ip and with grid2, you use hub ip. SafariDriver works over remote webdriver, but currently doesn't seem to work over Grid2 yet.
remote webdriver startup:
java -jar selenum-server-standalone-2.21.0.jar [-port somePort]
//default port of 4444
I believe what you are asking for is something like this?
selenium = new DefaultSelenium("localhost", 4444, *safari,"http://google.com.au");
selenium.start();
I generally use WebDriver, but my understanding is capabilities are options for when you create an instance of a browser, not to open the browser itself. Though I could be wrong as I am not experienced with Selenium Grid.
EDIT: This and this might help.
I have this problem. When on different computer, I start HUB and NODE and then run my tests where I initialize Google Chrome like this:
Selenium selenium = new DefaultSelenium("localhost", 4444, *googlechrome, "http://www.google.com");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized"));
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
Everything runs ok on my computer - Chrome comes up and does the script. However, If my friend tries to do exactly the same, she gets this error:
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_29'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:435)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:102)
at com.deutscheboerse.test.PerfTests.<init>(PerfTests.java:52)
at com.deutscheboerse.test.EUAStressTest.myTest(EUAStressTest.java:37)
at com.deutscheboerse.test.EUAStressTest.main(EUAStressTest.java:60)
Caused by: org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 4422; received: 3743
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:197)
at org.apache.http.impl.io.ContentLengthInputStream.close(ContentLengthInputStream.java:105)
at org.apache.http.conn.BasicManagedEntity.streamClosed(BasicManagedEntity.java:152)
at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:237)
at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:186)
at org.apache.http.util.EntityUtils.consume(EntityUtils.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor$EntityWithEncoding.<init> HttpCommandExecutor.java:399)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:287)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:415)
... 6 more
So far only difference what I found is, that hers hub is listening on http://10.10.190.134:5555 mine is listening on http://10.131.7.44:5555 but both can access the console on same IP and port. I dont have any clue whats wrong. Everything is appreciated, thanks
** EDIT **
Iried to run it on another computer and I had the same error. Little debugging showed me this message:
11:04:01.899 WARN - Exception: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
So, prior setting up the Chrome in Selenium Grid, I need to do this:
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, "chromedriver.exe");
I tried to do it and stil unable to run the Chrome... Any help is still wanted
EDID2
This is how I exactly set the property:
File file = new File("lib/chromedriver.exe");
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, file.getAbsolutePath());
I am using this approach because I need to run it on more computer and the JAR file can have different locations.
BTW, the warning is found in window with Selenium Grid in role node. I am thinking, if there is any other switcher. So far I am running these commands:
java -jar lib//selenium-server-standalone-2.20.0.jar -role hub
java -jar lib/selenium-server-standalone-2.20.0.jar -role node -hub http://localhost:4444/grid/register -maxSession 12
and then my JAR. The exception is in window with the NODE. Is there any switcher?
After a day searching, I have working solution. Everything is in how do you start the node. So first, do the usual:
java -jar lib/selenium-server-standalone-2.20.0.jar -role hub
Then start the node like this:
java -jar lib/selenium-server-standalone-2.20.0.jar -role webdriver -hub http://localhost:4444/grid/register -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=5 -Dwebdriver.chrome.driver=lib\chromedriver.exe
More specifically: You have to start up the NODE with parameter browser and add -D parameter specifying the full path to the ChromeDriver
My huge thanks goes to John Naegle who answered similar question here on SO regarding the Internet Explorer - see here
That's funny, but webdriver cannot resolve dns, http://localhost:4444/
I edited my host file, uncommented line:
127.0.0.1 localhost
And It's done.
Ok, I have already several testcases written for Webdriver approach. But now I need get the Selenium Grid for possible stress testing of the webapp.
I found this demo but its unable to control the Firefox 11. Then I found out this wiki page which is two level higher than I can understand, but that JAR File is supposedly able to control the Firefox 11.
What I need - some resources how to get the Grid started and how to let it do simple test - like writing "Hello World" into Google search bar and then clicking "Search."
EDIT
This is the error when I am trying to run the grid as node
D:\_dev\selenium-grid-1.0.8\lib>java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://localhost:4444/grid/register
22-Mar-2012 10:33:48 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid node
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.String.isEmpty()Z
at org.openqa.grid.common.RegistrationRequest.getRemoteControlConfiguration(RegistrationRequest.java:585)
at org.openqa.grid.internal.utils.SelfRegisteringRemote.startRemoteServer(SelfRegisteringRemote.java:86)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:72)
And this is output from server which seems ok
D:\_dev\selenium-grid-1.0.8\lib>java -jar selenium-server-standalone-2.20.0.jar -role hub
22-Mar-2012 10:33:33 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid server
360 [main] INFO org.seleniumhq.jetty7.server.Server - jetty-7.x.y-SNAPSHOT
422 [main] INFO org.seleniumhq.jetty7.server.handler.ContextHandler - started o.s.j.s.ServletContextHandler{/,null}
438 [main] INFO org.seleniumhq.jetty7.server.AbstractConnector - Started SocketConnector#0.0.0.0:4444
If you are working with windows, you need to add the path to firefox to your PATH environment variable. The reason for this is, that windows then knows what program to start, when you call firefox from command line, for example.
Then you need to donwload the selenium server standalone and then start the hub
java -jar selenium-server-standalone-2.20.0.jar -role hub
and also the client:
java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://localhost:4444/grid/register
Now you need to create a new Java Project in Eclipse, for example like so:
class MyFristTest{
//using the #test annotation tells eclipse
//to use junit (or tells you to import it)
#Test
public void myTest(){
Selenium selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://www.google.com”);
DesiredCapabilities capability = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
driver.get("http://www.example.com");
driver.findElement(By.linkText("RFC 2606")).click();
driver.findElement(By.linkText("txt")).click();
}
If you now start the JUnit Test, it should magically work.