Selenium - 使用Windows任务计划程序与命令行 [英] Selenium - Using Windows Task Scheduler vs. command line
问题描述
我有一个批处理文件,用于启动我使用IEDriverServer的Selenium脚本(用Java编写)。当我从命令行运行该批处理文件时,脚本按预期工作。但是,当我使用Windows任务计划程序运行完全相同的批处理文件时,脚本在WebDriverWait期间超时直到语句:
(new WebDriverWait(driver,JAVASCRIPT_TIMEOUT_SECONDS))。until(new ExpectedCondition< Boolean>(){
public Boolean apply(WebDriver d){
return d.getTitle()。equals(BROWSE_PAGE_TITLE);
}
});
我发现此Stack Overflow帖子:
- 在条件中编辑电源选项(如果需要,您也可以选择网络设置)
保存任务,右键单击任务并运行它以检查它是否正常工作。
希望这有一些帮助:)
I have a batch file that kicks off my Selenium script (written in Java), which uses the IEDriverServer. When I run that batch file from the command line, the script works as expected. However, when I use the Windows Task Scheduler to run the exact same batch file, the script times out during a WebDriverWait until statement:
(new WebDriverWait(driver, JAVASCRIPT_TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().equals(BROWSE_PAGE_TITLE);
}
});
I found this Stack Overflow post:
Selenium runs as scheduled task on Windows Server
which suggests that setting the job to "Run whether the user is logged in or not" can fix the problem, but I already have the job set that way.
I have tried both the 32-bit and 64-bit versions of the IEDriverServer.
It is also worth noting that the sendKeys method is taking about 5 seconds per keystroke when using the Task Scheduler, but not when running the batch file directly.
How can I get Selenium to behave the same way using the Task Scheduler as it does when running from the command line?
Additional Info:
- Windows Server 2008 R2
- IEDriverServer version 2.42.0
- Selenium Java version 2.42.2
Here is a suggestion, Create an executable jar file (Right click on your project and export as Executable Jar) and try to run that directly instead. I never faced any performance issues with this.
Also, make sure your internet connection is stable, You can use Network tab for those settings before your task runs.
Here is a short description of how to achieve this:
- Create a new Task
- Set the Schedule
- In General Tab, using "Run whether the user is logged in or not" will be great.
- Go to Actions, Click on New and Use setting somewhat like this :
- In Conditions edit the Power options (You can also select Network settings if you want)
- Also, do consider updating the settings as well
Save the task, Right click on task and Run it to check if it works fine.
Hope this is of some help :)
这篇关于Selenium - 使用Windows任务计划程序与命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!