Using while statement to check visibility or display CSS property (Selenium Python)

It happens often that your page is not predictable regarding when a certain element will become visible (ie modal).
This method has proven quite reliable in my tests. Loop through every second (or another time interval) until the element becomes visible:

while "hidden" in self.driver.find_element_by_id("ModalDialog").value_of_css_property("visibility"):
             time.sleep(1)

If it never becomes visible, well then your test will never end. That’s job security.
Similar method can be used for the display property.
Learn more about display and visibility over at w3schools (http://www.w3schools.com/css/css_display_visibility.asp).