Skip to content

Commit 6381a4b

Browse files
committed
#54: Set a global value for timeouts that's used across all wait related actions
- Added PHPDoc block to getDefaultWaitTimeout method - Changed usage of getDefaultWaitTimeout static method in other methods
1 parent d26cfe2 commit 6381a4b

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ public function _resetConfig()
119119
$this->config = ConfigSanitizerUtil::sanitizeWebDriverConfig($this->config);
120120
}
121121

122+
/**
123+
* Retrieve default timeout in seconds for 'wait*' actions
124+
*
125+
* @return int
126+
*/
122127
public static function getDefaultWaitTimeout()
123128
{
124129
return getenv('WAIT_TIMEOUT') ?: self::DEFAULT_WAIT_TIMEOUT;
@@ -318,7 +323,7 @@ public function selectMultipleOptions($selectSearchTextField, $selectSearchResul
318323
*/
319324
public function wait($timeout = null)
320325
{
321-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
326+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
322327

323328
if ($timeout >= 1000) {
324329
throw new TestRuntimeException(
@@ -341,7 +346,7 @@ public function wait($timeout = null)
341346
*/
342347
public function waitForElementChange($element, \Closure $callback, $timeout = null)
343348
{
344-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
349+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
345350

346351
$el = $this->matchFirstOrFail($this->baseElement, $element);
347352
$checker = function () use ($el, $callback) {
@@ -359,7 +364,7 @@ public function waitForElementChange($element, \Closure $callback, $timeout = nu
359364
*/
360365
public function waitForElement($element, $timeout = null)
361366
{
362-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
367+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
363368

364369
$condition = WebDriverExpectedCondition::presenceOfElementLocated($this->getLocator($element));
365370
$this->webDriver->wait($timeout)->until($condition);
@@ -374,7 +379,7 @@ public function waitForElement($element, $timeout = null)
374379
*/
375380
public function waitForElementVisible($element, $timeout = null)
376381
{
377-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
382+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
378383

379384
$condition = WebDriverExpectedCondition::visibilityOfElementLocated($this->getLocator($element));
380385
$this->webDriver->wait($timeout)->until($condition);
@@ -389,7 +394,7 @@ public function waitForElementVisible($element, $timeout = null)
389394
*/
390395
public function waitForElementNotVisible($element, $timeout = null)
391396
{
392-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
397+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
393398

394399
$condition = WebDriverExpectedCondition::invisibilityOfElementLocated($this->getLocator($element));
395400
$this->webDriver->wait($timeout)->until($condition);
@@ -405,7 +410,7 @@ public function waitForElementNotVisible($element, $timeout = null)
405410
*/
406411
public function waitForText($text, $timeout = null, $selector = null)
407412
{
408-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
413+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
409414

410415
$message = sprintf(
411416
'Waited for %d secs but text %s still not found',
@@ -431,7 +436,7 @@ public function waitForText($text, $timeout = null, $selector = null)
431436
*/
432437
public function waitForJS($script, $timeout = null)
433438
{
434-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
439+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
435440

436441
$condition = function ($wd) use ($script) {
437442
return $wd->executeScript($script);
@@ -451,7 +456,7 @@ public function waitForJS($script, $timeout = null)
451456
*/
452457
public function waitForAjaxLoad($timeout = null)
453458
{
454-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
459+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
455460

456461
try {
457462
$this->waitForJS('return !!window.jQuery && window.jQuery.active == 0;', $timeout);
@@ -470,7 +475,7 @@ public function waitForAjaxLoad($timeout = null)
470475
*/
471476
public function waitForPageLoad($timeout = null)
472477
{
473-
$timeout = $timeout ?? $this->getDefaultWaitTimeout();
478+
$timeout = $timeout ?? self::getDefaultWaitTimeout();
474479

475480
$this->waitForJS('return document.readyState == "complete"', $timeout);
476481
$this->waitForAjaxLoad($timeout);

0 commit comments

Comments
 (0)