我正在尝试在使用以下 javascript 启动后调整浏览器窗口的大小
driver.get(url);
driver.manage().window().setSize(1200,800);
但是,我得到一个错误
'setSize 不是函数 '.
有人可以帮我解决这个问题吗,我也试过了
reSizeTo()
我刚刚找到了我的问题的解决方案,下面的代码有效
driver.manage().window().setRect({width: 640, height: 480, x, y});
2022年的这个功能:
var width = 800;
var height = 600;
driver.manage().window().setRect({x: 0, y: 0, width: width, height: height});
https://www.selenium.dev/documentation/webdriver/interactions/windows/
它没有方法
setSize
,你应该使用setRect
代替