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

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

    Wailord's answer worked for me but it always opened the window and then moved it. So there is a brief moment where it blocks my editor.

    Chrome has a command-line switch for window position
    --window-position=x,y
    https://peter.sh/experiments/chromium-command-line-switches/#window-position

    from selenium import webdriver
    options = webdriver.ChromeOptions()
    options.add_argument('window-position=2000,0')  # opens at x=2000,y=0 from the start
    driver = webdriver.Chrome(options=options)
    

提交回复
热议问题