2017-06-04 54 views
2

的Firefox版本:52.0.2(32位)
平臺:Windows 7的
硒webdriver的版本:3.4.0(Java綁定)
問題陳述: 雖然試圖在Firefox瀏覽器進行全屏幕操作,它拋出UnsupportedCommandException
全屏操作沒有硒的webdriver 3.x的工作

測試代碼:

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(); 
    } 
} 

編輯:看來,這是一個已知的ISSU e和將被固定在FF55按本enter link description here

+0

從Gecko驅動程序默認情況下,如果以全屏啓動FireFox ...我認爲gecko沒有實現任何全屏方法 –

+0

這似乎是一個問題,將按照這個:FF:http:// bugzilla實現。 mozilla.org/show_bug.cgi?id=1189749 –

回答

2

這裏是回答你的問題:

雖然我們與硒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 UnsupportedCommandExceptiontrue。如何在Mozilla Firefox中實現全屏操作,通過發送F11 Keys完美工作。這裏是檢查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); 

讓我知道這是否回答你的問題。

+0

對不起mate..fullscreen是您在瀏覽器中按F11時的模式。最大化不同於全屏。 –

+0

@MrunalGosar請檢查我的更新答案,讓我知道它是否適合你。謝謝 – DebanjanB

+0

haha​​haha ..實際上,這是我已經使用目前的解決方法..但感謝您的努力隊友 –