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/")
Related
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
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)
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.