No one has actually requested this keyword be added to the library. I suggest you create an issue.
There are several ways to extend libraries. Whatever way you go it is best to import libraries (at least ones that do not come with RF) through a resource file. The benefit is realized when you can go to that resource and add a library like the one in this post and it is available to many test suites with one change.
Anyways, here is an example of a library that adds a keyword to S2L that you feel ought to be there. Some private methods are called, but this way does not rely on patching. Note that a big difference between the waiting here and Wait Until Keyword Succeeds is that all but fatal errors are ignored with WUKS whereas with this custom library, any error will cause the keyword to stop waiting and fail.
By the way Markus has implemented this keyword as Wait Until Page Not Contains Element in the Java port.
from robot.libraries.BuiltIn import BuiltIn
from Selenium2Library.keywords.keywordgroup import KeywordGroup
def _get_s2l():
return BuiltIn().get_library_instance('Selenium2Library')
class S2LExt(KeywordGroup):
def _run_on_failure(self):
_get_s2l()._run_on_failure()
def wait_until_page_does_not_contain(self, text, timeout=None, error=None):
"""Waits until `text` is not present on current page.
Fails if `timeout` expires and text is still present. See
`introduction` for more information about `timeout` and its
default value.
`error` can be used to override the default error message.
See also `Wait Until Page Contains Element`, `Wait For Condition` and
BuiltIn keyword `Wait Until Keyword Succeeds`.
"""
s2l = _get_s2l()
if not error:
error = "Text '%s' still on the page in <TIMEOUT>" % text
page_does_not_contain = lambda text: not s2l._page_contains(text)
s2l._wait_until(timeout, error, page_does_not_contain, text)