Scheduling Selenium Webdriver (C#) tests
In my test project I would like to schedule unattended run of Regression tests a couple of times a week using Selenium Webdriver with C#. I know this could be achieved with Jenkins or similar tools, but wondering is there any way to do it without a CI/CD tool. I could not get any conclusive info on whether this could be achieved just by some inbuilt/native capability within selenium or the tool stack I am using (as noted below) --
- Selenium Webdriver on C#
- Visual Studio 2015 Professional
- NUnit test framework
If you really want to write your own scheduler, you could create a Windows Service; which Visual Studio comes with a template for. From there, you can use a Timer or background Thread to initiate or perform your automated tests.
There isn't any built-in support for scheduling a run in your tool stack, but it would be quite simple to roll your own basic scheduled run.
The ingredients would be
- the command line to execute your tests
- a scheduled task
Create an nunit command to run your tests - this may need to be crafted based on specifics for your project, but a very basic one would be
More details here: https://github.com/nunit/docs/wiki/Console-Command-Line
Next, create the scheduled task
- open Task Scheduler
- Under Actions, click Create a Basic Task
- Provide a descriptive name
- Choose a timeframe (if you want multiple times a week, choose daily here)
- Choose the starting date and time, and how often to recur
- Choose Start a Program as the type of action
- The program to run is nunit3-console.exe, the arguments would be testsfile.dll or whatever arguments you need. Start In is where the dll lives
- Click Finish.
Now it will run on the schedule you provided, or you can launch it whenever you want by viewing it in the Task Scheduler Library and selecting Run