Reputation: 496
value_of_css_property(property_name)
returns value for a particular property.
But I want know if there is any way we can get all the css properties?
Upvotes: 7
Views: 6683
Reputation: 1695
element.get_property('style')
will give you all the properties
example:
print(e.get_property('style'))
['height', 'width', 'visibility', 'position', 'z-index', 'font-family', 'font-size', 'font-weight', 'font-style']
Upvotes: 0
Reputation: 52675
Try below to get property names:
element = driver.find_element_by_tag_name('a')
properties = driver.execute_script('return window.getComputedStyle(arguments[0], null);', element)
or to get all values of properties
element = driver.find_element_by_tag_name('a')
properties = driver.execute_script('return window.getComputedStyle(arguments[0], null);', element)
for property in properties:
print(element.value_of_css_property(property))
Upvotes: 14