junit - How to run Selenium webdriver script in mulitple browser without changing parameters - java -


I want to run my WebDrive script only once after running the same in more than one browser I am In my current framework, I have placed all the browser names in the properties file and from there I am receiving it and passing through it as a parameter. But the problem is this way, in one execution it runs only for one browser. If I want to run it in another browser, then I have to give another browser name for another execution. I want to run it once and execute the script for a browser, after which it should also run automatically for other browsers. I'm using junit. How can I get it?

Take a look at Selenyun or you can create a test site and use the system properties set on.

Something like this:

1- Create a test site with all the exams

  import org.junit.runner.RunWith; Import org.junit.runners.Suite; Import org.junit.runners.Suite.SuiteClasses; @Ravivith (suite category) @ suite classes ({MyClassTest.class, MySecondClassTest.class}) Public class alstays {}   

2- Run suites that set the properties first

  import org.junit.runner.JUnitCore; Import org.junit.runner.Result; Import org.junit.runner.notification.Failure; Public category MyTestRunner {public static zero main (string [] Args) // // Set Browser System.setProperty ("Browser", "Firefox"); Result of result = JUnitCore.RunClasses (AllTests.class); (For failure failure: result.getFailures ()) {System.out.println (failure.toString ()); } System.setProperty ("Browser", "Explorer"); Results Result = JUnitCore.RunClasses (AllTests.class); (For failure failure: result.getFailures ()) {System.out.println (failure.toString ()); } // .... the rest of the browsers .... //}}   

3- With this option you should get the property and set your test ( system GetProperty ("Browser"); )

  Public class MyClassTest {Private webDriver = new webDriver (); @ First public set up () {string browser = System.getProperty ("browser"); If (browser.equals ("Firefox")) This driver = new Firefox driver (); Else if (browser.equals ("explorer") this.driver = new ..... ......... test your test @ test->   

hope helps !

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -