Friday, March 5, 2010
Check that Java is installed in your system by using the command “java -version”. If Java is installed it will give the output about Java Version that is installed in your system. Else download the Java from Java website (http://www.java.com/en/download/index.jsp).
Check ANT is installed in your system by using the command “ant -version”.If Ant is installed it will give the output about Ant Version that is installed in your system. Else download the Apache Ant from Apache website (http://ant.apache.org/).
Download Selenium Grid from Selenium Grid website(http://selenium-grid.seleniumhq.org/download.html) and unpack it.
Go to the Unpacked directory of the Selenium grid using command prompt and type the command “ant launch-hub”. This will launch the Selenium Grid Hub on a default port “4444” to check whether the selenium grid is running. Type the URL “http://localhost:4444/console ” on your browser and check that you are able to see the selenium hub console on the browser.
Now go to the same Selenium Grid directory using command prompt and type the command “ant launch-remote-control”. This will start the Selenium Grid Remote control on default port “5555” and environment “*firefox” and register it to the Hub which you had earlier started.
Now after starting the selenium remote control we will test the example provided with Selenium Grid for sequence testing in single machine. For this go to the Selnium grid folder from command prompt and type the command “ant run-in-demo-sequence”. This will execute the test example provided with selenium grid to be executed in sequence.
Now you may had noticed in the setting up steps that I am running the test in sequence. You may think in your mind that, what's special in that? The same things can be achieved when we use a Selenium RC.Then here comes the important part of Selenium Grid.
Setting up Parallel execution on a single machine
Start the hub and one remote control in the same way as in the earlier setting up steps.
Now go to the Selenium Grid folder using command prompt and type the command
“ant -Dport =5556 launch-remote-control”
This will start another remote control on port “5556” and register it to the local hub. If you want to register more remote control to the Hub. You can do that by starting multiple remote control but with different ports.
To know the no. of registered remote control onto a hub go to the URL “http://localhost:4444/console”. It will give you a view as follows:
Now to run the test in parallel. Go to the selenium grid directory using command prompt and type the command “ant run-demo-in-parallel”. This will run the example tests given with selenium grid in parallel.
Setting up parallel execution for different machines and different environments
In this case start the Hub normally as you do in any of the system.
For starting the remote control use the following command.
ant -Dport=<port> -Dhost=<hostname> -DhubURL=<hub> -Denvironment=<environment> launch-remote-control
Here
“-Dport” should be used to set the port of the remote control.
“-Dhost” should be used to set the host(where the remote control has been started) IP. This is the IP which the hub will use to talk to the remote control.
“-DhubURL” should be used to set the Hub Url where the current remote control will register itself.
“-Denvironment” should be used to set an environment name that remote control represents to the hub.
Now start 4 different remote controls from 2 different machines and register them to the hub.
After this check the Hub console. It will look similar to the table as shown below depending upon the remote control that are registered to the Hub.
Then to verify your set-up go to the Selenium Grid folder from the command prompt and type the command “ant run-demo-in-parallel”
This will run an example test accompanied with the Selenium Grid to run in parallel.
Advantages of Selenium Grid
Remote Execution of the selenium tests can be done using Selenium Grid without actually copying your test code to to remote system.
Selenium Grid can be used to save time by executing independent testcases in parallel.
Load Testing can be done if we register a lot of remote control to a single hub and execute testcase in parallel to simulate multiple transactions at a single timeperiod.
25 comments :
Hi there,
Just tried to follow the example using the command:
ant -Denvironment='*firefox' -Dport=5555 -Dhost=10.112.4.203 -DhubURL=192.168.100.126:4444 -Denvironment="Firefox on Windows" launch-remote-control
and got the following exception:
Exception in thread "main" java.lang.IllegalStateException: unsupported protocol '192.168.100.126'
Any suggestion?
thanks in advance
Antonio
Try using -DhubURL=http://192.168.100.126:4444 in your argument.
It worked!!!
Thanks
Any Idea how you can set this up as a windows service?
@Daniel: I never tried it as a service. But you can try creating a batch file and putting that batch file to the "Startup" folder under the programs menu of windows.
I tried this thing for something else long back.
any idea how to use maven instead of ant with selenium grid
while working with grid, remote machine are not opening the browser or means there is no response from remote machine. Although console shows the remote machine as available host, but when we are running scripts, then in active host remote machine is not listed.can u help us y so??
Hi @dinu,
The above thing can be used when you are using the selenium 1 api.
If you are using the same and having the problem You can send a mail to me at mr.varun.menon@gmail.com directly with the details on how you are instantiating the selenium object and all. I will reply to it.
Regards
Varun
i tried following command:
ant -Dport=5555 -Dhost=xx.xx.xx.xx -Denvironment="*firefox" launch-remote-control
Result - able to see the settings in grid console
Again
ant -Dport=5556 -Dhost=xx.xx.xx.xx -Denvironment="*firefox" launch-remote-control
Result -
BUILD FAILED
Target "ûDport" does not exist in the project "Selenium Grid Distribution".
Pls suggest me. thanks in advance
-balakrishna
i configured remote controls in selenium grid successfully. Now i want to how to remove available and remote controls and also how to stop the hub.
pls suggest me. waiting for your reply
Just press Ctrl+C on the cmd prompt where the RC were started using ant.
thanks alot
Hi am facing the following issue when is use "ant run-demo-in-parallel"
[java] Feb 17, 2012 5:48:39 PM com.thoughtworks.selenium.grid.tools.ThreadS
afeSeleniumSessionStorage closeSeleniumSession
[java] INFO: Closing Selenese session: com.thoughtworks.selenium.DefaultSel
enium@e28b9
[java]
[java] ===============================================
[java] Selenium Grid Demo In Parallel
[java] Total tests run: 4, Failures: 4, Skips: 0
[java] ===============================================
[java]
BUILD FAILED
C:\Program Files\selenium-grid-1.0.8\build.xml:137: Java returned: 1
Total time: 0 seconds
pls suggest me sir!
thanks in advance!.
Hi Varun I successfully installed selenium grid.By following your step.But how to run my test cases in other machine which r having in ecilips.
You are using selenium RC or webdriver? For selenium RC DefaultSelenium class to create selenium object and pass the remote system URL.
For WebDriver use RemoteWebDriver class.
Hi Varun So far I have installed grid and also able to launch different servers to different port. But I am confused with script execution.
After setting up every thing How to run scripts.
Currently I have two scripts created and wanted to run in Parallel on same machine and with same browser. So my question how to run this.
Can you try with the new setup of webdriver mentioned in the following link
http://blog.varunin.com/2011/10/selenium-grid-with-webdriver.html
Thanks Varun for Reply but I have scripts created in JUnit and for batch execution I am using Ant and build.xml.
Is there any way to execute using ant.
Hi,
We have requirement like as soon as the application build deployment has been done, need to execute my jenkin jobs automatically.
Please suggest me on this.
Thanks,
Mahesh
Add the said automation job as a dependent job of your build deployment.
Look at post build task in jenkins
Thank you for response.
As per my understand for "post build task" plugin build deployment also need to done with Jenkins(to execute a shell/batch task depending on the build log output), but we have tool for build deployment, build information will store in log file, how do I map build log file to Jenkins to execute shell/batch.
Post a Comment