I am having an issue using chrome and selenium 2 webdriver. The issue is that when I start my browser session using the chromedriver it always starts in a window that is less than half the size of the available screen width. Because I am doing tests on a page that changes when the screen size changes, my tests fail because I'm trying to drag an element from the top of the page and drop it to an element that is at the bottom of the page. I get a scrolling error. But if the window is maximized, then I don't get this error. But the problem is, every time chrome starts a new session via chrome driver it always starts in a small window. I have explored many different options to get the browser to start maximized:
- Make a call via javascript to change the size of the window using window.resizeTo(width,height);. However, this doesn't work in later versions of chrome (or firefox for that matter).
- Start chrome with a switch --start-maximized. This works on windows, but this does nothing on a mac.
- Start chrome with a switch specifing a profile directory. This way the profile would define the window size. --profile-directory=~/chromeprofile This worked when I started chrome from the commandline, but if I do this from selenium webdriver/chromedriver it doesn't make any difference.
When I try: driver.manage().window().setSize() I get this exception:
INFO: Executing: [93debf43cf70ad3557442a7e1aee4620, setWindowSize {"windowHandle":"current","width":2560,"height":1440}] org.openqa.selenium.UnsupportedCommandException: [GET, HEAD, DELETE] Command duration or timeout: 16 milliseconds Build info: version: '2.15.0', revision: '15105', time: '2011-12-08 09:56:25' System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.2', java.version: '1.6.0_29' Driver info: driver.version: RemoteWebDriver at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:424) at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.setSize(RemoteWebDriver.java:578) at com.domo.automation.framework.utility.WebDriverUtil.startWebDriver(WebDriverUtil.java:36) at com.domo.automation.tests.DomoWebDriverTestCase.setUp(DomoWebDriverTestCase.java:45) at junit.framework.TestCase.runBare(TestCase.java:132) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:243) at junit.framework.TestSuite.run(TestSuite.java:238) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
What other options could I explore in order to accomplish this? The issue is that the window is too small? What can I do to automaticallly maximize the window every time chrome starts via webdriver on a mac?