Skip to content

Commit 92e2ca1

Browse files
committed
Handle the plural and singular form of the word second(s).
1 parent 669c484 commit 92e2ca1

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

seleniumbase/fixtures/page_actions.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,17 @@ def wait_for_element_visible(driver, selector, by=By.CSS_SELECTOR,
230230
if now_ms >= stop_ms:
231231
break
232232
time.sleep(0.1)
233+
plural = "s"
234+
if timeout == 1:
235+
plural = ""
233236
if not element and by != By.LINK_TEXT:
234237
raise ElementNotVisibleException(
235-
"Element {%s} was not visible after %s seconds!" % (
236-
selector, timeout))
238+
"Element {%s} was not visible after %s second%s!" % (
239+
selector, timeout, plural))
237240
if not element and by == By.LINK_TEXT:
238241
raise ElementNotVisibleException(
239-
"Link text {%s} was not visible after %s seconds!" % (
240-
selector, timeout))
242+
"Link text {%s} was not visible after %s second%s!" % (
243+
selector, timeout, plural))
241244

242245

243246
def wait_for_text_visible(driver, text, selector, by=By.CSS_SELECTOR,
@@ -274,10 +277,13 @@ def wait_for_text_visible(driver, text, selector, by=By.CSS_SELECTOR,
274277
if now_ms >= stop_ms:
275278
break
276279
time.sleep(0.1)
280+
plural = "s"
281+
if timeout == 1:
282+
plural = ""
277283
if not element:
278284
raise ElementNotVisibleException(
279-
"Expected text {%s} for {%s} was not visible after %s seconds!" %
280-
(text, selector, timeout))
285+
"Expected text {%s} for {%s} was not visible after %s second%s!" %
286+
(text, selector, timeout, plural))
281287

282288

283289
def wait_for_element_absent(driver, selector, by=By.CSS_SELECTOR,
@@ -304,8 +310,11 @@ def wait_for_element_absent(driver, selector, by=By.CSS_SELECTOR,
304310
time.sleep(0.1)
305311
except Exception:
306312
return True
307-
raise Exception("Element {%s} was still present after %s seconds!" %
308-
(selector, timeout))
313+
plural = "s"
314+
if timeout == 1:
315+
plural = ""
316+
raise Exception("Element {%s} was still present after %s second%s!" %
317+
(selector, timeout, plural))
309318

310319

311320
def wait_for_element_not_visible(driver, selector, by=By.CSS_SELECTOR,
@@ -335,9 +344,12 @@ def wait_for_element_not_visible(driver, selector, by=By.CSS_SELECTOR,
335344
return True
336345
except Exception:
337346
return True
347+
plural = "s"
348+
if timeout == 1:
349+
plural = ""
338350
raise Exception(
339-
"Element {%s} was still visible after %s seconds!" % (
340-
selector, timeout))
351+
"Element {%s} was still visible after %s second%s!" % (
352+
selector, timeout, plural))
341353

342354

343355
def find_visible_elements(driver, selector, by=By.CSS_SELECTOR):

0 commit comments

Comments
 (0)