@@ -119,6 +119,11 @@ public function _resetConfig()
119
119
$ this ->config = ConfigSanitizerUtil::sanitizeWebDriverConfig ($ this ->config );
120
120
}
121
121
122
+ /**
123
+ * Retrieve default timeout in seconds for 'wait*' actions
124
+ *
125
+ * @return int
126
+ */
122
127
public static function getDefaultWaitTimeout ()
123
128
{
124
129
return getenv ('WAIT_TIMEOUT ' ) ?: self ::DEFAULT_WAIT_TIMEOUT ;
@@ -318,7 +323,7 @@ public function selectMultipleOptions($selectSearchTextField, $selectSearchResul
318
323
*/
319
324
public function wait ($ timeout = null )
320
325
{
321
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
326
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
322
327
323
328
if ($ timeout >= 1000 ) {
324
329
throw new TestRuntimeException (
@@ -341,7 +346,7 @@ public function wait($timeout = null)
341
346
*/
342
347
public function waitForElementChange ($ element , \Closure $ callback , $ timeout = null )
343
348
{
344
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
349
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
345
350
346
351
$ el = $ this ->matchFirstOrFail ($ this ->baseElement , $ element );
347
352
$ checker = function () use ($ el , $ callback ) {
@@ -359,7 +364,7 @@ public function waitForElementChange($element, \Closure $callback, $timeout = nu
359
364
*/
360
365
public function waitForElement ($ element , $ timeout = null )
361
366
{
362
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
367
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
363
368
364
369
$ condition = WebDriverExpectedCondition::presenceOfElementLocated ($ this ->getLocator ($ element ));
365
370
$ this ->webDriver ->wait ($ timeout )->until ($ condition );
@@ -374,7 +379,7 @@ public function waitForElement($element, $timeout = null)
374
379
*/
375
380
public function waitForElementVisible ($ element , $ timeout = null )
376
381
{
377
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
382
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
378
383
379
384
$ condition = WebDriverExpectedCondition::visibilityOfElementLocated ($ this ->getLocator ($ element ));
380
385
$ this ->webDriver ->wait ($ timeout )->until ($ condition );
@@ -389,7 +394,7 @@ public function waitForElementVisible($element, $timeout = null)
389
394
*/
390
395
public function waitForElementNotVisible ($ element , $ timeout = null )
391
396
{
392
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
397
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
393
398
394
399
$ condition = WebDriverExpectedCondition::invisibilityOfElementLocated ($ this ->getLocator ($ element ));
395
400
$ this ->webDriver ->wait ($ timeout )->until ($ condition );
@@ -405,7 +410,7 @@ public function waitForElementNotVisible($element, $timeout = null)
405
410
*/
406
411
public function waitForText ($ text , $ timeout = null , $ selector = null )
407
412
{
408
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
413
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
409
414
410
415
$ message = sprintf (
411
416
'Waited for %d secs but text %s still not found ' ,
@@ -431,7 +436,7 @@ public function waitForText($text, $timeout = null, $selector = null)
431
436
*/
432
437
public function waitForJS ($ script , $ timeout = null )
433
438
{
434
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
439
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
435
440
436
441
$ condition = function ($ wd ) use ($ script ) {
437
442
return $ wd ->executeScript ($ script );
@@ -451,7 +456,7 @@ public function waitForJS($script, $timeout = null)
451
456
*/
452
457
public function waitForAjaxLoad ($ timeout = null )
453
458
{
454
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
459
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
455
460
456
461
try {
457
462
$ this ->waitForJS ('return !!window.jQuery && window.jQuery.active == 0; ' , $ timeout );
@@ -470,7 +475,7 @@ public function waitForAjaxLoad($timeout = null)
470
475
*/
471
476
public function waitForPageLoad ($ timeout = null )
472
477
{
473
- $ timeout = $ timeout ?? $ this -> getDefaultWaitTimeout ();
478
+ $ timeout = $ timeout ?? self :: getDefaultWaitTimeout ();
474
479
475
480
$ this ->waitForJS ('return document.readyState == "complete" ' , $ timeout );
476
481
$ this ->waitForAjaxLoad ($ timeout );
0 commit comments