Skip to content

Commit b3e4f2f

Browse files
committed
Use "seconds" in plural form only when timeout is not "1"
1 parent dffbc7d commit b3e4f2f

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

seleniumbase/fixtures/page_actions.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ def hover_and_click(driver, hover_selector, click_selector,
142142
if now_ms >= stop_ms:
143143
break
144144
time.sleep(0.1)
145+
plural = "s"
146+
if timeout == 1:
147+
plural = ""
145148
raise NoSuchElementException(
146-
"Element {%s} was not present after %s seconds!" %
147-
(click_selector, timeout))
149+
"Element {%s} was not present after %s second%s!" % (
150+
click_selector, timeout, plural))
148151

149152

150153
def hover_element_and_click(driver, element, click_selector,
@@ -167,9 +170,12 @@ def hover_element_and_click(driver, element, click_selector,
167170
if now_ms >= stop_ms:
168171
break
169172
time.sleep(0.1)
173+
plural = "s"
174+
if timeout == 1:
175+
plural = ""
170176
raise NoSuchElementException(
171-
"Element {%s} was not present after %s seconds!" %
172-
(click_selector, timeout))
177+
"Element {%s} was not present after %s second%s!" % (
178+
click_selector, timeout, plural))
173179

174180

175181
def hover_element_and_double_click(driver, element, click_selector,
@@ -192,9 +198,12 @@ def hover_element_and_double_click(driver, element, click_selector,
192198
if now_ms >= stop_ms:
193199
break
194200
time.sleep(0.1)
201+
plural = "s"
202+
if timeout == 1:
203+
plural = ""
195204
raise NoSuchElementException(
196-
"Element {%s} was not present after %s seconds!" %
197-
(click_selector, timeout))
205+
"Element {%s} was not present after %s second%s!" % (
206+
click_selector, timeout, plural))
198207

199208

200209
def wait_for_element_present(driver, selector, by=By.CSS_SELECTOR,
@@ -225,10 +234,13 @@ def wait_for_element_present(driver, selector, by=By.CSS_SELECTOR,
225234
if now_ms >= stop_ms:
226235
break
227236
time.sleep(0.1)
237+
plural = "s"
238+
if timeout == 1:
239+
plural = ""
228240
if not element:
229241
raise NoSuchElementException(
230-
"Element {%s} was not present after %s seconds!" % (
231-
selector, timeout))
242+
"Element {%s} was not present after %s second%s!" % (
243+
selector, timeout, plural))
232244

233245

234246
def wait_for_element_visible(driver, selector, by=By.CSS_SELECTOR,

0 commit comments

Comments
 (0)