@@ -230,14 +230,17 @@ def wait_for_element_visible(driver, selector, by=By.CSS_SELECTOR,
230
230
if now_ms >= stop_ms :
231
231
break
232
232
time .sleep (0.1 )
233
+ plural = "s"
234
+ if timeout == 1 :
235
+ plural = ""
233
236
if not element and by != By .LINK_TEXT :
234
237
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 ))
237
240
if not element and by == By .LINK_TEXT :
238
241
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 ))
241
244
242
245
243
246
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,
274
277
if now_ms >= stop_ms :
275
278
break
276
279
time .sleep (0.1 )
280
+ plural = "s"
281
+ if timeout == 1 :
282
+ plural = ""
277
283
if not element :
278
284
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 ))
281
287
282
288
283
289
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,
304
310
time .sleep (0.1 )
305
311
except Exception :
306
312
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 ))
309
318
310
319
311
320
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,
335
344
return True
336
345
except Exception :
337
346
return True
347
+ plural = "s"
348
+ if timeout == 1 :
349
+ plural = ""
338
350
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 ))
341
353
342
354
343
355
def find_visible_elements (driver , selector , by = By .CSS_SELECTOR ):
0 commit comments