selenium.webdriver.support.expected_conditions

Functions

alert_is_present() An expectation for checking if an alert is currently present and switching to it.
all_of(*expected_conditions) An expectation that all of multiple expected conditions is true.
any_of(*expected_conditions) An expectation that any of multiple expected conditions is true.
element_attribute_to_include(locator, str], …) An expectation for checking if the given attribute is included in the specified element.
element_located_selection_state_to_be(…) An expectation to locate an element and check if the selection state specified is in that state.
element_located_to_be_selected(locator, str]) An expectation for the element to be located is selected.
element_selection_state_to_be(element, …) An expectation for checking if the given element is selected.
element_to_be_clickable(mark, Tuple[str, str]]) An Expectation for checking an element is visible and enabled such that you can click it.
element_to_be_selected(element) An expectation for checking the selection is selected.
frame_to_be_available_and_switch_to_it(…) An expectation for checking whether the given frame is available to switch to.
invisibility_of_element(element, Tuple[str, …) An Expectation for checking that an element is either invisible or not present on the DOM.
invisibility_of_element_located(locator, …) An Expectation for checking that an element is either invisible or not present on the DOM.
new_window_is_opened(current_handles) An expectation that a new window will be opened and have the number of windows handles increase.
none_of(*expected_conditions) An expectation that none of 1 or multiple expected conditions is true.
number_of_windows_to_be(num_windows) An expectation for the number of windows to be a certain value.
presence_of_all_elements_located(locator, str]) An expectation for checking that there is at least one element present on a web page.
presence_of_element_located(locator, str]) An expectation for checking that an element is present on the DOM of a page.
staleness_of(element) Wait until an element is no longer attached to the DOM.
text_to_be_present_in_element(locator, str], …) An expectation for checking if the given text is present in the specified element.
text_to_be_present_in_element_attribute(…) An expectation for checking if the given text is present in the element’s attribute.
text_to_be_present_in_element_value(locator, …) An expectation for checking if the given text is present in the element’s value.
title_contains(title) An expectation for checking that the title contains a case-sensitive substring.
title_is(title) An expectation for checking the title of a page.
url_changes(url) An expectation for checking the current url.
url_contains(url) An expectation for checking that the current url contains a case- sensitive substring.
url_matches(pattern) An expectation for checking the current url.
url_to_be(url) An expectation for checking the current url.
visibility_of(element) An expectation for checking that an element, known to be present on the DOM of a page, is visible.
visibility_of_all_elements_located(locator, str]) An expectation for checking that all elements are present on the DOM of a page and visible.
visibility_of_any_elements_located(locator, str]) An expectation for checking that there is at least one element visible on a web page.
visibility_of_element_located(locator, str]) An expectation for checking that an element is present on the DOM of a page and visible.
selenium.webdriver.support.expected_conditions.alert_is_present() → Callable[[selenium.webdriver.remote.webdriver.WebDriver], Union[selenium.webdriver.common.alert.Alert, Literal[False]]][source]

An expectation for checking if an alert is currently present and switching to it.

selenium.webdriver.support.expected_conditions.all_of(*expected_conditions) → Callable[[D], Union[List[T], Literal[False]]][source]

An expectation that all of multiple expected conditions is true.

Equivalent to a logical ‘AND’. Returns: When any ExpectedCondition is not met: False. When all ExpectedConditions are met: A List with each ExpectedCondition’s return value.

selenium.webdriver.support.expected_conditions.any_of(*expected_conditions) → Callable[[D], Union[Literal[False], T]][source]

An expectation that any of multiple expected conditions is true.

Equivalent to a logical ‘OR’. Returns results of the first matching condition, or False if none do.

selenium.webdriver.support.expected_conditions.element_attribute_to_include(locator: Tuple[str, str], attribute_: str) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], bool][source]

An expectation for checking if the given attribute is included in the specified element.

locator, attribute

selenium.webdriver.support.expected_conditions.element_located_selection_state_to_be(locator: Tuple[str, str], is_selected: bool) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], bool][source]

An expectation to locate an element and check if the selection state specified is in that state.

locator is a tuple of (by, path) is_selected is a boolean

selenium.webdriver.support.expected_conditions.element_located_to_be_selected(locator: Tuple[str, str]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], bool][source]

An expectation for the element to be located is selected.

locator is a tuple of (by, path)

selenium.webdriver.support.expected_conditions.element_selection_state_to_be(element: selenium.webdriver.remote.webelement.WebElement, is_selected: bool) → Callable[[Any], bool][source]

An expectation for checking if the given element is selected.

element is WebElement object is_selected is a Boolean.

selenium.webdriver.support.expected_conditions.element_to_be_clickable(mark: Union[selenium.webdriver.remote.webelement.WebElement, Tuple[str, str]]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], Union[Literal[False], selenium.webdriver.remote.webelement.WebElement]][source]

An Expectation for checking an element is visible and enabled such that you can click it.

element is either a locator (text) or an WebElement

selenium.webdriver.support.expected_conditions.element_to_be_selected(element: selenium.webdriver.remote.webelement.WebElement) → Callable[[Any], bool][source]

An expectation for checking the selection is selected.

element is WebElement object

selenium.webdriver.support.expected_conditions.frame_to_be_available_and_switch_to_it(locator: Union[Tuple[str, str], str]) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation for checking whether the given frame is available to switch to.

If the frame is available it switches the given driver to the specified frame.

