- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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
How to 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
- Related Articles
- How to open browser window in incognito/private mode using python selenium webdriver?
- How to set the size of the browser window in Selenium?
- How to maximize the browser window in Selenium WebDriver using C#?
- How to close child browser window in Selenium WebDriver using Java?
- How to hide Firefox window (Selenium WebDriver)?
- How to open a new window on a browser using Selenium WebDriver for python?
- How to set Proxy in Firefox using Selenium WebDriver?
- How to set Selenium Python WebDriver default timeout?
- How to Maximize window in chrome using webDriver (Python)?
- How to set Page Load Timeout using C# using Selenium WebDriver?
- How to save and load cookies using Python Selenium WebDriver?
- How to open a browser window in full screen using Selenium WebDriver with C#?
- How can I close a specific window using Selenium WebDriver with Java?
- How to refresh a webpage using Python Selenium Webdriver?
- How to click on a link using Selenium webdriver in Python.

Advertisements