- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Maximize WebDriver (Selenium 2) in Python.
We can maximize browser window with Selenium webdriver in Python. It is a good practise to maximize the browser while running the tests to reduce the chance of failure.
Once a browser is maximized, the majority of elements become visible to the screen and the probability of interaction with the driver increases. Also, with a maximized browser, users have a better view of the elements on the page.
Some of ways of maximizing browser −
With the maximize_window method
With the fullscreen_window method
Code Implementation with maximize_window()
from selenium import webdriver #set chromedriver.exe path driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") # maximize browser driver.maximize_window() driver.get("https://www.tutorialspoint.com/index.htm") driver.close()
Code Implementation with fullscreen_window()
from selenium import webdriver #set chromedriver.exe path driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") # maximize browser driver.fullscreen_window() driver.get("https://www.tutorialspoint.com/index.htm") driver.close()
In the above examples, we have performed the below steps −
The browser driver path has been configured.
The browser has been launched.
URL has been hit on the browser.
The browser has been maximized.
Finally, the browser has been closed.
Kickstart Your Career
Get certified by completing the courseGet Started