简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM