Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webdriver firefox 7 maximize window

I've been using the following example to maximize my windows in my WebDriver tests, I upgraded to Firefox 7, and the script quit working. I don't get an error, the window just does not maximize, wondering if anyone else has seen this or know why it's no longer working, or another way to do it..

my current code that worked before FireFox 7...

public static final String MAXIMIZE_BROWSER_WINDOW = "if (window.screen) {window.moveTo(0, 0);window.resizeTo(window.screen.availWidth,window.screen.availHeight);};";

public static Object maximizeBrowserWindow(WebDriver driver) {
    return executeJavascript(driver, MAXIMIZE_BROWSER_WINDOW);
}

private static Object executeJavascript(WebDriver driver, String script){
    JavascriptExecutor js=(JavascriptExecutor) driver;
return js.executeScript(script);
}
like image 365
Green Avatar asked Oct 25 '11 20:10

Green


1 Answers

Firefox 7 disabled the ability to modify the main window via JavaScript. The issue report can be found in the Mozilla bug tracker. There have been some discussions of workarounds, on the WebDriver users mailing list, but none of them are particularly pretty.

like image 117
JimEvans Avatar answered Oct 01 '22 12:10

JimEvans