Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.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

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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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 在Selenium中按类查找元素_Python_Selenium_Selenium Webdriver - Fatal编程技术网

Python 在Selenium中按类查找元素

Python 在Selenium中按类查找元素,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,好的,所以我想找到179中的: <span class="totalcount">179</span> 将maxpage中的结果设置为: <selenium.webdriver.firefox.webelement.FirefoxWebElement (session="2c241847-ac56-4ed5-bb0e-73b473833ce4", element="9f837b6e-e78f-4fca-87b8-4efcb463e5a3")> 但我想得

好的,所以我想找到179中的:

<span class="totalcount">179</span>
将maxpage中的结果设置为:

<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="2c241847-ac56-4ed5-bb0e-73b473833ce4", element="9f837b6e-e78f-4fca-87b8-4efcb463e5a3")>


但我想得到等于179的值。您有什么建议吗?

maxpage
是WebElement类的实例。使用
maxpage.text
获取内容。

您也可以使用
maxpage.get\u属性(“值”)
命令
驱动程序。按类名称(“totalcount”)查找元素
返回WebElement

此类实例包括许多内容,如元素的位置、是否可见/可单击等。您必须使用
.text
查找元素的“值”。请尝试以下操作:

maxpage=driver。通过类名称(“totalcount”)查找元素。文本

或者
maxpage.text
并将其分配给字符串。

可能重复的您是否尝试过我的答案?如果有帮助的话,请在我的答案旁边打勾。谢谢。
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="2c241847-ac56-4ed5-bb0e-73b473833ce4", element="9f837b6e-e78f-4fca-87b8-4efcb463e5a3")>