景观中的 C# Selenium 移动仿真

标签 c# selenium

我正在使用 C# 在 .Net 环境中使用 Selenium 进行一些移动 UI 测试。

我能够在纵向模式下使用 chrome 移动仿真非常成功地进行测试,但我找不到如何将仿真置于横向模式。

我希望能够在测试期间以编程方式旋转,但通过研究,这似乎还不可能。

在纵向模式下工作。

        ChromeOptions chromeCapabilities = new ChromeOptions();         

        chromeCapabilities.EnableMobileEmulation("Apple iPhone 6");

        ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"C:\chromedriver");            

        IWebDriver driver = new ChromeDriver(service, chromeCapabilities);
        driver.Navigate().GoToUrl("www.google.com");

但是,如何将 iPhone 模拟设置为横向?

我已经试过了,但它不起作用,浏览器打开时没有大小限制

        ChromeMobileEmulationDeviceSettings CMEDS = new ChromeMobileEmulationDeviceSettings();
        CMEDS.Width = 66;
        CMEDS.Height = 37;
        CMEDS.PixelRatio = 1.0;
        CMEDS.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25";

        ChromeOptions chromeCapabilities = new ChromeOptions();

        chromeCapabilities.EnableMobileEmulation(CMEDS);

        ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"C:\chromedriver");

        IWebDriver driver = new ChromeDriver(service, chromeCapabilities);
        driver.Navigate().GoToUrl("www.google.com");

大大收到任何帮助或建议!! 提前致谢

最佳答案

据我所知,目前无法更改屏幕方向

这是一个相关的开放问题:


somefew hints在源代码中,我想到可以通过添加自定义的全新设备 来拥有面向“横向”的仿真设备(尽管如何以编程方式添加设备是一个悬而未决的问题)。

关于景观中的 C# Selenium 移动仿真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36338760/

相关文章:

c# - 删除行从 CSV 文件开始 在 SSIS 控制流脚本任务中

c# - 如何从 C# 中的智能卡读取名称和地址等基本数据?

c# - Application.Restart() 是否为应用程序创建新进程?

java - selenium webdriver - 构造 Action 点击和发送键

python - selenium - 等待编辑框可交互(单击按钮后)

c# - 在 IEnumerable 上使用扩展方法的 Foreach

c# - 动态创建类型

selenium - 测试结果报告

javascript - e2e 测试 Angular UI 网格的规范方法

google-chrome - 我可以在不使用 chromedriver.exe 的情况下为 Chrome 使用 Selenium (webdriver) 吗?