[英]Browser is not maximized when running selenium scripts via Jenkins as windows service
I am running my selenium scripts written in Java using chromedriver on Windows Server 2008 R2 Server VDI (acting as slave) and have done the setup as windows service. 我正在Windows Server 2008 R2 Server VDI(充当从属服务器)上使用chromedriver运行用Java编写的硒脚本,并已完成了Windows服务的设置。 Problem is browser size is coming as(1036, 780) with no browser getting opened on UI during execution. 问题是浏览器大小即将变为(1036,780),执行期间没有在UI上打开浏览器。 If I run the same script on local (not via Jenkins), then the browser size would be (1554, 843) and hence the reason script is getting failed as it's not able to find the element id. 如果我在本地(而不是通过Jenkins)运行相同的脚本,那么浏览器的大小将为(1554,843),因此原因脚本由于找不到元素ID而失败。
I've tried the options below but nothing worked out for me till now. 我已经尝试过以下选项,但到目前为止没有任何结果。
1) Tried to maximize the browser using the below code but still the browser size didn't changed. 1)尝试使用以下代码最大化浏览器,但浏览器大小并未更改。
Dimension d = new Dimension(1554,843);
//Resize current window to the set dimension
driver.manage().window().setSize(d);
2) Tried to run in fullscreen mode using below code. 2)尝试使用以下代码在全屏模式下运行。
driver.manage().window().fullscreen();
3) On VDI (slave), in services.msc, selected the check box 'Allow service to interact with desktop' but no result 3)在VDI(从站)上,在services.msc中,选中“允许服务与桌面交互”复选框,但没有结果
4) Tried to launch slave using Windows scheduler but even in this case script failed and no browser was opened on UI. 4)尝试使用Windows调度程序启动从属服务器,但即使在这种情况下,脚本也失败,并且没有在UI上打开浏览器。 Referred below link. 参考以下链接。
https://wiki.jenkins.io/display/JENKINS/Launch+Java+Web+Start+slave+agent+via+Windows+Scheduler https://wiki.jenkins.io/display/JENKINS/Launch+Java+Web+Start+slave+agent+via+Windows+Scheduler
My requirement is to run the selenium scripts on the particular VDI (acting as slave) and the reason behind the configuration of Jenkins set up as windows service is, whenever the VDI reboots it automatically establishes the JNLP connection with slave node using slave.jar. 我的要求是在特定的VDI(充当从属服务器)上运行硒脚本,而将Jenkins设置为Windows服务的配置背后的原因是,每当VDI重新启动时,它都会使用slave.jar与从属节点自动建立JNLP连接。
Can anyone suggest me workaround for this problem. 谁能建议我解决此问题。 Thanks in advance. 提前致谢。
尝试使用:
webdriver.maximize_window()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.