selenium.webdriver.support.expected_conditions.invisibility_of_element(element: Union[selenium.webdriver.remote.webelement.WebElement, Tuple[str, str]]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], Union[selenium.webdriver.remote.webelement.WebElement, bool]][source]

An Expectation for checking that an element is either invisible or not present on the DOM.

element is either a locator (text) or an WebElement

selenium.webdriver.support.expected_conditions.invisibility_of_element_located(locator: Union[selenium.webdriver.remote.webelement.WebElement, Tuple[str, str]]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], Union[selenium.webdriver.remote.webelement.WebElement, bool]][source]

An Expectation for checking that an element is either invisible or not present on the DOM.

locator used to find the element

selenium.webdriver.support.expected_conditions.new_window_is_opened(current_handles: List[str]) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation that a new window will be opened and have the number of windows handles increase.

selenium.webdriver.support.expected_conditions.none_of(*expected_conditions) → Callable[[D], bool][source]

An expectation that none of 1 or multiple expected conditions is true.

Equivalent to a logical ‘NOT-OR’. Returns a Boolean

selenium.webdriver.support.expected_conditions.number_of_windows_to_be(num_windows: int) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation for the number of windows to be a certain value.

selenium.webdriver.support.expected_conditions.presence_of_all_elements_located(locator: Tuple[str, str]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], List[selenium.webdriver.remote.webelement.WebElement]][source]

An expectation for checking that there is at least one element present on a web page.

locator is used to find the element returns the list of WebElements once they are located

selenium.webdriver.support.expected_conditions.presence_of_element_located(locator: Tuple[str, str]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], selenium.webdriver.remote.webelement.WebElement][source]

An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible.

locator - used to find the element returns the WebElement once it is located

selenium.webdriver.support.expected_conditions.staleness_of(element: selenium.webdriver.remote.webelement.WebElement) → Callable[[Any], bool][source]

Wait until an element is no longer attached to the DOM.

element is the element to wait for. returns False if the element is still attached to the DOM, true otherwise.

selenium.webdriver.support.expected_conditions.text_to_be_present_in_element(locator: Tuple[str, str], text_: str) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], bool][source]

An expectation for checking if the given text is present in the specified element.

locator, text

selenium.webdriver.support.expected_conditions.text_to_be_present_in_element_attribute(locator: Tuple[str, str], attribute_: str, text_: str) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], bool][source]

An expectation for checking if the given text is present in the element’s attribute.

locator, attribute, text

selenium.webdriver.support.expected_conditions.text_to_be_present_in_element_value(locator: Tuple[str, str], text_: str) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], bool][source]

An expectation for checking if the given text is present in the element’s value.

locator, text

selenium.webdriver.support.expected_conditions.title_contains(title: str) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation for checking that the title contains a case-sensitive substring.

title is the fragment of title expected returns True when the title matches, False otherwise

selenium.webdriver.support.expected_conditions.title_is(title: str) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation for checking the title of a page.

title is the expected title, which must be an exact match returns True if the title matches, false otherwise.

selenium.webdriver.support.expected_conditions.url_changes(url: str) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation for checking the current url.

url is the expected url, which must not be an exact match returns True if the url is different, false otherwise.

selenium.webdriver.support.expected_conditions.url_contains(url: str) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation for checking that the current url contains a case- sensitive substring.

url is the fragment of url expected, returns True when the url matches, False otherwise

selenium.webdriver.support.expected_conditions.url_matches(pattern: str) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation for checking the current url.

pattern is the expected pattern. This finds the first occurrence of pattern in the current url and as such does not require an exact full match.

selenium.webdriver.support.expected_conditions.url_to_be(url: str) → Callable[[selenium.webdriver.remote.webdriver.WebDriver], bool][source]

An expectation for checking the current url.

url is the expected url, which must be an exact match returns True if the url matches, false otherwise.

selenium.webdriver.support.expected_conditions.visibility_of(element: selenium.webdriver.remote.webelement.WebElement) → Callable[[Any], Union[Literal[False], selenium.webdriver.remote.webelement.WebElement]][source]

An expectation for checking that an element, known to be present on the DOM of a page, is visible.

Visibility means that the element is not only displayed but also has a height and width that is greater than 0. element is the WebElement returns the (same) WebElement once it is visible

selenium.webdriver.support.expected_conditions.visibility_of_all_elements_located(locator: Tuple[str, str]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], Union[List[selenium.webdriver.remote.webelement.WebElement], Literal[False]]][source]

An expectation for checking that all elements are present on the DOM of a page and visible. Visibility means that the elements are not only displayed but also has a height and width that is greater than 0.

locator - used to find the elements returns the list of WebElements once they are located and visible

selenium.webdriver.support.expected_conditions.visibility_of_any_elements_located(locator: Tuple[str, str]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], List[selenium.webdriver.remote.webelement.WebElement]][source]

An expectation for checking that there is at least one element visible on a web page.

locator is used to find the element returns the list of WebElements once they are located

selenium.webdriver.support.expected_conditions.visibility_of_element_located(locator: Tuple[str, str]) → Callable[[Union[selenium.webdriver.remote.webdriver.WebDriver, selenium.webdriver.remote.webelement.WebElement]], Union[Literal[False], selenium.webdriver.remote.webelement.WebElement]][source]

An expectation for checking that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

locator - used to find the element returns the WebElement once it is located and visible