maximize() method is not working on Safari 10.1

1,275 views
Skip to first unread message

sujanthan rajagopal

unread,
Apr 12, 2017, 2:21:01 AM4/12/17
to webdriver
I am trying to maximize the window on safari brow it is not working. always opening small window. Even if I am trying to use the setSize() method to resize the window, i am getting error. My settings are:

Selenium verision: 3.0.1
Safari version: 10.1
OS: El captian


Simon Stewart

unread,
Apr 13, 2017, 6:49:56 AM4/13/17
to webdriver
Does it work with the Technology Preview of safaridriver?

Simon

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+unsubscribe@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at https://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/d/optout.

steve

unread,
Jun 27, 2017, 5:37:43 AM6/27/17
to webdriver
Maximize works in Safari 10.0. But Displayed property doesn't which I need.

Does anyone have a workaround for maximizing the window while we wait for Apple to fix the defect in Safari 10.1.

I raised ticket 32485581 with Apple on the 31 May. It took Apple 22 days to tell me it was a duplicate. Not sure whats worse: Apple's customer relations or their regression testing of Safari. Do they even use WebDriver internally?

Unable to maximize the window using WebDriver with Safari 10.1.1

Created on May 31 2017, 2:40 PM for Safari

Apple Developer Relations
June 22 2017, 8:20 AM
Engineering has determined that your bug report is a duplicate of another issue and will be closed. 

The open or closed status of the original report your bug was duplicated to appears in a text box within the bug detail section of the bug reporter user interface. For security and privacy reasons, we don't provide access to the original bug yours was duped to.

Steve


On Thursday, 13 April 2017 11:49:56 UTC+1, Simon Stewart wrote:
Does it work with the Technology Preview of safaridriver?

Simon
On Thu, Mar 30, 2017 at 4:31 PM, 'sujanthan rajagopal' via webdriver <webd...@googlegroups.com> wrote:
I am trying to maximize the window on safari brow it is not working. always opening small window. Even if I am trying to use the setSize() method to resize the window, i am getting error. My settings are:

Selenium verision: 3.0.1
Safari version: 10.1
OS: El captian


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

darrell grainger

unread,
Jun 27, 2017, 7:52:11 AM6/27/17
to webdriver
I haven't used this in a while, so it is written in Java, but I would do something like:

            java.awt.Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
            Dimension dimension = new Dimension((int)dim.getWidth(), (int)dim.getHeight());
            Point point = new Point(0,0);
            driver.manage().window().setPosition(point);
            driver.manage().window().setSize(dimension);

I'd use the Java Toolkit to get the screen size then I could tell WebDriver to set the position to 0,0 and the size to the size of the display. This worked on all operating systems and all browsers, not just Safari. If you aren't using Java, you'll have to figure out if there is something in the language you are using which will give you the screen resolution for the current computer.

Darrell

steve

unread,
Jun 27, 2017, 9:56:45 AM6/27/17
to webdriver
Thanks for the suggestion.

I'm remotely accessing an Applie iMac running Mac OS Sierra with Safari 10.1.1 from a Windows 10 Pro box running C# .NET code with WebDriver 3.3.0 via java running Selenium Standalone Server 3.3.0 (hence the java in the exception below).

I'm executing driver.Manage().Window.Size = new Size(800, 600);

The window size remains the same size and it bombs out with this exception. We just don't seem to be able to interact with the Safari window itself.

{"A request to use a window could not be satisfied because the window could not be found. (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 7 milliseconds\nBuild info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'\nSystem info: host: '*********.local', ip: '***.***.***.***', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_131'\nDriver info: org.openqa.selenium.safari.SafariDriver\nCapabilities [{applicationCacheEnabled=true, rotatable=false, databaseEnabled=true, handlesAlerts=true, version=12603.2.4, cleanSession=true, platform=MAC, nativeEvents=true, locationContextEnabled=false, webStorageEnabled=true, browserName=safari, javascriptEnabled=true, platformName=macOS, cssSelectorsEnabled=true}]\nSession ID: A5EEF0C2-1A39-4A06-B5C0-E6E7CC916FFE"}

Steve

darrell grainger

unread,
Jun 28, 2017, 8:07:00 AM6/28/17
to webdriver
If you are attempting to maximize the browser on a remote machine, then using something like Toolkit (or the C# equivalent) would not work. It is going to give you the size of your client machine and not the node running the browser.

I did a little research. I thought maybe using ExecuteScript you might be able to resize the window using pure javascript but I found that it is disabled in Safari. Since WebDriver is really just using javascript to manipulate the browser and you cannot resize Safari using javascript, it might not be possible.

I'd look at using DesiredCapabilities to set command line switches. There might be a command line switch for Safari which will start it in maximized mode. This way you don't need to resize the browser window, it will start in maximized mode when it opens.

Darrell

Steve Murphy

unread,
Jul 7, 2017, 8:37:51 AM7/7/17
to webdriver
Regarding DesiredCapabilities... unlike ChromeOptions, the SafariOptions doesn't currently allow arguments to be passed through - even if I knew what the argument was to maximize the window.

Giving up on the WebDriver end I tried many methods on the Mac itself but ended up being able to maximize the window using AppleScript which will find the Safari window opened by WebDriver and maximize it.

Unfortunately, on a Mac the "maximize" button seems to act more like a "zoom" and stops the Click action from working! Can't have everything but at least I tried! SpiritualPoints++

The search continues. Have even thought about joining the Apple Beta Program to get latest updates to Safari...https://beta.apple.com/sp/betaprogram/

The AppleScript used to maximize is below:

tell application "System Events"
     tell process "Safari"
          click button 2 of window 1
          -- button 2 is the green "zoom" button for all applications
          -- window 1 is always the frontmost window
     end tell
end tell
Reply all
Reply to author
Forward
0 new messages