Running Parellel selenium Test Cases Without TestNG or Junit - selenium

How to run Selenium Test Cases parallely without using TestNG or JUnit.
Currently i am using the command
Client(Node) command :
java -jar selenium-server-standalone-2.35.0.jar -role node -hub
Protocol://host:4444/grid/register -browser browserName=firefox,platform=WINDOWS maxInstances=3.
But its not working.
I Need to execute one/many test cases parelley(at a time 5) in Firefox

Java -jar selenium-server-standalone-2.35.0.jar -role node -hub Protocol://host:4444/grid/register -browser browserName=firefox,platform=WINDOWS maxInstances=3.
But its not working.
It won't work. By running the above command you are setting up selenium grid to run 3 instances of test IF and When it gets 3 requests. You need to write the logic to pass three instances of tests pointing to the hub in parallel for the node to work its magic.
To run tests in parallel using java, you need to create logic using multithreading. You should take care to
make your classes thread safe
Specify which tests to run
Create a report of testing so that others can know what your test is doing
Or you can use JUnit or testNG which will do most of these for you.

You could do it using Maven Surefire, which has parallel running capability. You would only want to use TestNG if you need to parameterize. Surefire creates a pretty ok test report also.

Related

How to run multiple selenium processes at a time with nightwatch?

I'm using nightwatch to run tests in parallel. I would like to be able to run multiple tests at a time in different selenium processes. How can I accomplish that?
What I did is create a selenium hub:
java -jar /opt/selenium-server-standalone-2.53.0.jar -Dwebdriver.chrome.driver=/usr/bin/chromedriver -Dwebdriver.chrome.bin=/usr/bin/google-chrome -log /home/jenkins-user/log/selenium.log -role hub &
And when each test runs, I create a node:
java -jar /opt/selenium-server-standalone-2.53.0.jar -Dwebdriver.chrome.driver=/usr/bin/chromedriver -Dwebdriver.chrome.bin=/usr/bin/google-chrome -log /home/jenkins-user/log/selenium.log -role node -browser browserName=chrome -hub http://localhost:4444/grid/register &
Unfortunately, this prevents me from running nightwatch tests in parallel.
What am I doing wrong?
Why do you want to start multiple selenium processes? You should not do that.
Check my answer for similar question: Running multiple nightwatch instances

Unable to run RC commands under Selenium Grid 2

I've tried this on multiple versions of selenium 2 (from 2.24-2.28) and on two different systems. It's a very simple scenario. I want to run RC commands via Selenium Grid and I don't want to port my 1000+ test scripts to WebDriver, so hopefully that's not the only solution.
Test case:
1) START HUB:
java -jar selenium-server-standalone-2.28.0.jar -role hub
2) START NODE:
java -jar selenium-server-standalone-2.28.0.jar -role node -hub http://localhost:4444/grid/register
(I've tried every variation of this I could think of, including -role rc)
Communications seem fine between the two. The console status is up and shows the connection between the two.
3) REQUEST RC URL:
http://localhost:4444/selenium-server/driver/?cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
Output is always:
HTTP ERROR: 500
Problem accessing /selenium-server/driver/. Reason:
java.lang.NullPointerException
If I revert to non-grid mode, the request returns as expected.
Am I missing something or is RC simply not supported under Grid 2?
This seems to be fixed for *firefox as a browser in 2.30 however I still observe the same behaviour for *googlechrome

Selenium-PHPUnit, Selenium Grid

