0 votes
1 view
in DevOps and Agile by (28.4k points)

I see that there are methods for getting the screen 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 any way to get either the location or dimensions of an element with the Selenium Python bindings?

1 Answer

0 votes
by (28.4k points)

WebElements have 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)

Output:

{'y': 202, 'x': 165}

{'width': 77, 'height': 22}

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

 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...