Javatpoint Logo
Javatpoint Logo

get_window_rect Driver method - Selenium Python

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_rect driver method in Selenium. This method is used to get the x and y coordinates and the height and width of the current webpage or window.

Syntax of the get_window_rect( )

Example of get_window_rect()

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

The get_window_position() method of the driver in selenium only gives the x and y points of the current window. But this method also gives the height and width of the window.

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

Code:

Output4:

{'height': 611, 'width': 818, 'x': 64, 'y': 21}

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

get_window_rect Driver method - Selenium Python

Explanation:

Using the Chrome driver, we have automated a website (javatpoint). Then, using the get_window_rect() function, we get the position of the running window, including the x and y coordinates, height, and width. 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