

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 get coordinates or dimensions of element with Selenium Python?
We can get coordinates or dimensions of elements with Selenium webdriver. Each of the elements have .size and .location properties which give the x, y coordinates and height, width of the element in the form of a dictionary.
Syntax −
loc = element.location
s = element.size
Let us consider an element for which we shall find coordinates and dimensions−
Example
from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") driver.implicitly_wait(0.5) driver.get("https://www.tutorialspoint.com/about/about_careers.htm") #identify element l= driver.find_element_by_xpath("//img[@class='tp-logo']") #get x, y coordinates loc = l.location #get height, width s = l.size print(loc) print(s) driver.close()
Output
- Related Questions & Answers
- How to get attribute of element from Selenium?
- How to get the attribute value of a web element in Selenium (using Java or Python)?
- How to get the screenshot of a particular element in the page in Selenium with python?
- Get the Kronecker product of two arrays with different dimensions in Python
- Get the Kronecker product of arrays with 4D and 3D dimensions in Python
- How to get the dimensions of a view in Android?
- How to get text from Selenium element WebElement object?
- Checking if element exists with Python Selenium.
- How to get text with selenium web driver in python?
- How to get selected option using Selenium WebDriver with Python?
- How to identify nth element using xpath in Selenium with python?
- How to get an attribute value of an element in Selenium Webdriver?
- How to get the complete screenshot of a page in Selenium with python?
- Screenshot of a particular element with Python Selenium in Linux
- How to get the dimensions of a view in iOS App?
Advertisements