如何创建调度程序以每晚12.00- Selenium WebDriver运行我的脚本 [英] How to create scheduler to run my script every night at 12.00- Selenium WebDriver

查看:193
本文介绍了如何创建调度程序以每晚12.00- Selenium WebDriver运行我的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 目前正在使用 Selenium WebDriver 并使用 Java 。我有一个名为* Test *的项目。

  • 在该项目中,我有许多Java程序,例如 Login.java Testing1.java 等。

  • 这个场景是我想每天早上12点运行我的所有脚本。是否有可能创建一个调度程序来自动运行我的脚本。

  • Currently working on Selenium WebDriver and using Java. I have a project called*Test*.
  • In that Project i have many Java Programs such as Login.java, Testing1.java etc.,.
  • The scenario is i want to run all my scripts daily morning at 12.00 a.m. Is there any possibility to create a scheduler to run my scripts automatically.

推荐答案

创建 testng.xml 文件,名称为 testsuite.xml

现在按照以下2个步骤进行操作:

Now follow below 2 steps:

步骤1:创建调度程序的批处理文件:

Step 1: Create an batch file for scheduler:

使用下面的代码 - 修改它并粘贴到记事本中。将记事本保存在工作目录中run.bat

use below code - modify it and paste in notepad. save the notepad in working directory as"run.bat"

set ProjectPath=C:\Selenium\Selenium_tests\DemoProject 
echo %ProjectPath%
set classpath=%ProjectPath%\bin;%ProjectPath%\Lib\*
echo %classpath%
java org.testng.TestNG %ProjectPath%\testsuite.xml

a)第一行用于设置项目路径
b)第二行用于验证路径是否已设置。
c)第三行用于设置classpath - lib文件夹包含添加到项目构建路径的所有jar文件
d)第四行用于验证是否设置了classpath
e)第五行用于执行xml文件包含所有测试的详细信息。

a) First line is for setting project path b) second line is for verifying that path is set or not. c) third line is for setting classpath - lib folder contain all the jar file added to project build path d) fourth line is for verifying whether classpath is set or not e) fifth line is for executing xml file having details of all test.

步骤2:转到控制面板>管理工具>任务计划程序并创建一个任务,当时将触发run.bat文件你想要的。

Step 2: go to control panel > administrative tool >task scheduler and create a task which will trigger run.bat file at the time you want.

它会起作用。

这篇关于如何创建调度程序以每晚12.00- Selenium WebDriver运行我的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