我正在编写selenium测试。我有一个脚本有问题,因为selenium找不到元素。我认为这是RemoteWebDriver的一个问题,因为当我看屏幕时,我看到屏幕是不完整的,没有右侧的按钮。如果我使用的是本地驱动程序,我会使用line driver.manage().window().maximize(),这样就可以工作了。所以我的问题是,有没有可能最大化RemoteWebDriver窗口的大小?也许有一种替代方案可以让那个驱动程序全屏显示?我使用的是Jenkins和selenium。
发布于 2016-12-01 20:57:54
我在chrome中遇到过很多次这个问题,我的变通方法是使用javascript的scrollIntoView将视区移动到该元素。
在php /phpunit-selenium中:
$this->execute([
'script' => 'var elm = document.getElementById("id");elm.scrollIntoView(true);',
'args' => $args
]);
// Continue to access element您应该能够在'script‘中提取该位,并在您用于selenium测试的任何语言中将其作为原始javascript执行。
发布于 2018-01-04 21:48:09
对于chrome,我们可以使用
DesiredCapabilities cap = new DesiredCapabilities();
ChromeOptions options = new ChromeOptions();
cap.setCapability(ChromeOptions.CAPABILITY, options);
options.addArguments("--start-maximized");
driver = new ChromeDriver(cap);火狐在最新的geckodriver版本中不需要任何driver.window().manage().maximize()
https://stackoverflow.com/questions/40905969
复制相似问题