
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
Set Window Size Using PhantomJS and Selenium WebDriver in Python
We can set window size using PhantomJS and Selenium webdriver in Python. To work with the PhantomJS, we should create a driver object of the webdriver.PhantomJS class.
Then pass the path of the phantomjs.exe driver file as a parameter to the Class. Next, to set the window size, we shall use the set_window_size method and pass the dimensions as parameters to the method.
To obtain the window size of the browser, we can use the get_window_size method.
Syntax
driver.set_window_size(800,1000) print(driver.get_window_size())
Example
from selenium import webdriver #set phantomjs.exe path driver = webdriver.PhantomJS(executable_path="C:\phantomjs.exe") driver.maximize_window() #launch URL driver.get("https://www.tutorialspoint.com/index.htm") #set new window size driver.set_window_size(800, 880) #obtain window size print(driver.get_window_size()) driver.quit()
Output
Advertisements