Python 3.x 在浏览器中进行图元检查时,如何获取图元尺寸值?
在浏览器中进行图元检查时,如何获取图元尺寸值?我的意思是,如何通过selenium或其他方式获得Python 3.x 在浏览器中进行图元检查时,如何获取图元尺寸值?,python-3.x,selenium,selenium-webdriver,Python 3.x,Selenium,Selenium Webdriver,在浏览器中进行图元检查时,如何获取图元尺寸值?我的意思是,如何通过selenium或其他方式获得402x48 你可以用硒来做这个 getAttribute(arg0)方法 String width = driver.findElement(image locator).getAttribute("width"); String height = driver.findElement(image locator).getAttribute("height"); 嗨,欢迎来到stack overf
402x48
你可以用硒来做这个
getAttribute(arg0)
方法
String width = driver.findElement(image locator).getAttribute("width");
String height = driver.findElement(image locator).getAttribute("height");
嗨,欢迎来到stack overflow。有关如何提问和相应更新问题的更多详细信息,请参阅该链接。
.size
或其他语言首选.getSize()
。java中的Selenium API只有.getSize()
我不确定其他语言。我希望它能为您解决问题。我的意思是:.getSize()
比这两个.getAttribute()
更受欢迎。
print(driver.find_element_by_xpath("//someXpath").size) # gives size of the element as width & height.