How can I control Chromedriver open window size?
I'm using Selenium WebDriver for automation and I'm using Chromedriver.
I have noticed that when my driver runs and opens the chrome browser, it opens the browser with a strange size. I tried to fixed it but in vain.
Does anybody know how can I change it?
Python
Drivers
chrome = 57.0.2987.133
chromedriver = 2.27.440174
Code:
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--window-size=1920,1080")
driver = Chrome(chrome_options=chrome_options)
Use this for your custom size:
driver.manage().window().setSize(new Dimension(1024,768));
you can change your dimensions as per your requirements.
C# version of @yonatan-kiron's answer, and Selenium's using
statement from their example code.
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--window-size=1300,1000");
using (IWebDriver driver = new ChromeDriver(chromeOptions))
{
...
}