Run Selenium Tests Using Task Scheduler in Windows 7

In this post, you’ll find how to run Selenium tests using task scheduler in Windows 7. With the steps given here, you’ll be able to schedule your tests for daily execution.

Though, there are many ready-made CI tools available which can help you do it. But they need a lot of configuration which many us would prefer to avoid.

Like CronTab in Linux, Windows OS has this built-in feature which allows creating tasks and schedule them for execution. So it’s easy to run Selenium tests using task scheduler.

However, you need to be a little careful while setting up an automation task in the scheduler.

First, you require admin rights to use task scheduler. Then, you’ve to choose appropriate settings to open a browser and run Selenium tests.

Run Selenium Tests Using Task Scheduler in Windows 7.

Before we tell you the steps to run Selenium tests using task scheduler, you should know how to run the tests from the command line. Once you know this command, you can place it in a batch file. And it would be the final batch file which we’ll add to task scheduler to run the Selenium tests on a daily basis.

Run Selenium Tests Using Task Scheduler in Windows 7

Run Selenium Tests Using Task Scheduler.

 

1- Prepare a Windows Batch File to Run Selenium Tests.

There could be three use cases which you may need to handle.

1.1- You have the Selenium tests in a single or multiple class files.

Use the below command to run the tests. Keep the Selenium library on the current path. And name Java class file as <SeleniumTests.java>.

1.2- You have the Selenium tests exported from Eclipse as a Runnable Jar file.

Use the below command to run the tests. Make sure the output Jar contains all the Selenium dependencies.

1.3- You might be using <testng.xml> to run Selenium tests.

Use the below command to run the tests.

You can check more details from here to run testng.xml from the command line.

1.4- Now, use the below code to add into a batch file. Save the batch file as <run.bat>.

 

2- How to run a batch file using the task scheduler in Windows 7?

2.1- Open control panel.

2.2- Go to <Administrative tool >>Task scheduler>.

2.3- Create a task to run the batch file. Also, specify the time to start the execution.

2.4- Don’t forget to check the below setting in task scheduler.

Read from this link for more detail on task scheduler.

 

If you have any query about the above steps, then do leave it in the comment box. We’ll try to address at the earliest possible.

All the Best,

TechBeamers.

Leave a Reply


*