diff --git a/.env.example b/.env.example index c04afaab8..f41de89a5 100644 --- a/.env.example +++ b/.env.example @@ -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 ***# diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php index 98646d0c4..0bce48efd 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php @@ -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]); diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index 10cd77937..ab99b5159 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -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 @@ -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. * diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 07f069c10..3ad277d86 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -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