user964503
user964503

Reputation: 131

wait element to be invisible selenium

I'm trying to wait for an element to be invisible that exist on the previous step, the previous step is a window that appears and then I want to wait until it's closed to continue with the script, the element from previous step is:

//textarea[@id="position_description"]

but not sure why it waits more than the specified time on the first explicit wait time:

class InputAutocompleteElement(InputElement):
    def __set__(self, obj, value):
        WebDriverWait(self.driver, 2).until(EC.invisibility_of_element_located((By.XPATH, '//textarea[@id="position_description"]')))            
        driver = obj.driver
        element = self.find_element(driver, self.locator)
        element.clear()
        element.send_keys(value)
        WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID, "idOfAutocompleteDropdown"))
        element.send_keys(Keys.RETURN)

Takes more than the 2 seconds to continue with the rest of the lines, I'm not sure if it's related to an implicit wait that I have when I setup the login to access the application, the time for that implicit time is 10 seconds.

Upvotes: 0

Views: 1328

Answers (1)

JeffC
JeffC

Reputation: 25611

The Selenium docs state not to mix implicit and explicit waits. That's likely the issue you are seeing.

WARNING: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times.

Upvotes: 1

Related Questions