7

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?

2 Answers 2

14

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))
Sign up to request clarification or add additional context in comments.

Comments

0

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']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.