In a multi-monitor display environment, how do I tell Selenium which display to open a new window in?

后端 未结 17 2208
小蘑菇
小蘑菇 2021-01-31 15:53

Sorry if this has been asked and answered. I did a search but came up empty.

17条回答
  •  北海茫月
    2021-01-31 16:35

    I use this not very fancy, but quick method to achieve that. Because I do not only want it on my second screen but also maximized I don't have to be too precise on the coordinates. Any X-coordinate above 2000 is usually on the second screen for all my dev machines: (This example uses chromedriver but works with any IWebDriver)

    chrome = new ChromeDriver();
    chrome.Manage().Window.Position = new System.Drawing.Point(2000, 1); // To 2nd monitor. 
    chrome.Manage().Window.Maximize();
    

提交回复
热议问题