在PC,Iphone和Ipad上使用selenium测试网页

问题描述 投票:0回答:1

我需要在PC,iphone和ipad等各种设备上使用chrome浏览器测试网页,以验证各种UI元素的方向和显示。

我可以使用我的电脑上的chrome中的开发人员工具查看各种移动设备的显示和方向。

但是我想知道我是否可以通过使用selenium启动chrome浏览器来测试这个,并根据chrome开发人员工具中ipad的分辨率调整c#的大小。

这是一种可靠的测试方法吗?

 driver.Manage().Window.Size = new System.Drawing.Size(320, 568);
c# selenium ipad
1个回答
0
投票

要调整Chrome浏览器窗口的大小,您可以使用以下任一选项:

  • 使用Window界面: driver.Manage().Window.Size = new Size(1024, 768);
  • 使用ChromeOptions和AddArgument()ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArgument("--window-size=1024,768"); IWebDriver driver = new ChromeDriver(chromeOptions)
  • 使用ExecuteScript()((IJavaScriptExecutor)driver).ExecuteScript("window.resizeTo(1024, 768);");

您可以在Fitting objects in window screen using Selenium Java中找到基于Java的相关解决方案

© www.soinside.com 2019 - 2024. All rights reserved.