[Python] Why are expected_conditions all_of, none_of, and any_of absent in the Selenium python...

Discussão em 'Python' iniciado por Stack, Maio 29, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Selenium with Python and came across the need to use WebDriverWait and selenium.webdriver.support.expected_conditions in it. I have to wait for an element to be removed and for another to be displayed, so I was wishing to use all_of and none_of to make the conditions easier to understand:

    WebDriverWait(browser, 10).until(
    EC.all_of(
    EC.presence_of_element_located((By.CSS_SELECTOR, "span[title='VMC OIC-2 batch 2022'")),
    EC.none_of(
    EC.presence_of_element_located((By.CSS_SELECTOR, "div#startup")),
    EC.presence_of_element_located((By.CSS_SELECTOR, "div#initial-startup"))
    )
    )
    )


    Unforunately, I received this error:

    AttributeError: module 'selenium.webdriver.support.expected_conditions' has no attribute 'all_of'


    On further inspection through raw printing I got to know that none of the any_of, all_of and none_of conditions were working.

    Another thing to note is that the mentioned conditions are present in Selenium with Java. I could find an issue talking about this, and it seems like any_of, all_of and none_of were eventually added to expected_conditions as is evident in the Selenium repository's corresponding file: expected_conditions.py (the last three functions).

    This question is demanding an explanation, not an alternative, I am well aware I can write a function to do the same task or even copy the function listed in expected_conditions.py but I would really like to know why these functions are present in the repository and absent in the working package.

    Thanks for reading!

    Continue reading...

Compartilhe esta Página