robotframework-appiumwindows 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,163 +1,163 @@
1
- import time
2
-
3
- import robot
4
-
5
- from .keywordgroup import KeywordGroup
6
-
7
-
8
- class _WaitingKeywords(KeywordGroup):
9
-
10
- def __init__(self):
11
- self._sleep_between_wait = 0.2
12
-
13
- def wait_until_element_is_visible(self, locator, timeout=None, error=None):
14
- """Waits until element specified with `locator` is visible.
15
-
16
- Fails if `timeout` expires before the element is visible. See
17
- `introduction` for more information about `timeout` and its
18
- default value.
19
-
20
- `error` can be used to override the default error message.
21
-
22
- See also `Wait Until Page Contains`, `Wait Until Page Contains
23
- Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword
24
- Succeeds`.
25
- """
26
-
27
- def check_visibility():
28
- visible = self._is_visible(locator)
29
- if visible:
30
- return
31
- elif visible is None:
32
- return error or "Element locator '%s' did not match any elements after %s" % (
33
- locator, self._format_timeout(timeout))
34
- else:
35
- return error or "Element '%s' was not visible in %s" % (locator, self._format_timeout(timeout))
36
-
37
- self._wait_until_no_error(timeout, check_visibility)
38
-
39
- def wait_until_page_contains(self, text, timeout=None, error=None):
40
- """Waits until `text` appears on current page.
41
-
42
- Fails if `timeout` expires before the text appears. See
43
- `introduction` for more information about `timeout` and its
44
- default value.
45
-
46
- `error` can be used to override the default error message.
47
-
48
- See also `Wait Until Page Does Not Contain`,
49
- `Wait Until Page Contains Element`,
50
- `Wait Until Page Does Not Contain Element` and
51
- BuiltIn keyword `Wait Until Keyword Succeeds`.
52
- """
53
- if not error:
54
- error = "Text '%s' did not appear in <TIMEOUT>" % text
55
- self._wait_until(timeout, error, self._is_text_present, text)
56
-
57
- def wait_until_page_does_not_contain(self, text, timeout=None, error=None):
58
- """Waits until `text` disappears from current page.
59
-
60
- Fails if `timeout` expires before the `text` disappears. See
61
- `introduction` for more information about `timeout` and its
62
- default value.
63
-
64
- `error` can be used to override the default error message.
65
-
66
- See also `Wait Until Page Contains`,
67
- `Wait Until Page Contains Element`,
68
- `Wait Until Page Does Not Contain Element` and
69
- BuiltIn keyword `Wait Until Keyword Succeeds`.
70
- """
71
-
72
- def check_present():
73
- present = self._is_text_present(text)
74
- if not present:
75
- return
76
- else:
77
- return error or "Text '%s' did not disappear in %s" % (text, self._format_timeout(timeout))
78
-
79
- self._wait_until_no_error(timeout, check_present)
80
-
81
- def wait_until_page_contains_element(self, locator, timeout=None, error=None):
82
- """Waits until element specified with `locator` appears on current page.
83
-
84
- Fails if `timeout` expires before the element appears. See
85
- `introduction` for more information about `timeout` and its
86
- default value.
87
-
88
- `error` can be used to override the default error message.
89
-
90
- See also `Wait Until Page Contains`,
91
- `Wait Until Page Does Not Contain`
92
- `Wait Until Page Does Not Contain Element`
93
- and BuiltIn keyword `Wait Until Keyword Succeeds`.
94
- """
95
- if not error:
96
- error = "Element '%s' did not appear in <TIMEOUT>" % locator
97
- self._wait_until(timeout, error, self._is_element_present, locator)
98
-
99
- def wait_until_page_does_not_contain_element(self, locator, timeout=None, error=None):
100
- """Waits until element specified with `locator` disappears from current page.
101
-
102
- Fails if `timeout` expires before the element disappears. See
103
- `introduction` for more information about `timeout` and its
104
- default value.
105
-
106
- `error` can be used to override the default error message.
107
-
108
- See also `Wait Until Page Contains`,
109
- `Wait Until Page Does Not Contain`,
110
- `Wait Until Page Contains Element` and
111
- BuiltIn keyword `Wait Until Keyword Succeeds`.
112
- """
113
-
114
- def check_present():
115
- present = self._is_element_present(locator)
116
- if not present:
117
- return
118
- else:
119
- return error or "Element '%s' did not disappear in %s" % (locator, self._format_timeout(timeout))
120
-
121
- self._wait_until_no_error(timeout, check_present)
122
-
123
- def set_sleep_between_wait_loop(self, seconds=0.2):
124
- """Sets the sleep in seconds used by wait until loop.
125
-
126
- If you use the remote appium server, the default value is not recommended because
127
- it is another 200ms overhead to the network latency and will slow down your test
128
- execution.
129
- """
130
- old_sleep = self._sleep_between_wait
131
- self._sleep_between_wait = robot.utils.timestr_to_secs(seconds)
132
- return old_sleep
133
-
134
- def get_sleep_between_wait_loop(self):
135
- """Gets the sleep between wait loop in seconds that is used by wait until keywords.
136
- """
137
- return robot.utils.secs_to_timestr(self._sleep_between_wait)
138
-
139
- # Private
140
-
141
- def _wait_until(self, timeout, error, function, *args):
142
- error = error.replace('<TIMEOUT>', self._format_timeout(timeout))
143
-
144
- def wait_func():
145
- return None if function(*args) else error
146
-
147
- self._wait_until_no_error(timeout, wait_func)
148
-
149
- def _wait_until_no_error(self, timeout, wait_func, *args):
150
- timeout = robot.utils.timestr_to_secs(timeout) if timeout is not None else self._timeout_in_secs
151
- maxtime = time.time() + timeout
152
- while True:
153
- timeout_error = wait_func(*args)
154
- if not timeout_error:
155
- return
156
- if time.time() > maxtime:
157
- self._invoke_original("log_source")
158
- raise AssertionError(timeout_error)
159
- time.sleep(self._sleep_between_wait)
160
-
161
- def _format_timeout(self, timeout):
162
- timeout = robot.utils.timestr_to_secs(timeout) if timeout is not None else self._timeout_in_secs
163
- return robot.utils.secs_to_timestr(timeout)
1
+ import time
2
+
3
+ import robot
4
+
5
+ from .keywordgroup import KeywordGroup
6
+
7
+
8
+ class _WaitingKeywords(KeywordGroup):
9
+
10
+ def __init__(self):
11
+ self._sleep_between_wait = 0.2
12
+
13
+ def wait_until_element_is_visible(self, locator, timeout=None, error=None):
14
+ """Waits until element specified with `locator` is visible.
15
+
16
+ Fails if `timeout` expires before the element is visible. See
17
+ `introduction` for more information about `timeout` and its
18
+ default value.
19
+
20
+ `error` can be used to override the default error message.
21
+
22
+ See also `Wait Until Page Contains`, `Wait Until Page Contains
23
+ Element`, `Wait For Condition` and BuiltIn keyword `Wait Until Keyword
24
+ Succeeds`.
25
+ """
26
+
27
+ def check_visibility():
28
+ visible = self._is_visible(locator)
29
+ if visible:
30
+ return
31
+ elif visible is None:
32
+ return error or "Element locator '%s' did not match any elements after %s" % (
33
+ locator, self._format_timeout(timeout))
34
+ else:
35
+ return error or "Element '%s' was not visible in %s" % (locator, self._format_timeout(timeout))
36
+
37
+ self._wait_until_no_error(timeout, check_visibility)
38
+
39
+ def wait_until_page_contains(self, text, timeout=None, error=None):
40
+ """Waits until `text` appears on current page.
41
+
42
+ Fails if `timeout` expires before the text appears. See
43
+ `introduction` for more information about `timeout` and its
44
+ default value.
45
+
46
+ `error` can be used to override the default error message.
47
+
48
+ See also `Wait Until Page Does Not Contain`,
49
+ `Wait Until Page Contains Element`,
50
+ `Wait Until Page Does Not Contain Element` and
51
+ BuiltIn keyword `Wait Until Keyword Succeeds`.
52
+ """
53
+ if not error:
54
+ error = "Text '%s' did not appear in <TIMEOUT>" % text
55
+ self._wait_until(timeout, error, self._is_text_present, text)
56
+
57
+ def wait_until_page_does_not_contain(self, text, timeout=None, error=None):
58
+ """Waits until `text` disappears from current page.
59
+
60
+ Fails if `timeout` expires before the `text` disappears. See
61
+ `introduction` for more information about `timeout` and its
62
+ default value.
63
+
64
+ `error` can be used to override the default error message.
65
+
66
+ See also `Wait Until Page Contains`,
67
+ `Wait Until Page Contains Element`,
68
+ `Wait Until Page Does Not Contain Element` and
69
+ BuiltIn keyword `Wait Until Keyword Succeeds`.
70
+ """
71
+
72
+ def check_present():
73
+ present = self._is_text_present(text)
74
+ if not present:
75
+ return
76
+ else:
77
+ return error or "Text '%s' did not disappear in %s" % (text, self._format_timeout(timeout))
78
+
79
+ self._wait_until_no_error(timeout, check_present)
80
+
81
+ def wait_until_page_contains_element(self, locator, timeout=None, error=None):
82
+ """Waits until element specified with `locator` appears on current page.
83
+
84
+ Fails if `timeout` expires before the element appears. See
85
+ `introduction` for more information about `timeout` and its
86
+ default value.
87
+
88
+ `error` can be used to override the default error message.
89
+
90
+ See also `Wait Until Page Contains`,
91
+ `Wait Until Page Does Not Contain`
92
+ `Wait Until Page Does Not Contain Element`
93
+ and BuiltIn keyword `Wait Until Keyword Succeeds`.
94
+ """
95
+ if not error:
96
+ error = "Element '%s' did not appear in <TIMEOUT>" % locator
97
+ self._wait_until(timeout, error, self._is_element_present, locator)
98
+
99
+ def wait_until_page_does_not_contain_element(self, locator, timeout=None, error=None):
100
+ """Waits until element specified with `locator` disappears from current page.
101
+
102
+ Fails if `timeout` expires before the element disappears. See
103
+ `introduction` for more information about `timeout` and its
104
+ default value.
105
+
106
+ `error` can be used to override the default error message.
107
+
108
+ See also `Wait Until Page Contains`,
109
+ `Wait Until Page Does Not Contain`,
110
+ `Wait Until Page Contains Element` and
111
+ BuiltIn keyword `Wait Until Keyword Succeeds`.
112
+ """
113
+
114
+ def check_present():
115
+ present = self._is_element_present(locator)
116
+ if not present:
117
+ return
118
+ else:
119
+ return error or "Element '%s' did not disappear in %s" % (locator, self._format_timeout(timeout))
120
+
121
+ self._wait_until_no_error(timeout, check_present)
122
+
123
+ def set_sleep_between_wait_loop(self, seconds=0.2):
124
+ """Sets the sleep in seconds used by wait until loop.
125
+
126
+ If you use the remote appium server, the default value is not recommended because
127
+ it is another 200ms overhead to the network latency and will slow down your test
128
+ execution.
129
+ """
130
+ old_sleep = self._sleep_between_wait
131
+ self._sleep_between_wait = robot.utils.timestr_to_secs(seconds)
132
+ return old_sleep
133
+
134
+ def get_sleep_between_wait_loop(self):
135
+ """Gets the sleep between wait loop in seconds that is used by wait until keywords.
136
+ """
137
+ return robot.utils.secs_to_timestr(self._sleep_between_wait)
138
+
139
+ # Private
140
+
141
+ def _wait_until(self, timeout, error, function, *args):
142
+ error = error.replace('<TIMEOUT>', self._format_timeout(timeout))
143
+
144
+ def wait_func():
145
+ return None if function(*args) else error
146
+
147
+ self._wait_until_no_error(timeout, wait_func)
148
+
149
+ def _wait_until_no_error(self, timeout, wait_func, *args):
150
+ timeout = robot.utils.timestr_to_secs(timeout) if timeout is not None else self._timeout_in_secs
151
+ maxtime = time.time() + timeout
152
+ while True:
153
+ timeout_error = wait_func(*args)
154
+ if not timeout_error:
155
+ return
156
+ if time.time() > maxtime:
157
+ self.log_source()
158
+ raise AssertionError(timeout_error)
159
+ time.sleep(self._sleep_between_wait)
160
+
161
+ def _format_timeout(self, timeout):
162
+ timeout = robot.utils.timestr_to_secs(timeout) if timeout is not None else self._timeout_in_secs
163
+ return robot.utils.secs_to_timestr(timeout)