2024-03-29 15:52:44 发布
网友
例如,如果需要检查一个元素是否有class属性(在bs4中它是element.has_attr("class")),那么如何在Selenium中做到这一点呢?你知道吗
class
element.has_attr("class")
您可以使用.get_attribute()方法并检查结果是否是None,如下所示:
.get_attribute()
None
x = element.get_attribute('class') if x is not None: # then it has the attribute! else: # it doesn't have the attribute =(
您可以使用
.get_attribute()
方法并检查结果是否是None
,如下所示:相关问题 更多 >
编程相关推荐