title: How to set window size in Selenium Chrome Python
body: <p>The following code to resize a selenium chrome window does not work:</p>
  
  <pre><code>driver.set_window_size(1920, 1080)
  time.sleep(5)
  size = driver.get_window_size()
  print("Window size: width = {}px, height = {}px.".format(size["width"], size["height"]))
  </code></pre>
  
  <p>From which the output is:</p>
  
  <pre><code>Window size: width = 1044px, height = 788px
  </code></pre>
  
  <p>I've also tried using options to set the window size on driver creation (and lots of other things, seem comments below), but can't get it to work either:</p>
  
  <pre><code>options.add_argument("--window-size=1920,1080")
  </code></pre>
  
  <p>I am using selenium 3.14.0, chrome driver version 72.0.3626.109 and running in background / headless mode: I am literally needing to run my code in background, meaning it launches automatically in the background. I think there is a subtle difference between headless, which when launched is associated with a particular user, and background, which is also headless but may not be associated with a particular user and may have other idiosyncrasies - I'm starting to think this may be part of my issue. </p>
  
  <p>I'd like to get chrome driver to work because firefox does not run in the background (which I need), and ie is a pain.</p>
  
  <p>I want to figure this out because I can't see an element I need to click when the window is so small.</p>