Skip to content

Commit

Permalink
robotframework#1297: new wait until location is keyword and atest
Browse files Browse the repository at this point in the history
  • Loading branch information
acaovilla committed Jan 21, 2019
1 parent abd84da commit 5588670
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions atest/acceptance/keywords/location.robot
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,24 @@ Wait Until Location Contains Fails With Timeout
Run Keyword And Expect Error
... my_message
... Wait Until Location Contains not_here timeout=0.1 message=my_message

Wait Until Location Is
[Setup] Go To Page "javascript/wait_location.html"
Click Element button
Wait Until Location Is http://localhost:7000/html/

Wait Until Location Is Fails
[Setup] Go To Page "javascript/wait_location.html"
${orig_timeout}= Set Selenium Timeout 2 s
Click Element button
Run Keyword And Expect Error
... Location did not is 'not_me' in 2 seconds.
... Wait Until Location Is not_me
Set Selenium Timeout ${orig_timeout}

Wait Until Location Is Fails With Timeout
[Setup] Go To Page "javascript/wait_location.html"
Click Element button
Run Keyword And Expect Error
... my_message
... Wait Until Location Is not_here timeout=0.1 message=my_message
21 changes: 21 additions & 0 deletions src/SeleniumLibrary/keywords/waiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ def wait_for_condition(self, condition, timeout=None, error=None):
timeout, error
)

@keyword
def wait_until_location_is(self, expected, timeout=None, message=None):
"""Wait until that current URL is ``expected``.
The ``expected`` argument is the expected value in url.
Fails if ``timeout`` expires before the location is. See
the `Timeouts` section for more information about using timeouts
and their default value.
The ``message`` argument can be used to override the default error
message.
New in SeleniumLibrary 3.4.0
"""

expected = str(expected)
self._wait_until(lambda: expected == self.driver.current_url,
"Location did not is '%s' in <TIMEOUT>." % expected,
timeout, message)

@keyword
def wait_until_location_contains(self, expected, timeout=None, message=None):
"""Wait until that current URL contains ``expected``.
Expand Down

0 comments on commit 5588670

Please sign in to comment.