Hello Welcome to Selenium Tutorials, today we will discuss how to Execute Selenium test from command line.
Before executing testcases from command line you should have setup ready, if you still have not done then please follow the below link and complete setup part-
Once you start designing test case continuously your test cases count will increase so you have to manage your test cases accordingly.
TestNG having very interesting concept of creating xml file based on your requirement and put all relevant test cases inside testng.xml file and run it as a Test Suite.
Scenario – If you have 50 test case for application 1 and 70 test case for application 2 and 100 test case for application3 so in this case we can create 3 xml (1 xml for each app) and run them either individually or run all xml in one shot.
1- TestNG should be installed.
2- Multiple xml file should be created.
3- Class-path should be set.
Run selenium test from command line
Step 2- Set classpath now
Some key points to remember-
1-Put all the jars (Selenium jars) into separate folder and put that folder into project home directory
in my case- I created lib folder (you can keep name based on your choice) and I kept all jars inside it which we downloaded from Selenium website.
Refer below screenshot of Lib folder and I have shown only some jars but you have to kept all files.
2- Open command prompt and type cd\ and press enter.
Now go to project home directory for this type cd directory path and enter
Now we can set classpath for this,specify bin folder
Home Directory > set classpath=Home Directory\bin; and press enter
Home Directory > set classpath=Home Directory\lib\*; and press enter
Step 3-Now run xml file using below command
Home-directory > java org,testng.TestNG testng.xml testng2.xml testng2.xml and hit enter
Thanks for visiting my blog. If you find this post informative then please share with your friends.:)
For more updates like our Facebook Page.
For any Selenium related query Join Facebook Group.