Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Did you try</p> <pre><code>browser.maximize </code></pre> <p>It only works on IE, but it is an option that's been documented for a while (see the <a href="http://wiki.openqa.org/display/WTR/Cheat+Sheet" rel="nofollow">watir cheat-sheet</a>) </p> <p>Of course you need perhaps to consider WHY the browser needs to run full screen, or what happens if you move the scripts to a system where the default screen size is different. You might be better off to set the browser to a specific size, which can be done with a simple javascript <em>resizeTo</em> function, you can even 'goto' it as a URL</p> <pre><code>browser.goto('javascript:resizeTo(800,600)') </code></pre> <p>There is also a '<em>moveTo</em>' that can be used the same way. so you can position the window at a known point.</p> <p>If you need the browser in a particular place and size, something else to consider would be creating a page with the proper javascript to set things they way you want and then make that your default homepage so it runs as soon as the browser opens. If your google for 'javascript maximize browser' or 'javascript resize browser' you will likely find example code for such a page.</p> <p>=-=-=-= <strong>Edit</strong> (<em>based on clarification that 'fullscreen' is what is wanted, not merely maximized</em>) </p> <p>Lastly you could look at simply simulating a 'F11' keypress as that is the fullscreen toggle for most browsers. If you are using watir-webdriver this can be done via the sendkeys method</p> <pre><code>browser.send_keys :f11 </code></pre> <p>However that is a toggle, and in a script would depend on things being in the right state to start with. Something that got out of sync might end up turning 'off' the fullscreen.</p> <p>So you might investigate also the idea of a specific page on the local system that would spawn a new fullscreen window, and having the code attach to the new window. (or using the switching window code in watir-webdriver) although this sort of 'popup a new window in fullscreen mode' is something you might expect to be blocked or deprecated (see below) in the future if not already on some browsers.</p> <p><strong>Warning:</strong> being able to throw the browser into fullscreen mode from the HTML is something that is somewhat frowned upon because it is considered a <em>security vulnerability</em>. This is because someone could craft a specific image to make it LOOK like a url bar and other controls were present, and the user at a legitimate site, when creating a phishing site. Such sites are currently one of the larger issues the web community faces right now (contents of my spamfilter are about 20% phishing and rising rapidly) So while there may have been methods in the past to do that, increasingly they get 'shut down' by newer more secure versions of browsers. This might tend to make the sendkeys option your best bet going forward in terms of something that should work cross browser. (nearly all that I know of use F11 for the fullscreen toggle) </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload