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

后端 未结 17 2228
小蘑菇
小蘑菇 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:50

    For Java:

    //imports:
    import java.awt.*;
    import java.awt.event.InputEvent;
    
    driver = new FirefoxDriver();
    
    //drag & drop to my right screen in debug mode:
    boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("jdwp") >= 0;
    
    if(isDebug) {
      Robot robot = new Robot();
    
      robot.mouseMove(800, 10);
      robot.mousePress(InputEvent.BUTTON1_MASK);
      robot.mouseMove(2800, 100);
      robot.mouseRelease(InputEvent.BUTTON1_MASK);
      driver.manage().window().maximize();
    }
    

    driver.manage().window().setPosition(point); didn't work for me.

提交回复
热议问题