1

I have only one test case and i want to run that particular test case on two different machines say one in windows and other linux. How can i configure my nodes or selenium framework so that it can run my test case parallely on different machines at the same time.I have done following changes in my framework to run it on single machine.

  DesiredCapabilities cap = new DesiredCapabilities();
  cap.setBrowserName("firefox");
  cap.setPlatform(Platform.ANY);
  driver = new RemoteWebDriver(new URL(nodeURL), cap);
kittudk
  • 55
  • 3
  • 14
  • Have a look at p.1 in my answer to a [similar question](http://stackoverflow.com/questions/14385052/selenium-grid-on-multiple-browsers-should-each-test-case-have-separate-class-fo/14648596#14648596) – Sergio Pelin Aug 01 '13 at 15:04

2 Answers2

1

Step 1 - create two runnable JAR files (my own approach) containing the one test for linux and one test for windows. Possibly differentiate by this line:

cap.setPlatform(Platform.LINUX);

and

cap.setPlatform(Platform.WINDOWS);

Capabilities taken from head, so pleasde doublecheck

Step 2 - start hub and two nodes

Step 3 - run the two JARs from your computer (assuming the JAR will have configured where the hub is). The hub will assign tests to nodes automatically

If you have additional questions, ask me ;)

Pavel Janicek
  • 14,128
  • 14
  • 53
  • 77
  • yes , I have tried this approach and this works ... But what if i have to run it on 4-5 machines then everytime i cant run 5 jar's containing test. I wanted an approach to solve it in one shot. Run the jar once and test execution must take place on five different machines. Is it possible ?? – kittudk Jul 29 '13 at 16:41
  • It is possible, but in my own case I made deal with developer to help me out with this. On another project I am running just one JAR file against 80 machines. But the code is bit cryptic to me, so I cannot help you with the realisation of this... – Pavel Janicek Jul 30 '13 at 06:35
1

I think you can try TestNG.

On my approach I have two parameters: OS and BROWSER. With testng.xml you can create your testsuite with those parameters like this:

 <?xml version="1.0" encoding="iso-8859-1"?>
   <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
   <suite name="Your_suite" verbose="2" **parallel**="tests" >

   <test name='Your_Test_Name'>
       <parameter name='os' value='**WINDOWS**'/>
       <parameter name='browser' value='CHROME'/>
        <classes>
            <class name='tests.AnyTest'/>
        </classes>
   </test>

   <test name='Your_Test_Name'>
       <parameter name='os' value='**LINUS**'/>
       <parameter name='browser' value='FIREFOX'/>
        <classes>
            <class name='tests.AnyTest'/>
        </classes>
   </test>

  </suite>

So I can run my test on windows, linux, macOS, android or iphone, and the most important thing, I don't have to change my code.

Hope it helps.

Héctor Flores
  • 253
  • 2
  • 9
  • Thanks @Hector .. where should we mention our node URL's in the code itself or pass it as an argument ?? – kittudk Jul 31 '13 at 06:59
  • With TestNG you can add parameters like URL, Partner, Username, Password, ... And you can define those parameters for your test suite or for each test case. – Héctor Flores Jul 31 '13 at 13:29
  • @HéctorFlores is this available in c# as well, with Nunit .? – Ak02 Oct 01 '19 at 06:13