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

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

尝试了这个线程中提到的所有可能的方法,但没有使用无法通过Jenkins中的Selenium为Chrome浏览器设置大小(增加大小)?

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

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

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

我在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也支持此类解决方法 。