python - make selenium driver wait until elements style attribute has changed -


as title suggests need wait dynamically loaded material. material shows when scrolling end of page each time.

currently trying following:

driver.execute_script("window.scrollto(0, document.body.scrollheight);") webdriverwait(driver, 5).until(expected_conditions.presence_of_element_located(     (by.xpath, "//*[@id='inf-loader']/span[1][contains(@style, 'display: inline-block')]"))) 

is xpath problem here (not familiar)? keeps timing out though display style change when scrolling selenium.

i wait display style change inline-block custom expected condition , use value_of_css_property():

from selenium.webdriver.support import expected_conditions ec  class wait_for_display(object):     def __init__(self, locator):         self.locator = locator      def __call__(self, driver):         try:             element = ec._find_element(driver, self.locator)             return element.value_of_css_property("display") == "inline-block"         except staleelementreferenceexception:             return false 

usage:

wait = webdriverwait(driver, 5) wait.until(wait_for_display((by.xpath, "//*[@id='inf-loader']/span[1]"))) 

you may try tweak poll frequency make check condition more often:

wait = webdriverwait(driver, 5, poll_frequency=0.1)  # default frequency 0.5 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -