selenium学习笔记9——selenium获取元素css中的
2018-07-20 本文已影响0人
满船清梦压星河ya_
获取元素的属性
driver.find_element_by_id("ua").get_attribute("color")
获取元素css中的属性
如果元素A的color属性没有在标签中,而是在css样式中,如何获取?
get_attribute()方法获取失败。
# 获取color属性
driver.find_element_by_id("ua").value_of_css_property("color")
# 获取背景图片
driver.find_element_by_id("ua").value_of_css_property("background-image")