2024-05-21 17:13:52 发布
网友
我看到有一些方法可以通过各种用于Selenium的Java库来获取元素的屏幕位置和尺寸,比如org.openqa.selenium.Dimension,它提供.getSize(),以及org.openqa.selenium.Point和getLocation()。
org.openqa.selenium.Dimension
.getSize()
org.openqa.selenium.Point
getLocation()
有没有任何方法可以通过Selenium Python绑定获得元素的位置或维度?
明白了!线索在selenium.webdriver.remote.webelement — Selenium 3.14 documentation.
web元素具有属性.size和.location。两者都属于dict类型。
.size
.location
dict
driver = webdriver.Firefox() e = driver.find_element_by_xpath("//someXpath") location = e.location size = e.size print(location) print(size)
输出:
{'y': 202, 'x': 165} {'width': 77, 'height': 22}
它们还有一个名为^{}的属性,它本身就是一个dict,包含元素的size和location。
size
location
明白了!线索在selenium.webdriver.remote.webelement — Selenium 3.14 documentation.
web元素具有属性
.size
和.location
。两者都属于dict
类型。输出:
它们还有一个名为^{} 的属性,它本身就是一个
dict
,包含元素的size
和location
。相关问题 更多 >
编程相关推荐