Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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 2.7 使用Selenium+;时是否可以在div中获取类的名称;蟒蛇_Python 2.7_Selenium_Selenium Chromedriver - Fatal编程技术网

Python 2.7 使用Selenium+;时是否可以在div中获取类的名称;蟒蛇

Python 2.7 使用Selenium+;时是否可以在div中获取类的名称;蟒蛇,python-2.7,selenium,selenium-chromedriver,Python 2.7,Selenium,Selenium Chromedriver,我想知道是否有可能获取类名“status_indicator yellow”并将其存储在变量中 请尝试以下代码: <span id="app_status_health"> <span class="status_indicator yellow" id="ext-gen10267"></span> </span> 希望它能帮助你 @K.Abhulimen,如果我的答案有帮助的话——在我的答案旁边打勾,谢谢。我看到的可能是重复的,它对我不起作用

我想知道是否有可能获取类名“status_indicator yellow”并将其存储在变量中

请尝试以下代码:

<span id="app_status_health">
 <span class="status_indicator yellow" id="ext-gen10267"></span>
</span>

希望它能帮助你

@K.Abhulimen,如果我的答案有帮助的话——在我的答案旁边打勾,谢谢。我看到的可能是重复的,它对我不起作用,但在接受的答案中使用了相同的实现!
class_name = driver.find_element_by_css_selector("#app_status_health>span").get_attribute("class")