From 4f1e99f9111517981cfc295a9891ab332ad12b54 Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Wed, 9 Dec 2020 00:06:35 +0100 Subject: [PATCH 01/14] first changes --- src/SeleniumHelper.php | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/SeleniumHelper.php b/src/SeleniumHelper.php index 9dda351..8111f59 100644 --- a/src/SeleniumHelper.php +++ b/src/SeleniumHelper.php @@ -5,40 +5,25 @@ use Facebook\WebDriver\WebDriver; use Facebook\WebDriver\WebDriverBy; use Facebook\WebDriver\WebDriverExpectedCondition; -use Pagantis\SeleniumFormUtils\Step\AbstractStep; -use Pagantis\SeleniumFormUtils\Step\Rejected; +use Clearpay\SeleniumFormUtils\Step\AbstractStep; +use Clearpay\SeleniumFormUtils\Step\Rejected; /** * Class SeleniumHelper - * @package Pagantis\SeleniumFormUtils + * @package Clearpay\SeleniumFormUtils */ class SeleniumHelper { /** * Form base domain, initial status to verify before start testing */ - const FORM_BASE_URL = 'https://form.sbx.pagantis.com'; + const FORM_BASE_URL = 'clearpay.com'; /** * @var WebDriver */ protected static $webDriver; - /** - * @var string $mobilePhone needed to identify returning users - */ - public static $mobilePhone = null; - - /** - * @var array $arraySteps - */ - public static $arraySteps = array ( - '25' => 'ConfirmData', - '50' => 'Missing', - '75' => 'Application', - '100' => 'Rejected', - ); - /** * @param WebDriver $webDriver * @param bool $rejected @@ -102,22 +87,20 @@ protected static function validateFormUrl() } /** - * Get the step of the breadcrumb progress bar + * Get the step of the url * * @return string */ protected static function getFormStep() { + $formStep = explode(DIRECTORY_SEPARATOR, self::$webDriver>getCurrentURL()); - return self::$arraySteps[ - self::$webDriver->findElement(WebDriverBy::cssSelector(".ProgressBar progress")) - ->getAttribute("value") - ]; + return array_pop($formStep); } /** * Turn the form step into a selenium handler class: - * from: '/result/status-approved' to '\Result\StatusApproved' + * from: 'status-approved' to 'StatusApproved' * * @param $formStep * @@ -126,7 +109,7 @@ protected static function getFormStep() protected static function getStepClass($formStep) { $formSteps = explode(DIRECTORY_SEPARATOR, $formStep); - $stepClass = 'Pagantis\SeleniumFormUtils\Step'; + $stepClass = 'Clearpay\SeleniumFormUtils\Step'; foreach ($formSteps as $formStep) { if ($formStep !== '') { $stepClass .= "\\".str_replace('-', '', ucwords($formStep, '-')); @@ -142,8 +125,8 @@ protected static function getStepClass($formStep) */ public static function waitToLoad() { - $element = WebDriverBy::cssSelector(".MainContainer"); - $condition = WebDriverExpectedCondition::presenceOfElementLocated($element); - self::$webDriver->wait(90, 1500)->until($condition); + $condition = WebDriverExpectedCondition::titleContains(self::PAGANTIS_TITLE); + self::$webDriver->wait(90, 1500) + ->until($condition, self::$webDriver->getCurrentURL()); } } From c60a3dab2b3375e7b2075adf16ec7018ae730a0d Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:06:08 +0100 Subject: [PATCH 02/14] Update SeleniumHelper.php --- src/SeleniumHelper.php | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/SeleniumHelper.php b/src/SeleniumHelper.php index 8111f59..8d1edeb 100644 --- a/src/SeleniumHelper.php +++ b/src/SeleniumHelper.php @@ -5,8 +5,9 @@ use Facebook\WebDriver\WebDriver; use Facebook\WebDriver\WebDriverBy; use Facebook\WebDriver\WebDriverExpectedCondition; -use Clearpay\SeleniumFormUtils\Step\AbstractStep; -use Clearpay\SeleniumFormUtils\Step\Rejected; +use Pagantis\SeleniumFormUtils\Step\AbstractStep; +use Pagantis\SeleniumFormUtils\Step\Rejected; +use Pagantis\SeleniumFormUtils\Step\AccountVerification; /** * Class SeleniumHelper @@ -19,6 +20,11 @@ class SeleniumHelper */ const FORM_BASE_URL = 'clearpay.com'; + /** + * + */ + const CLEARPAY_TITLE = 'Clearpay'; + /** * @var WebDriver */ @@ -40,7 +46,11 @@ public static function finishForm(WebDriver $webDriver, $rejected = false) do { self::waitToLoad(); $formStep = self::getFormStep(); - $formStepClass = "\\".self::getStepClass($formStep); + if(self::stepIsExcluded($formStep)){ + $continue = true; + continue; + } + $formStepClass = self::getStepClass($formStep); /** @var AbstractStep $stepClass */ $stepClass = new $formStepClass(self::$webDriver); $continue = $stepClass->run($rejected); @@ -54,6 +64,16 @@ public static function finishForm(WebDriver $webDriver, $rejected = false) return $formStep; } + /** + * @param $currentStep + * + * @return bool + */ + public static function stepIsExcluded($currentStep) + { + return (substr($currentStep,0,4) === '004.'); + } + /** * @param WebDriver $webDriver * @@ -93,7 +113,7 @@ protected static function validateFormUrl() */ protected static function getFormStep() { - $formStep = explode(DIRECTORY_SEPARATOR, self::$webDriver>getCurrentURL()); + $formStep = explode(DIRECTORY_SEPARATOR, self::$webDriver->getCurrentURL()); return array_pop($formStep); } @@ -109,7 +129,7 @@ protected static function getFormStep() protected static function getStepClass($formStep) { $formSteps = explode(DIRECTORY_SEPARATOR, $formStep); - $stepClass = 'Clearpay\SeleniumFormUtils\Step'; + $stepClass = 'Pagantis\SeleniumFormUtils\Step'; foreach ($formSteps as $formStep) { if ($formStep !== '') { $stepClass .= "\\".str_replace('-', '', ucwords($formStep, '-')); @@ -125,7 +145,7 @@ protected static function getStepClass($formStep) */ public static function waitToLoad() { - $condition = WebDriverExpectedCondition::titleContains(self::PAGANTIS_TITLE); + $condition = WebDriverExpectedCondition::titleContains(self::CLEARPAY_TITLE); self::$webDriver->wait(90, 1500) ->until($condition, self::$webDriver->getCurrentURL()); } From 88497109626dcb9383f07f76b74af52f27285053 Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:08:22 +0100 Subject: [PATCH 03/14] New steps --- src/Step/AccountVerification.php | 48 +++++++++++++++++++++++++ src/Step/OrderConfirmation.php | 60 ++++++++++++++++++++++++++++++++ src/Step/Password.php | 53 ++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 src/Step/AccountVerification.php create mode 100644 src/Step/OrderConfirmation.php create mode 100644 src/Step/Password.php diff --git a/src/Step/AccountVerification.php b/src/Step/AccountVerification.php new file mode 100644 index 0000000..81d446b --- /dev/null +++ b/src/Step/AccountVerification.php @@ -0,0 +1,48 @@ +webDriver->wait()->until($condition); + + //Fill email + $fillEmail = $this->webDriver->findElement($simulatorElementSearch)->clear()->sendKeys(self::EMAIL); + + //Click on confirm + $formContinue = $this->webDriver->findElement(WebDriverBy::id('continueBtn')); + $formContinue->click(); + + sleep(5); + + return true; + } +} diff --git a/src/Step/OrderConfirmation.php b/src/Step/OrderConfirmation.php new file mode 100644 index 0000000..63c6890 --- /dev/null +++ b/src/Step/OrderConfirmation.php @@ -0,0 +1,60 @@ +webDriver->wait()->until($condition); + } catch (\Exception $e) { + $errorElementSearch = WebDriverBy::className('technical-error-container'); + $condition = WebDriverExpectedCondition::presenceOfElementLocated($errorElementSearch); + $this->webDriver->wait()->until($condition); + $this->assertTrue((bool) $condition, "ERROR ON ".self::STEP); + } + + //Click on popup + $buttonElementSearch = WebDriverBy::name('dialogButton'); + $condition = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch); + $this->webDriver->wait()->until($condition); + $formContinue = $this->webDriver->findElement($buttonElementSearch)->click(); + sleep(3); + + //Click on confirm + $buttonElementSearch = WebDriverBy::className('button-contained-primary'); + $condition = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch); + $this->webDriver->wait()->until($condition); + $formContinue = $this->webDriver->findElement($buttonElementSearch)->click(); + + sleep(5); + + return false; + } +} diff --git a/src/Step/Password.php b/src/Step/Password.php new file mode 100644 index 0000000..faf9b3a --- /dev/null +++ b/src/Step/Password.php @@ -0,0 +1,53 @@ +webDriver->wait()->until($condition); + + //Fill email + $fillEmail = $this->webDriver->findElement($simulatorElementSearch)->clear()->sendKeys(self::PASSWORD); + + //Click on confirm + $formContinue = $this->webDriver->findElement(WebDriverBy::id('continueBtn')); + $formContinue->click(); + + sleep(5); + + return true; + } +} From 254a96536e5689e6b0b976773105df14be9e724b Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:10:07 +0100 Subject: [PATCH 04/14] Delete ConfirmData.php --- src/Step/ConfirmData.php | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/Step/ConfirmData.php diff --git a/src/Step/ConfirmData.php b/src/Step/ConfirmData.php deleted file mode 100644 index 9a2a04f..0000000 --- a/src/Step/ConfirmData.php +++ /dev/null @@ -1,37 +0,0 @@ -validateStep(self::STEP); - //Click on confirm: - $confirmCheckbox = $this->webDriver->findElement(WebDriverBy::className('checkmark')); - $confirmCheckbox->click(); - $formContinue = $this->webDriver->findElement(WebDriverBy::name('continue_button')); - $formContinue->click(); - - return true; - } -} From 9e01682b0072f7dce1ac16c4af186793f5ccd719 Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:10:17 +0100 Subject: [PATCH 05/14] Delete Application.php --- src/Step/Application.php | 85 ---------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 src/Step/Application.php diff --git a/src/Step/Application.php b/src/Step/Application.php deleted file mode 100644 index 171d63e..0000000 --- a/src/Step/Application.php +++ /dev/null @@ -1,85 +0,0 @@ -validateStep(self::STEP); - - try { - $iframe = $this->webDriver->findElement(WebDriverBy::tagName('iframe')); - $iFrameOneId = $iframe->getAttribute('name'); - $spreedlyCode = explode('-', $iFrameOneId); - $iFrameTwoId = 'spreedly-cvv-frame-'.end($spreedlyCode); - - //CVV IFRAME - $this->moveToParent(); - $this->moveToIFrame($iFrameTwoId); - $cvv = $this->webDriver->findElement(WebDriverBy::id('cvv')); - $cvv->clear()->sendKeys(self::CARD_CVC); - $this->moveToParent(); - - //CARD IFRAME - $this->moveToIFrame($iFrameOneId); - $messageElementSearch = WebDriverBy::id('card_number'); - sleep(2); - - $cardNumberIframe = $this->webDriver->findElement($messageElementSearch); - if ($cardNumberIframe!='') { - $cardNumberStyle = $cardNumberIframe->getAttribute('style'); - } - - if (strpos($cardNumberStyle, "display: none")===false) { - $this->waitTobeVisible(WebDriverBy::id('card_number')); - $creditCardNumber = $this->webDriver->findElement(WebDriverBy::name('card_number')); - $card = $rejected ? self::REJECTED_CARD_NUMBER : self::VALID_CARD_NUMBER; - $creditCardNumber->clear()->sendKeys($card); - $this->moveToParent(); - sleep(1); - $fullName = $this->webDriver->findElement(WebDriverBy::name('fullName')); - $fullName->clear()->sendKeys(self::CARD_HOLDER); - $expirationDate = $this->webDriver->findElement(WebDriverBy::name('expirationDate')); - $expirationDate->clear()->sendKeys('1221'); - } - - $this->moveToParent(); - sleep(1); - } catch (\Exception $exception) { - unset($exception); - return false; - } - - $formContinue = $this->webDriver->findElement(WebDriverBy::name('continue_button')); - $formContinue->click(); - return true; - } -} From 3058ee6ebd551ce8d271e527e7f2fe321bafb9e3 Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:10:29 +0100 Subject: [PATCH 06/14] Delete Missing.php --- src/Step/Missing.php | 144 ------------------------------------------- 1 file changed, 144 deletions(-) delete mode 100644 src/Step/Missing.php diff --git a/src/Step/Missing.php b/src/Step/Missing.php deleted file mode 100644 index 8f60391..0000000 --- a/src/Step/Missing.php +++ /dev/null @@ -1,144 +0,0 @@ -validateStep(self::STEP); - - /* - * Field DNI: - */ - try { - $name = $this->webDriver->findElement(WebDriverBy::name('dni')); - $name->clear()->sendKeys($this->getDNI()); - } catch (\Exception $exception) { - unset($exception); - } - /* - * Field BirthDate: - */ - try { - $dob = $this->webDriver->findElement(WebDriverBy::name('dob')); - $dob->clear()->sendKeys('12/12/1979'); - } catch (\Exception $exception) { - unset($exception); - } - /* - * Field address: - */ - try { - $name = $this->webDriver->findElement(WebDriverBy::name('address')); - $name->clear()->sendKeys($this->faker->address. ' ' . $this->faker->city); - } catch (\Exception $exception) { - unset($exception); - } - /* - * Field city: - */ - try { - $name = $this->webDriver->findElement(WebDriverBy::name('city')); - $name->clear()->sendKeys($this->faker->city); - } catch (\Exception $exception) { - unset($exception); - } - /* - * Field zipcode: - */ - try { - $name = $this->webDriver->findElement(WebDriverBy::name('zipcode')); - $name->clear()->sendKeys('28045'); - } catch (\Exception $exception) { - unset($exception); - } - /* - * Field Phone: - */ - try { - $name = $this->webDriver->findElement(WebDriverBy::name('mobilePhone')); - $name->clear()->sendKeys('6' . $this->faker->randomNumber(8)); - } catch (\Exception $exception) { - unset($exception); - } - /* - * Field Full Name: - */ - try { - $name = $this->webDriver->findElement(WebDriverBy::name('name')); - $name->clear()->sendKeys( - $this->faker->firstName . ' ' . $this->faker->lastName - ); - } catch (\Exception $exception) { - unset($exception); - } - - /* - * Field password: - */ - try { - $name = $this->webDriver->findElement(WebDriverBy::name('password')); - if (null === SeleniumHelper::$mobilePhone) { - throw new \Exception('Please provide mobile phone for returning customer'); - } else { - $name->clear()->sendKeys(substr(SeleniumHelper::$mobilePhone, -4)); - } - } catch (\Exception $exception) { - unset($exception); - } - - /* - * Click form continue - */ - $element = WebDriverBy::name("continue_button"); - try { - $condition = WebDriverExpectedCondition::elementToBeClickable($element); - $this->webDriver->wait(90, 1500)->until($condition); - $formContinue = $this->webDriver->findElement($element); - $formContinue->click(); - } catch (\Exception $exception) { - sleep(10); - unset($exception); - } - - return true; - } -} From d0ca81f253a2258af30bd9a8c5688980e1dc59cf Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:10:40 +0100 Subject: [PATCH 07/14] Delete Rejected.php --- src/Step/Rejected.php | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 src/Step/Rejected.php diff --git a/src/Step/Rejected.php b/src/Step/Rejected.php deleted file mode 100644 index 3524cf3..0000000 --- a/src/Step/Rejected.php +++ /dev/null @@ -1,34 +0,0 @@ -validateStep(self::STEP); - $formContinue = $this->webDriver->findElement(WebDriverBy::name('back_to_store_button')); - $formContinue->click(); - - return false; - } -} From 9c884303b6934d8901c41418a212b52ce01fec3c Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Wed, 9 Dec 2020 14:11:53 +0100 Subject: [PATCH 08/14] Update AbstractStep.php --- src/Step/AbstractStep.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/Step/AbstractStep.php b/src/Step/AbstractStep.php index c085bf1..0da0224 100644 --- a/src/Step/AbstractStep.php +++ b/src/Step/AbstractStep.php @@ -68,23 +68,6 @@ public function waitTobeVisible(WebDriverBy $webDriverBy) return $this->webDriver->findElement($webDriverBy); } - /** - * @param string $step - * - * @throws \Exception - */ - public function validateStep($step) - { - $currentStep = SeleniumHelper::$arraySteps[ - $this->webDriver->findElement(WebDriverBy::cssSelector(".ProgressBar progress")) - ->getAttribute("value") - ]; - - if ($step !== $currentStep) { - throw new \Exception('Wrong step: ' . $arraySteps[$step]); - } - } - /** * @param $iFrameLocator * From 1fa1eee3d5d4b8b81c711f1f946771b55fc19fb5 Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Fri, 11 Dec 2020 00:24:33 +0100 Subject: [PATCH 09/14] Update SeleniumHelper.php --- src/SeleniumHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SeleniumHelper.php b/src/SeleniumHelper.php index 8d1edeb..6ea1403 100644 --- a/src/SeleniumHelper.php +++ b/src/SeleniumHelper.php @@ -55,7 +55,7 @@ public static function finishForm(WebDriver $webDriver, $rejected = false) $stepClass = new $formStepClass(self::$webDriver); $continue = $stepClass->run($rejected); --$maxSteps; - } while ($continue && $formStep !== Rejected::STEP && $maxSteps > 0); + } while ($continue && $maxSteps > 0); if ($maxSteps <= 0) { throw new \Exception('Error while finishing form, step: ' . $formStep); From bfd3aba959937c5c28693128933d1b3cf92a9e8f Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Fri, 11 Dec 2020 00:51:06 +0100 Subject: [PATCH 10/14] Update SeleniumHelper.php --- src/SeleniumHelper.php | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/SeleniumHelper.php b/src/SeleniumHelper.php index 6ea1403..c9dbde1 100644 --- a/src/SeleniumHelper.php +++ b/src/SeleniumHelper.php @@ -39,23 +39,28 @@ class SeleniumHelper */ public static function finishForm(WebDriver $webDriver, $rejected = false) { - self::$webDriver = $webDriver; - self::waitToLoad(); - self::validateFormUrl(); - $maxSteps = 20; - do { + try { + self::$webDriver = $webDriver; self::waitToLoad(); - $formStep = self::getFormStep(); - if(self::stepIsExcluded($formStep)){ - $continue = true; - continue; - } - $formStepClass = self::getStepClass($formStep); - /** @var AbstractStep $stepClass */ - $stepClass = new $formStepClass(self::$webDriver); - $continue = $stepClass->run($rejected); - --$maxSteps; - } while ($continue && $maxSteps > 0); + self::validateFormUrl(); + $maxSteps = 20; + do { + self::waitToLoad(); + $formStep = self::getFormStep(); + if(self::stepIsExcluded($formStep)){ + $continue = true; + continue; + } + $formStepClass = self::getStepClass($formStep); + /** @var AbstractStep $stepClass */ + $stepClass = new $formStepClass(self::$webDriver); + $continue = $stepClass->run($rejected); + --$maxSteps; + } while ($continue && $maxSteps>0); + } catch (\Exception $exception) { + echo $exception->getMessage(); + echo self::$webDriver->getCurrentURL(); + } if ($maxSteps <= 0) { throw new \Exception('Error while finishing form, step: ' . $formStep); From 049d072f9dabb958fa8018c3fcdcdedb0d0e0efd Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Fri, 11 Dec 2020 09:51:54 +0100 Subject: [PATCH 11/14] Adding sleep before steps --- src/Step/OrderConfirmation.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Step/OrderConfirmation.php b/src/Step/OrderConfirmation.php index 63c6890..23886b3 100644 --- a/src/Step/OrderConfirmation.php +++ b/src/Step/OrderConfirmation.php @@ -38,9 +38,11 @@ public function run($rejected = false) $condition = WebDriverExpectedCondition::presenceOfElementLocated($errorElementSearch); $this->webDriver->wait()->until($condition); $this->assertTrue((bool) $condition, "ERROR ON ".self::STEP); + return false; } //Click on popup + sleep(3); $buttonElementSearch = WebDriverBy::name('dialogButton'); $condition = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch); $this->webDriver->wait()->until($condition); @@ -52,8 +54,7 @@ public function run($rejected = false) $condition = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch); $this->webDriver->wait()->until($condition); $formContinue = $this->webDriver->findElement($buttonElementSearch)->click(); - - sleep(5); + sleep(3); return false; } From e8f9fc686c229ce1a8198fca2e7d7819bcb36e8b Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Fri, 11 Dec 2020 09:54:10 +0100 Subject: [PATCH 12/14] Update OrderConfirmation.php --- src/Step/OrderConfirmation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Step/OrderConfirmation.php b/src/Step/OrderConfirmation.php index 23886b3..36d783c 100644 --- a/src/Step/OrderConfirmation.php +++ b/src/Step/OrderConfirmation.php @@ -30,6 +30,7 @@ public function run($rejected = false) { try{ //Wait after redirection + sleep(3); $simulatorElementSearch = WebDriverBy::id('OrderConfirmation-container'); $condition = WebDriverExpectedCondition::presenceOfElementLocated($simulatorElementSearch); $this->webDriver->wait()->until($condition); From 1abdc6c56448902addba03816e1e9304a9f7d3fd Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Fri, 11 Dec 2020 10:21:11 +0100 Subject: [PATCH 13/14] Adding logs --- src/SeleniumHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SeleniumHelper.php b/src/SeleniumHelper.php index c9dbde1..d8181f3 100644 --- a/src/SeleniumHelper.php +++ b/src/SeleniumHelper.php @@ -60,6 +60,7 @@ public static function finishForm(WebDriver $webDriver, $rejected = false) } catch (\Exception $exception) { echo $exception->getMessage(); echo self::$webDriver->getCurrentURL(); + echo self::$webDriver->getPageSource(); } if ($maxSteps <= 0) { From 1ce31df80630c6e6cf9b817638308b96a1fcf7c0 Mon Sep 17 00:00:00 2001 From: pgarces <37547687+pgarcess@users.noreply.github.com> Date: Fri, 11 Dec 2020 10:57:54 +0100 Subject: [PATCH 14/14] RiskContainer on form --- src/Step/OrderConfirmation.php | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Step/OrderConfirmation.php b/src/Step/OrderConfirmation.php index 36d783c..2248525 100644 --- a/src/Step/OrderConfirmation.php +++ b/src/Step/OrderConfirmation.php @@ -42,20 +42,28 @@ public function run($rejected = false) return false; } - //Click on popup - sleep(3); - $buttonElementSearch = WebDriverBy::name('dialogButton'); - $condition = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch); - $this->webDriver->wait()->until($condition); - $formContinue = $this->webDriver->findElement($buttonElementSearch)->click(); - sleep(3); + try{ + //Click on popup + sleep(3); + $buttonElementSearch = WebDriverBy::name('dialogButton'); + $condition = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch); + $this->webDriver->wait()->until($condition); + $formContinue = $this->webDriver->findElement($buttonElementSearch)->click(); + sleep(3); - //Click on confirm - $buttonElementSearch = WebDriverBy::className('button-contained-primary'); - $condition = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch); - $this->webDriver->wait()->until($condition); - $formContinue = $this->webDriver->findElement($buttonElementSearch)->click(); - sleep(3); + //Click on confirm + $buttonElementSearch = WebDriverBy::className('button-contained-primary'); + $condition = WebDriverExpectedCondition::presenceOfElementLocated($buttonElementSearch); + $this->webDriver->wait()->until($condition); + $formContinue = $this->webDriver->findElement($buttonElementSearch)->click(); + sleep(3); + } catch (\Exception $e) { + $errorElementSearch = WebDriverBy::className('riskPageContainer'); + $condition = WebDriverExpectedCondition::presenceOfElementLocated($errorElementSearch); + $this->webDriver->wait()->until($condition); + $this->assertTrue((bool) $condition, "ERROR ON ".self::STEP); + return false; + } return false; }