@@ -103,38 +103,43 @@ protected function instantiateLocator()
103103 /**
104104 * Function to Do Admin Login In Joomla!
105105 *
106- * @param string|null $user Optional Username. If not passed the one in acceptance.suite.yml will be used
107- * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used
106+ * @param string|null $user Optional Username. If not passed the one in acceptance.suite.yml will be used
107+ * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used
108+ * @param bool $useSnapshot Whether or not you want to reuse the session from previous login. Enabled by default.
108109 *
109110 * @return void
110111 *
111112 * @since 3.0.0
112113 */
113- public function doAdministratorLogin ($ user = null , $ password = null )
114+ public function doAdministratorLogin ($ user = null , $ password = null , $ useSnapshot = true )
114115 {
115116 if (is_null ($ user ))
116117 {
117118 $ user = $ this ->config ['username ' ];
118119 }
119-
120120 if (is_null ($ password ))
121121 {
122122 $ password = $ this ->config ['password ' ];
123123 }
124-
124+ if ($ useSnapshot && $ this ->loadSessionSnapshot ($ user ))
125+ {
126+ return ;
127+ }
125128 $ this ->debug ('I open Joomla Administrator Login Page ' );
126129 $ this ->amOnPage ($ this ->locator ->adminLoginPageUrl );
127130 $ this ->waitForElement ($ this ->locator ->adminLoginUserName , TIMEOUT );
128131 $ this ->debug ('Fill Username Text Field ' );
129132 $ this ->fillField ($ this ->locator ->adminLoginUserName , $ user );
130133 $ this ->debug ('Fill Password Text Field ' );
131134 $ this ->fillField ($ this ->locator ->adminLoginPassword , $ password );
132-
133135 // @todo: update login button in joomla login screen to make this xPath more friendly
134136 $ this ->debug ('I click Login button ' );
135137 $ this ->click ($ this ->locator ->adminLoginButton );
136138 $ this ->debug ('I wait to see Administrator Control Panel ' );
137139 $ this ->waitForText ($ this ->locator ->adminControlPanelText , 4 , $ this ->locator ->controlPanelLocator );
140+ if ($ useSnapshot ) {
141+ $ this ->saveSessionSnapshot ($ user );
142+ }
138143 }
139144
140145 /**
0 commit comments