在使用Selenium获取元素的class值时,你可以按照以下步骤操作: 定位到包含目标class的元素: 首先,你需要使用Selenium的定位器(如ID、name、XPath、CSS选择器等)来定位到包含你感兴趣class属性的HTML元素。 使用Selenium的get_attribute方法获取class值: 一旦定位到元素,你可以使用get_attribute方法来获取该元素的class属性值...
1> 获取class值为important的h1标签 find_element_by_css_selector(h1.importane) 2>获取所有class值为important的标签 find_element_by_css_selector(*.importane)或者find_element_by_css_selector(.importane) 3>获取class值为important warning的标签 find_element_by_css_selector(.importane.warning) 2通...
您可以尝试下一个示例: