Javatpoint Logo
Javatpoint Logo

get_window_size driver method - Selenium Python

What is a Selenium Module?

Selenium is a module offered by Python used to automate testing. It offers an easy-to-use API for making different functional tests with the help of the Selenium driver.

Selenium is an open-source Python framework that offers API for writing functional tests using Selenium. It is used for cross-browser testing of web applications. Various scripting languages support this library, like Python, Java, Node.js, C#, and Ruby.

Selenium is developed to drive the browser and execute tests for different applications used by developers, project managers, and quality assurance engineers to speed up the time. Over many years, Selenium evolved from a technology created to drive a single browser and run tests to a standard protocol for software to interact with a browser as if it were a human, an in-browser tool for recording and replaying tests (Selenium IDE), a distributed computing grid for running multiple tests at once (Selenium Grid), and many more.

Using Web drivers, Selenium navigates the web browsers and does the required testing like searching web pages, scrolling them, parsing them, running multiple tests simultaneously, etc.

Installing Selenium Library in Python

The Selenium library in Python can be installed using a command prompt or any Python terminal using this command:

The Web driver can be used for multiple tasks like controlling or transforming the browser by adding cookies, navigating the tabs, searching on the webpage, etc., using different methods provided by Selenium.

The article will let you learn about the get_window_size driver method in Selenium. This method is used to get the height and width of the current web page or window.

What is Window Size?

The Window Size in the Selenium Framework is the height and width of the window, which is being automated by the drivers.

Syntax of the get_window_size( )

Example of get_window_size( )

In this, using the driver's get() function, we will get the webpage we want to navigate. Then, using the get_window_size( ) function, we will get the current window's dimensions (height and width).

Implementation of get_window_size( )

Let's implement the above example with the help of a program in Python.

Code:

Output:4

{'width': 1050, 'height': 708}

Here is the screenshot of the window we get using the driver for the automation.

get_window_size driver method - Selenium Python

Explanation:

Using the Chrome driver, we have automated a website (javatpoint). Then, using the get_window_size() function, we get the height and width of the running. It can be changed as we move the window's position on the screen.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA




news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news