1

I am currently running my selenium test from the command line using TestNG

java -cp \lib\testng.jar;
         \lib\selenium-server-standalone-2.42.2.jar;
         \lib\log4j-1.2.17.jar;
         \bin\. 
         org.testng.TestNG runTest.xml

However I would ideally like to use as a command line argument what webdriver to use. Currently in my setUp() it just loads the firefox driver, and changing drivers means commenting and uncommenting out code

So as an end goal I could use.

-chrome -firefox

To run tests on firefox and chrome.

What method do you suggest is best to achieve this?

1 Answer 1

1

You can create a custom parameter -Dbrowser=chrome or -Dbrowser=firefox. Based on the value in the Dbrowser you need to initialize appropriate driver in the setup() method.

-Dbrowser can be read using the System.getProperty("browser") code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.