Skip to content

magento/magento2-functional-testing-framework#54: Set a global value for timeouts that's used across all wait related actions #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 29, 2018
Merged
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ MODULE_WHITELIST=Magento_Framework,Magento_ConfigurableProductWishlist,Magento_C

#*** Bool property which allows the user to toggle debug output during test execution
#MFTF_DEBUG=

#*** Default timeout for wait actions
WAIT_TIMEOUT=10
#*** End of .env ***#
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ public function testTooManyArgumentException()
$actionObject->resolveReferences();
}

/**
* Method should return either .env file value or constant value
*/
public function testGetDefaultWaitTimeout()
{
$this->assertEquals(ActionObject::getDefaultWaitTimeout(), ActionObject::DEFAULT_WAIT_TIMEOUT);

$envFile = new \Dotenv\Dotenv(__DIR__ . '/../../../../../../../', '.env.example');
$envFile->load();

$this->assertEquals(ActionObject::getDefaultWaitTimeout(), getenv('WAIT_TIMEOUT'));
}

private function mockSectionHandlerWithElement($elementObject)
{
$sectionObject = new SectionObject('SectionObject', ['elementObject' => $elementObject]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ActionObject
const ACTION_ATTRIBUTE_SELECTOR = 'selector';
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PARAMETER = '/\(.+\)/';
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\(.+\)}})/';
const DEFAULT_WAIT_TIMEOUT = 10;

/**
* The unique identifier for the action
Expand Down Expand Up @@ -127,6 +128,16 @@ public function __construct(
}
}

/**
* Retrieve default timeout in seconds for 'wait*' actions
*
* @return int
*/
public static function getDefaultWaitTimeout()
{
return getenv('WAIT_TIMEOUT') ?: self::DEFAULT_WAIT_TIMEOUT;
}

/**
* This function returns the string property stepKey.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
if (isset($customActionAttributes['timeout'])) {
$time = $customActionAttributes['timeout'];
}
$time = $time ?? ActionObject::getDefaultWaitTimeout();

if (isset($customActionAttributes['parameterArray']) && $actionObject->getType() != 'pressKey') {
// validate the param array is in the correct format
Expand Down