How to use Chrome options In Software Testing
First need to assign ChromeOptions() to one object let’s say ‘options’ then pass it to the driver to use options.
Assigning chrome options to the object ‘options’
options = webdriver.ChromeOptions()
Setting the size of the browser window using the below format
options.add_argument(“–window-size=width,height”)
Python3
#Python Program to Implement ChromeOptions from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By options = webdriver.ChromeOptions() # maximize the browser of width 2560 and height 1440 options.add_argument( "--window-size=1200,500" ) # chromedriver path service_obj = Service( 'C:\\webdrivers_selenium\\chromedriver.exe' ) # driver object driver = webdriver.Chrome(service = service_obj, options = options) # opening browser # closing browser driver.close() |
Output:
How to set browser width and height in Selenium WebDriver?
Using Selenium WebDriver, we can set the browser width and height. Various methods are available to set browser width and height. When we run any test, the browser will open in default size. So, if we need to change the size of the browser, we can do it using selenium WebDriver keywords. A few of them are listed below.
- Using maximize_window()
- Using minimize_window()
- Using set_window_size()
- Using chrome options
Contact Us