From 60514eaf250ac4f565ce9f0843f340a84138686d Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Mon, 21 May 2018 12:58:20 +0530 Subject: [PATCH] Allowing Joomla Browser to Save and Load Sessions for Administrator --- src/JoomlaBrowser.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 8d38954..50a8d88 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -103,25 +103,28 @@ protected function instantiateLocator() /** * Function to Do Admin Login In Joomla! * - * @param string|null $user Optional Username. If not passed the one in acceptance.suite.yml will be used - * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used + * @param string|null $user Optional Username. If not passed the one in acceptance.suite.yml will be used + * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used + * @param bool $useSnapshot Whether or not you want to reuse the session from previous login. Enabled by default. * * @return void * * @since 3.0.0 */ - public function doAdministratorLogin($user = null, $password = null) + public function doAdministratorLogin($user = null, $password = null, $useSnapshot = true) { if (is_null($user)) { $user = $this->config['username']; } - if (is_null($password)) { $password = $this->config['password']; } - + if ($useSnapshot && $this->loadSessionSnapshot($user)) + { + return; + } $this->debug('I open Joomla Administrator Login Page'); $this->amOnPage($this->locator->adminLoginPageUrl); $this->waitForElement($this->locator->adminLoginUserName, TIMEOUT); @@ -129,12 +132,14 @@ public function doAdministratorLogin($user = null, $password = null) $this->fillField($this->locator->adminLoginUserName, $user); $this->debug('Fill Password Text Field'); $this->fillField($this->locator->adminLoginPassword, $password); - // @todo: update login button in joomla login screen to make this xPath more friendly $this->debug('I click Login button'); $this->click($this->locator->adminLoginButton); $this->debug('I wait to see Administrator Control Panel'); $this->waitForText($this->locator->adminControlPanelText, 4, $this->locator->controlPanelLocator); + if ($useSnapshot) { + $this->saveSessionSnapshot($user); + } } /**