Before posting this I checked a lot on this site and on google to figured out my problem.
I am testing my web application which is principally coded in PHP using Symfony2 framework.
I am using Selenium to do my functional tests. All I want to do for the moment is to run my functional tests in parallel on my local machine using Selenium Grid. What I do is recording the test on Selenium IDE and export the test case in phpunit format. I tried to use selenium grid but my phpunit tests are still running sequentially.
What I did:
1) java -jar selenium-server-standalone-2.24.1.jar -role hub
2) java -jar selenium-server-standalone-2.24.1.jar -role node -hub http://localhost:4444/grid/register -browser "browserName=firefox,maxInstances=2,maxSession=2"
3) ant
There is in my build.xml a phpunit target:
<target name="phpunit" description="Run unit tests">
<exec executable="phpunit" failonerror="true"/>
</target>
In my phpunit.xml this part of code is present:
<testsuites>
<testsuite name="LoginSuite">
<file suffix="Test.php">../../src/Tests/FunctionalTests/LoginSuite_testLoginTest.php</file>
</testsuite>
</testsuites>
And my LoginSuite_testLoginTest.php looks like this:
<?php
namespace Tests\FunctionalTests;
use Tests\FunctionalTests\SetUpTest;
class LoginSuite_testLoginTest extends SetUpTest
{
public function testLogin()
{
$this->open("/home");
$this->click("link=Login");
$this->type("id=username", "test.user#gmail.com");
$this->type("id=password", "test");
$this->click("id=_submit");
$this->waitForPageToLoad("30000");
}
public function testLogin2()
{
$this->open("/home");
$this->click("link=Login");
$this->type("id=username", "test.user2#gmail.com");
$this->type("id=password", "test");
$this->click("id=_submit");
$this->waitForPageToLoad("30000");
}
}
?>
At the third step when I launch ant command I am getting a jetty error 500 Problem accessing /selenium-server/driver/
If instead of doing:
java -jar selenium-server-standalone-2.24.1.jar -role node -hub http://localhost:4444 /grid/register -browser "browserName=firefox,maxInstances=2,maxSession=2"
I do the same command without -browser informations it launches my tests but not in parallel..., so strange.
I saw that to launch phpunit tests in parallel we have to create our own script to do it. So in this case do I need selenium grid or not?? I am very confused. Thanks for your help.
There is a parallel wrapper for phpunit command line https://github.com/siivonen/parallel-phpunit so you don't need to write it. You need to have Selenium Hub (with some nodes connected to it) running somewhere. Then you run your tests pointing to that location and the Hub will proxy the calls to free nodes.
We use parallel-phpunit and Selenium Grid with four nodes connected to a hub. Our CI runs 30 minutes of Selenium tests in 3 minutes.
There could be different issues. One is, while running pre recorded steps, you should add seleniumProtocol=Selenium in "browser" argument, because by default it will be the webdriver.

Selenium grid2: how to run multiple tests against a single node?

I fear this is a very trivial question. But I'm having some trouble getting selenium Grid2 to run multiple test against a single node, from my understanding this should be possible by setting maxSessions.
This is my setup:
-Hub runs completly standard
-Node runs firefox with 5instances and 5 sessions enabled.
I've created 6 dummy tests using MBUNIT and added [Paralizable] to make them run side by side.
This is what I've done to test:
1: Start 2 nodes and run all tests (they run in parallel one on each node)
2: Turn off nodeA and run all tests
In step 2 is where i get stuck, i expected the last node would run 2 tests at once since the maxSessions is set to 5 but this doesn't happen, it only runs 1.
I suspect I've used a wrong parameter when starting the hub or node somewhere but right now i can't figure it out. anybody who want to help a newbie at Grid2? :)
This is roughly my code, very basic just for playing around:
[TestFixture]
public class RemoteTest
{
[Test]
[Parallelizable]
public void StartClose()
{
DesiredCapabilities cap = DesiredCapabilities.Firefox();
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), cap);
driver.Navigate().GoToUrl("http://www.google.dk");
driver.Quit();
}
}
Commands used:
java -jar selenium-server-standalone-2.14.0.jar -role hub
java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://192.168.0.26:4444/grid/register
no question is trivial :)
To start a server (use the following command)
java -jar selenium-server-standalone-2.14.0.jar -role hub
To start a Node (use the following command)
java -jar selenium-server-standalone-2.14.0.jar -role node -hub
http://localhost:4444/grid/register
Incase if u had tried to start a node with browsers as well (check the following command)
-browser browserName=firefox,version=3.6,maxInstances=5,platform=LINUX
maxInstances --> Signify the Max instances of same browser that can run on a Grid node
Selenium Grid: MaxSessions vs MaxInstances
If you specify capabilities in your test case that do not exist on your grid then there will be no match and the test will fail to run.
Please avoid running the tests from the Nodes and instead run tests from hub. I tried the same experiment where I ran the tests from the server (HUB) and I registered a node for running parallel test cases and everything worked perfect.

How to run Selenium tests in Grid in one browser window?

When using only Selenium server it was possible to run the tests in the single browser window with the setting
-java -jar selenium-server-standalone-2.2.0.jar -singleWindow
When switched to grid 2, -singleWindow parameter is not working anymore.
Help is really appreciated.
Made it happen by running the following line:
java -jar selenium-server-standalone-2.2.0.jar -role webdriver -singleWindow -hub http://192.168.1.149:4444/grid/register -port 5557
Seems like the order of the parameters is important.