Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 在浏览器中进行图元检查时,如何获取图元尺寸值?_Python 3.x_Selenium_Selenium Webdriver - Fatal编程技术网

Python 3.x 在浏览器中进行图元检查时,如何获取图元尺寸值?

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

在浏览器中进行图元检查时,如何获取图元尺寸值?我的意思是,如何通过selenium或其他方式获得
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.