Get coordinates or dimensions of element with Python using Selenium WebDriver

0 votes
I see that there are methods for getting the position and dimensions of an element through various Java libraries for Selenium, such as org.openqa.selenium.Dimension, which offers .getSize(), and org.openqa.selenium.Point with getLocation().

Is there a way to get the location or dimensions of an element using Selenium Python bindings?
Jul 11, 2018 in Selenium by QueenBee
• 1,820 points
8,928 views

1 answer to this question.

0 votes

WebElements have the properties such as .size and .location. Both are of type dict.

driver = webdriver.Firefox()
e = driver.find_element_by_xpath("//GiveXpath")
location = e.location
size = e.size
print(location)
print(size)

Returns:

{'y': 200, 'x': 125}
{'width': 87, 'height': 32}

Elements also have a property called rect which is itself a dict, and contains the element's size and location.

answered Jul 11, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

How to get coordinates of a web element using Python Selenium?

Hey Ushma, you can use following code ...READ MORE

answered Jul 29, 2019 in Selenium by Abha
• 28,140 points
3,341 views
+1 vote
1 answer

Can I get meta-description of a webpage using selenium webdriver with python?

Hi Arpit, you can use this code ...READ MORE

answered Jul 31, 2019 in Selenium by Anvi
• 14,150 points
4,159 views
0 votes
2 answers
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,773 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,188 views
0 votes
2 answers

What is the role of TestNG & JUnit frameworks in Selenium?

TestNG and JUnit are test frameworks . it ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
2,938 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,263 views
0 votes
1 answer

How do I get current URL in Selenium Webdriver using Python?

Use current_url element. Example: print browser.current_url READ MORE

answered Aug 8, 2018 in Selenium by Meci Matt
• 9,460 points
26,051 views
0 votes
1 answer

XPath for the elements with no ID or Name in Selenium Webdriver

Use like this or similar to this: //div[@id="top-level-menu-item-3"]/div[@class="filter-label"] //div[@id="top-level-menu1"] ...READ MORE

answered Apr 17, 2018 in Selenium by Meci Matt
• 9,460 points
7,467 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP