Selenium get_property is None?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Selenium get_property is None?



I can't seem to get any properties from any elements on any webpages and I don't know what I'm doing wrong. I've written this very basic test case to show what I mean:


from selenium import webdriver

URL = "https://stackoverflow.com/tour"
Driver = webdriver.Firefox()

Driver.get(URL)

TheContent = Driver.find_element_by_id("content")
print(TheContent.get_property("background-color"))



This seems like the simplest of simple tests to me, but it still returns different results than expected. I know by using the Dev Tools that the StackOverflow tour page has a div with the id content and that its background color is #FFF (white).


content



A screenshot inspecting the StackOverflow webpage



Yet running the above script still prints out "None." I'm pretty sure it is printing out "None" because it is grabbing the wrong element, but I have no idea why. There is only one element with the id content?


content



Can anyone explain what I am doing wrong? Thanks so much in advance!





Possible duplicate of How to obtain CSS value (eg. color) of element using selenium webdriver in Python
– JeffC
Aug 8 at 1:57





But get_property and get_attribute are supposed to work in Selenium Python, too? Says so in the docs.
– Guy
Aug 8 at 2:11



get_property


get_attribute





They do but I think the issue is that you are looking for a CSS style and not a property of the element itself. What happens when you try to return the id using .get_property()? I'm assuming that works.
– JeffC
Aug 8 at 3:09


id


.get_property()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard