Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Resize Browser Window in WebDriver?
We can resize the browser window in Selenium webdriver. We can configure the size of the browser with the help of the set_window_size method in Python.
The dimensions of the window size are passed as parameters to this method. Again, to get the size of the browser, we can use the method get_window_size.
Syntax
driver.set_window_size(200,500)
Example
Code Implementation
from selenium import webdriver
#set geckodriver.exe path
driver = webdriver.Firefox(executable_path="C:\geckodriver.exe")
#maximize browser
driver.maximize_window()
#launch URL
driver.get("https://www.tutorialspoint.com/index.htm")
#new browser size
driver.set_window_size(800, 880)
#get window size
print(driver.get_window_size())
#close browser
driver.close()
Output

Advertisements