I am using Selenium Remote Control . During executing the tests the actual Firefox window is so small. I want it full screen so I can see what is happening. How can I maximize the browser screen?

- 36,924
- 42
- 155
- 176

- 83,322
- 195
- 530
- 832
-
What programming language are you using with Selenium-RC? java, C# or what? – Ripon Al Wasim May 20 '13 at 09:37
-
How to resize/maximize FF by executing Selenium WebDriver? – Ripon Al Wasim Jun 19 '14 at 13:25
9 Answers
Try the windowMaximize command:
selenium.windowMaximize();
You can also set a specific width and height using the following command:
selenium.getEval("window.resizeTo(X, Y); window.moveTo(0,0);")
Where X is the width and Y is the height.

- 8,191
- 4
- 38
- 39
-
3And for those of you using Python, the call is, predicably, `my_selenium_instance.window_maximize()` – Brandon Rhodes Aug 31 '11 at 19:32
-
1The eval does not work on newer versions of Firefox. See Eli Colner's answer. – Oliver Bock Nov 14 '12 at 04:04
-
9
This works for me. All the other solutions didn't work in FF7.
WebDriver driver = ((WebDriverBackedSelenium) selenium).getWrappedDriver();
driver.manage().window().setPosition(new Point(0, 0));
driver.manage().window().setSize(new Dimension(1920, 1080));

- 271
- 3
- 2
-
2
-
1Works with only the 2nd two lines of the answer since I run with pure Webdriver without Selenium. Thanks. – djangofan Jun 23 '12 at 04:45
-
3Javascript version: ``driver.manage().window().setSize(1920, 1080);`` – user85461 Jan 07 '14 at 19:35
-
user85461, what do you mean by Javascript version? As in the equivalent call using WebDriverJS binding? Don't want other users to be confused thinking you can execute that as plain javascript and it will simply work. – David Jul 07 '14 at 05:39
-
Just wanted to point out so other users don't get mistaken. This code is for Java (or also possibly C#). The syntax for other WebDriver language bindings will be different and those other ones won't have line 1 with the WebDriverBackedSelenium. – David Jul 07 '14 at 06:03
-
-
i use selenium ide, and run a java batch from my testing server (linux) directly on my windows machine where the selenium processes. does this go on the java batch, or somewhere in the selenium ide? – blamb Oct 15 '14 at 02:43
-
here is my batch file `@ECHO OFF SET JRE_HOME=C:\Progra~2\Java\jre7 %JRE_HOME%\bin\java -jar selenium-server-standalone-2.34.0.jar -Dwebdriver.ie.driver=.\IEDriverServer_Win32_2.39.0.exe -Dwebdriver.chrome.driver=chromedriver_win32_2.10.exe` – blamb Oct 15 '14 at 02:45
You can do the following:
page.driver.browser.manage.window.maximize

- 8,147
- 12
- 54
- 58

- 810
- 1
- 6
- 15
-
none of the other ones work. For security reasons a javascript – Michael Yagudaev Jul 05 '13 at 19:04
Selenium 2.31.0
driver = webdriver.Firefox()
# Resize the window to the screen width/height
driver.set_window_size(300, 500)
# Move the window to position x/y
driver.set_window_position(200, 200)

- 1,948
- 19
- 10
for Firefox: sel.key_press_native(122) (122 in the key code for F11)
-
that's an interesting bit of trivia. I didn't know you could do that. While it's probably not what he was looking for, it would be good for scripted presentations. – fijiaaron Jun 29 '11 at 19:10
Well I think the best way is to use selenium.windowMaximize() selenium function instead of manipulating the windows size.

- 21
- 1
None of the answers provided work when passing the -singlewindow parameter to the Selenium RC server. However, if you pass a firefox profile to the Selenium RC server (as detailed somewhat here), you can make an empty profile folder and put this file in the folder:
localstore.rdf(case sensitive filename!):
<?xml version="1.0"?>
<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<RDF:Description RDF:about="chrome://browser/content/browser.xul#main-window"
sizemode="normal"
height="9999"
width="9999"
screenX="0"
screenY="0" />
lastSelected="paneTabs" />
<RDF:Description RDF:about="chrome://browser/content/browser.xul">
<NC:persist RDF:resource="chrome://browser/content/browser.xul#main-window"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#PersonalToolbar"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#nav-bar"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#status-bar"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#toggle_taskbar"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#navigator-toolbox"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#toolbar-menubar"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-box"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-title"/>
</RDF:Description>
</RDF:RDF>
Replace width and height with your preferred width and height. 9999x9999 will pretty much maximize any monitor.
The simplest example possible of running your Selenium RC server this way assuming we have the previously mentioned localstore.rdf in our home directory, and we are currently in the directory of the Selenium RC server:
rm -rf ~/ffProfile
mkdir ~/ffProfile
cp localstore.rdf ~/ffProfile
java -jar selenium-server-*.jar -singlewindow -firefoxProfileTemplate "~/ffProfile"
This also has the added benefit of not "polluting" your tests.

- 5,208
- 2
- 34
- 53
To expand on David Hunt's suggestion for more specific window resizing and moving note the following.
To work in most environments move before resizing. That is:
selenium.getEval("window.moveTo(X, Y); window.resizeTo(X, Y); ")
To cover 2/3's of the screen, which is handy for seeing part of the selenium driving window underneath, and to do this regardless of your target screen resolution:
selenium.getEval("window.moveTo(screen.availWidth / 3,0); window.resizeTo(screen.availWidth * (2/3), screen.availHeight); ");

- 1,676
- 1
- 16
- 18