How to Maximize window in chrome using webDriver (python)

前端 未结 9 1873
天命终不由人
天命终不由人 2021-01-30 08:29

Is there a way to maximize the chrome browser window using python selenium WebDriver?

Note: I am using Chrome Driver 23.0 Any solution on this would be greatly appreciat

相关标签:
9条回答
  • 2021-01-30 08:46

    try this, tested on windows platform and it works fine :

    from selenium import webdriver
    browser = webdriver.Chrome('C:\\Users\\yeivic\\Downloads\\chromedriver')
    browser.fullscreen_window()
    browser.get('http://google.com/')
    
    0 讨论(0)
  • 2021-01-30 08:47

    You could use ChromeOptions and set suitable argument:

    options = ChromeOptions()
    options.add_argument("--start-maximized")
    driver = ChromeDriver(options)
    
    0 讨论(0)
  • 2021-01-30 08:49

    Nothing worked for me except:

    driver.set_window_size(1024, 600)
    driver.maximize_window()
    

    I found this by inspecting selenium/webdriver/remote/webdriver.py. I've never found any useful documentation, but reading the code has been marginally effective.

    0 讨论(0)
  • 2021-01-30 08:50

    Try

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--start-fullscreen");
    
    0 讨论(0)
  • 2021-01-30 08:53

    This works for me, with Mac OS Sierra using Python,

    options = webdriver.ChromeOptions()
    options.add_argument("--kiosk")
    driver = webdriver.Chrome(chrome_options=options)
    
    0 讨论(0)
  • 2021-01-30 08:56

    Try this:

    driver.manage().window().maximize();
    
    0 讨论(0)
提交回复
热议问题