Skip to content

Commit 64240ea

Browse files
authored
Improve implcit wait testing (#1360)
Fixes #1362
1 parent bc344b9 commit 64240ea

File tree

4 files changed

+62
-19
lines changed

4 files changed

+62
-19
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
*** Settings ***
2+
Resource ../resource.robot
3+
4+
*** Test Cases ***
5+
Browser Open With Implicit Wait And Test Wating
6+
[Setup] Open Browser To Start Page
7+
${old_value} = Set Selenium Implicit Wait 3
8+
${start_time} = Get Current Date result_format=epoch exclude_millis=yes
9+
Run Keyword And Ignore Error Wait Until Page Contains Element //not_here 1
10+
${end_time} = Get Current Date result_format=epoch exclude_millis=yes
11+
Should Be True ${start_time + 3} <= ${end_time}
12+
[Teardown] Set Selenium Implicit Wait ${old_value}
13+
14+
15+
Implicit Wait And New Window
16+
${old_value} = Set Selenium Implicit Wait 3
17+
Execute Javascript window.open("about:blank")
18+
Select Window NEW
19+
${start_time} = Get Current Date result_format=epoch exclude_millis=yes
20+
Run Keyword And Ignore Error Wait Until Page Contains Element //not_here 1
21+
${end_time} = Get Current Date result_format=epoch exclude_millis=yes
22+
Should Be True ${start_time + 3} <= ${end_time}
23+
[Teardown] Set Selenium Implicit Wait ${old_value}
24+
25+
Implicit Wait And Back To Main Window
26+
${old_value} = Set Selenium Implicit Wait 3
27+
Execute Javascript window.open("about:blank")
28+
Select Window NEW
29+
Select Window MAIN
30+
${start_time} = Get Current Date result_format=epoch exclude_millis=yes
31+
Run Keyword And Ignore Error Wait Until Page Contains Element //not_here 1
32+
${end_time} = Get Current Date result_format=epoch exclude_millis=yes
33+
Should Be True ${start_time + 3} <= ${end_time}
34+
[Teardown] Set Selenium Implicit Wait ${old_value}

atest/acceptance/open_and_close.robot

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ Browser Should Open And Close
77
Open Browser To Start Page Without Testing Default Options
88
Close Browser
99

10-
Browser Open With Implicit Wait Should Not Override Default
11-
Open Browser To Start Page And Test Implicit Wait 10
12-
Close Browser
13-
1410
There Should Be A Good Error Message If Browser Is Not Opened
1511
Run Keyword And Expect Error No browser is open. Title Should Be foo
1612

atest/acceptance/resource.robot

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ Open Browser To Start Page Without Testing Default Options
3131
${orig timeout} = Set Selenium Timeout 10 seconds
3232
[Return] ${orig speed} 5 seconds
3333

34-
Open Browser To Start Page And Test Implicit Wait
35-
[Arguments] ${implicit_wait}
36-
[Documentation] This keyword tests that 'Set Selenium Implicit Wait' and
37-
... 'Get Selenium Implicit Wait' work as expected
38-
Should Not Be Equal 0 ${implicit_wait}
39-
... Please do not pass in a value of 0 for the implicit wait argument for this function
40-
${old_wait}= Set Selenium Implicit Wait ${implicit_wait}
41-
Open Browser ${FRONT PAGE} ${BROWSER} remote_url=${REMOTE_URL}
42-
... desired_capabilities=${DESIRED_CAPABILITIES}
43-
${default_implicit_wait} = Get Selenium Implicit Wait
44-
Should Be Equal ${implicit_wait} seconds ${default_implicit_wait}
45-
#be sure to revert the implicit wait to whatever it was before so as to not effect other tests
46-
Set Selenium Implicit Wait ${old_wait}
47-
4834
Cannot Be Executed In IE
4935
[Documentation] Cannot Be Executed In IE
5036
${runsInIE}= Set Variable If "${BROWSER}".replace(' ', '').lower() in ['ie', '*iexplore', 'internetexplorer'] ${TRUE}

utest/test/keywords/test_browsermanagement.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from selenium import webdriver
55

66
from SeleniumLibrary.keywords import BrowserManagementKeywords
7-
from SeleniumLibrary.utils import SELENIUM_VERSION
7+
from SeleniumLibrary import SeleniumLibrary
88

99

1010
class BrowserManagementTests(unittest.TestCase):
@@ -26,6 +26,33 @@ def test_set_selenium_timeout_only_affects_open_browsers(self):
2626
verifyNoMoreInteractions(second_browser)
2727
unstub()
2828

29+
def test_selenium_implicit_wait_default(self):
30+
sl = SeleniumLibrary()
31+
self.assertEqual(sl.implicit_wait, 0.0)
32+
33+
def test_set_selenium_implicit_wait(self):
34+
sl = SeleniumLibrary()
35+
sl.set_selenium_implicit_wait('5.0')
36+
self.assertEqual(sl.implicit_wait, 5.0)
37+
38+
sl.set_selenium_implicit_wait('1 min')
39+
self.assertEqual(sl.implicit_wait, 60.0)
40+
41+
def test_selenium_implicit_wait_error(self):
42+
with self.assertRaises(ValueError):
43+
SeleniumLibrary(implicit_wait='False')
44+
sl = SeleniumLibrary(implicit_wait='3')
45+
with self.assertRaises(ValueError):
46+
sl.set_selenium_implicit_wait('1 vuosi')
47+
48+
def test_selenium_implicit_wait_get(self):
49+
sl = SeleniumLibrary(implicit_wait='3')
50+
self.assertEqual(sl.get_selenium_implicit_wait(), '3 seconds')
51+
52+
org_value = sl.set_selenium_implicit_wait('1 min')
53+
self.assertEqual(sl.get_selenium_implicit_wait(), '1 minute')
54+
self.assertEqual(org_value, '3 seconds')
55+
2956
def test_bad_browser_name(self):
3057
ctx = mock()
3158
bm = BrowserManagementKeywords(ctx)

0 commit comments

Comments
 (0)