Get Coordinates & Dimensions of Element with Python and Selenium

app.py

driver = webdriver.Firefox()

e = driver.find_element_by_xpath("//someXpath")

location = e.location
size = e.size
w, h = size['width'], size['height']

print(location)
print(size)
print(w, h)

Output

{'y': 202, 'x': 165}
{'width': 77, 'height': 22}
77 22

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.