Sorry if this has been asked and answered. I did a search but came up empty.
I have 2 1920x1080 monitors, I move the browser window to the 2nd monitor and maximize it there.
Get screen resolution
java.awt.Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double width = screenSize.getWidth();
double height = screenSize.getHeight();
Move browser to second monitor and maximize
if (width <= 1920) {
Point point = new Point(width, 0);
driver.manage().window().setPosition(point);
driver.manage().window().maximize();
}
If your resolution is wider than a typical monitor, open the browser in a more realistic resolution (this is optional, but I recommend it)
else
{
Point point = new Point(0, 0);
driver.manage().window().setPosition(point);
Dimension targetWindowSize = new Dimension(1920, 1080);
driver.manage().window().setSize(targetWindowSize);
}
I noticed that for me its always opening in the primary monitor. So I changed the primary display from OSX display arrangement options window.
There's actually a fairly easy way to do this. There's a method called 'set_window_position' which accepts negative values. So I wanted the browser to open on my left screen, so a simple negative 1000px pixels dragged it in enough for the maximize_window to pick the left screen.
driver.set_window_position(-1000, 0)
driver.maximize_window()
So depending on the screen sizes and where you want it to go, make some calculations and just drag it there!
Source: http://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.firefox.webdriver (picked firefox for this example)
In case the monitor where you want to open a browser windows is to the left of the monitor with IDE, try negative values. In Java:
WebDriver driver = new FirefoxDriver();
driver.manage().window().setPosition(new Point(-1500, 0));
Just put the Mac "Menu Bar" on the monitor where you want the browser to open up. That sets the default monitor.