在通过Jenkins作为Windows服务运行时无法最大化浏览器

时间:2016-06-09 02:34:05

标签: java selenium jenkins

通过Windows运行测试脚本时,由于脚本失败,无法最大化浏览器窗口,

尝试了本主题中提到的所有可能方法,但没有用 Unable to Set Size (Increase Size) for Chrome Browser through Selenium in Jenkins?

有没有办法最大化窗口?任何帮助表示赞赏。提前谢谢。

2 个答案:

答案 0 :(得分:0)

我在TeamCity上看到了相同的内容,因为它再次作为Windows服务运行(在虚拟桌面上)。在使用Firefox配置文件后,我们不得不使用全屏模式。示例代码如下(C#):

//Make Firefox fullscreen for TeamCity agent's runs
_driver.Manage().Window.Maximize();
((IJavaScriptExecutor)_driver).ExecuteScript(
"window.resizeTo(screen.width, screen.height)");
_driver.Manage().Window.Position = new Point(0, 0);
_driver.Manage().Window.Size = 
    new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
_driver.FindElement(By.CssSelector("body")).SendKeys(Keys.F11);
_driver.Navigate().GoToUrl("about:blank");

Chrome也支持such workaround

答案 1 :(得分:0)

当使用Jenkins运行自动化测试时,我遇到了类似的问题。这与交互式服务检测有关。

我似乎解决这个问题的唯一方法是将Jenkins删除为Windows服务,然后使用sciprt从CMD运行。

相关问题