ChromeDriver窗口不会重新调整尺寸以适应Nexus 5的尺寸

时间:2018-01-22 21:24:28

标签: c# selenium selenium-chromedriver

我目前正在使用:

options.EnableMobileEmulation("Nexus 5");

要模拟网站的移动版本,但ChromeDriver窗口不会重新调整尺寸以适应Nexus 5的尺寸,因此我留下半个空白页。

示例:

enter image description here

我希望窗口大小适合网站的内容,而不是产生空的网页内容。

1 个答案:

答案 0 :(得分:3)

请尝试以下代码:

System.Drawing.Size window_size = new System.Drawing.Size(x, y);
driver.Manage().Window.Size = window_size;

其中x,y:宽度和高度,以像素为单位。

希望它可以帮到你!