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

2 answers

  • answered 2018-02-13 04:21 Null511

    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.

  • answered 2018-02-13 23:27 Chris Riccio

    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

    1. the command line to execute your tests
    2. a scheduled task

    More specifically:

    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

    nunit3-console testsfile.dll
    

    More details here: https://github.com/nunit/docs/wiki/Console-Command-Line

    Next, create the scheduled task

    1. open Task Scheduler
    2. Under Actions, click Create a Basic Task
    3. Provide a descriptive name
    4. Choose a timeframe (if you want multiple times a week, choose daily here)
    5. Choose the starting date and time, and how often to recur
    6. Choose Start a Program as the type of action
    7. 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
    8. 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