Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/wait for multiple #1922

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SeleniumLibrary/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class SeleniumLibrary:
def wait_until_location_is_not(self, location: str, timeout: Optional[Optional] = None, message: Optional[Optional] = None): ...
def wait_until_page_contains(self, text: str, timeout: Optional[Optional] = None, error: Optional[Optional] = None): ...
def wait_until_page_contains_element(self, locator: Union, timeout: Optional[Optional] = None, error: Optional[Optional] = None, limit: Optional[Optional] = None): ...
def wait_until_page_contains_any_of_elements(self, locators: list[Union[WebElement, None, str]], timeout: Optional[timedelta] = None, error: Optional[str] = None): ...
def wait_until_page_does_not_contain(self, text: str, timeout: Optional[Optional] = None, error: Optional[Optional] = None): ...
def wait_until_page_does_not_contain_element(self, locator: Union, timeout: Optional[Optional] = None, error: Optional[Optional] = None, limit: Optional[Optional] = None): ...
# methods from library.
Expand Down
23 changes: 23 additions & 0 deletions src/SeleniumLibrary/keywords/waiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,29 @@ def wait_until_page_contains_element(
error,
)

@keyword
def wait_until_page_contains_any_of_elements(
self,
locators: list[Union[WebElement, None, str]],
timeout: Optional[timedelta] = None,
error: Optional[str] = None,
):
"""Waits until any of the element locators in ``locators`` appears on the current page.

Fails if ``timeout`` expires before the element appears. See
the `Timeouts` section for more information about using timeouts and
their default value and the `Locating elements` section for details
about the locator syntax.

``error`` can be used to override the default error message.
"""
return self._wait_until(
lambda: any([self.find_element(locator, required=False) for locator in locators]),
f"Elements did not appear in <TIMEOUT>: \n '{locators}'",
timeout,
error,
)

@keyword
def wait_until_page_does_not_contain_element(
self,
Expand Down