简体   繁体   English

全屏操作在 selenium webdriver 3.x 中不起作用

[英]Fullscreen operation is not working in selenium webdriver 3.x

Firefox Version: 52.0.2 (32-bit)火狐版本:52.0.2(32 位)
Platform: Windows 7平台:Windows 7
Selenium Webdriver version: 3.4.0 (Java bindings) Selenium Webdriver 版本:3.4.0(Java 绑定)
Problem statement: While trying to perform full screen operation in firefox browser then it throws UnsupportedCommandException问题陈述:尝试在firefox浏览器中执行全屏操作时抛出UnsupportedCommandException

Test Code:测试代码:

public class GeckoTest {
    public static void main(String[] args) throws IOException {
        System.setProperty("webdriver.gecko.driver","<geckodriver executable>");
        FirefoxBinary binary = new FirefoxBinary(new File("firefox binary"));
        FirefoxOptions options = new FirefoxOptions();
        options.setBinary(binary);
        options.setLogLevel(Level.ALL);
        WebDriver browser = new FirefoxDriver(options);
        browser.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        browser.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
        browser.get("http://examples.sencha.com/extjs/6.5.0/examples/kitchensink/?classic#form-fieldtypes");
        browser.manage().window().fullscreen();
        WebDriverWait wait = new WebDriverWait(browser,20,3000);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//div[contains(@class,'x-form-spinner x-form-spinner-default x-form-spinner-down x-form-spinner-down-default')]")));
        Actions builder = new Actions(browser);
        builder.doubleClick(browser.findElement(By.xpath(".//div[contains(@class,'x-form-spinner x-form-spinner-default x-form-spinner-down x-form-spinner-down-default')]"))).perform();
        browser.close();
    }
}

EDIT: It seems this is an known issue and will be fixed in FF55 as per this enter link description here编辑:这似乎是一个已知问题,将根据此处输入链接描述在 FF55 中修复

While you work with Selenium 3.4.x, geckodriver v0.16.1 and Mozilla Firefox 53.0, as you mentioned when we try to perform full screen operation in Mozilla Firefox browser then it throws UnsupportedCommandException is true .当您使用 Selenium 3.4.x、geckodriver v0.16.1 和 Mozilla Firefox 53.0 时,正如您when we try to perform full screen operation in Mozilla Firefox browser then it throws UnsupportedCommandException提到的when we try to perform full screen operation in Mozilla Firefox browser then it throws UnsupportedCommandException is true How ever there is an alternative to achieve the full screen operation in Mozilla Firefox which works perfect through sending F11 Keys .如何在 Mozilla Firefox 中实现全屏操作的替代方法是通过发送F11 Keys完美运行。 Here is the minimal code block to check full screen operation in Mozilla Firefox:这是在 Mozilla Firefox 中检查全屏操作的最小代码块:

System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe");
WebDriver browser = new FirefoxDriver();
browser.get("http://examples.sencha.com/extjs/6.5.0/examples/kitchensink/?classic#form-fieldtypes");
browser.findElement(By.tagName("body")).sendKeys(Keys.F11);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM