我现在使用的是Windows 7机器。我试图通过任务调度程序启动 Selenium 测试。我使用了一个 bat 文件来包含编译和运行 selenium 测试所需的所有命令。对于 selenium 测试,我使用 java。那么脚本中的内容会是这样的
cd C:\Users\test\Documents\SevOneNMS\qa\automation
C:\"Program Files"\Java\jdk1.7.0\bin\javac -d C:\Users\test\Documents\tmp -classpath .;../../../jars/junit-4.11.jar;../../../jars/jsch-0.1.49.jar;../../../jars/commons-net-3.1.jar;../../../jars/selenium-server-standalone-2.31.0.jar;tmp;../../../config tests/alerts/AlertActions.java
cd C:\Users\test\Documents\tmp
java -classpath .;../jars/junit-4.11.jar;../jars/jsch-0.1.49.jar;../jars/commons-net-3.1.jar;../jars/selenium-server-standalone-2.31.0.jar org.junit.runner.JUnitCore tests.alerts.AlertActions
当我直接在Windows 7下运行这个bat文件时,它工作得很好。但是当通过任务计划程序启动它时,命令行窗口只弹出半秒就消失了,没有错误消息,测试根本没有执行。 下面是任务调度程序的命令行(Testing.bat 是我所说的bat 文件)。我不明白为什么它不起作用。请帮忙。
schtasks /create /tr Testing.bat /tn selenium /sc ONCE /st 05:55 /f
schtasks /run /tn selenium
schtasks /delete /tn selenium /f
最佳答案
感谢 Aubin,当我在 schtasks.ext 中使用/tr 参数的绝对路径时,一切正常。并且
It's because the current directory isn't set by task scheduler when it's set by explorer.exe when you double click the batch file .
关于java - 当我通过Windows任务计划程序启动selenium测试时,Firefox没有弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16044979/