@@ -24,22 +24,36 @@ class JoomlaBrowser extends WebDriver
2424 'database type ' ,
2525 'database prefix ' ,
2626 'admin email ' ,
27- 'language ' ,
28-
27+ 'language '
2928 );
3029
3130 /**
3231 * Function to Do Admin Login In Joomla!
32+ *
33+ * @param string|null $user Optional Username. If not passed the one in acceptance.suite.yml will be used
34+ * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used
3335 */
34- public function doAdministratorLogin ()
36+ public function doAdministratorLogin ($ user = null , $ password = null )
3537 {
3638 $ I = $ this ;
39+
40+ if (is_null ($ user ))
41+ {
42+ $ user = $ this ->config ['username ' ];
43+ }
44+
45+ if (is_null ($ password ))
46+ {
47+ $ password = $ this ->config ['password ' ];
48+ }
49+
50+
3751 $ this ->debug ('I open Joomla Administrator Login Page ' );
3852 $ I ->amOnPage ('/administrator/index.php ' );
3953 $ this ->debug ('Fill Username Text Field ' );
40- $ I ->fillField (['id ' => 'mod-login-username ' ], $ this -> config [ ' username ' ] );
54+ $ I ->fillField (['id ' => 'mod-login-username ' ], $ user );
4155 $ this ->debug ('Fill Password Text Field ' );
42- $ I ->fillField (['id ' => 'mod-login-password ' ], $ this -> config [ ' password ' ] );
56+ $ I ->fillField (['id ' => 'mod-login-password ' ], $ password );
4357 // @todo: update login button in joomla login screen to make this xPath more friendly
4458 $ this ->debug ('I click Login button ' );
4559 $ I ->click (['xpath ' => "//button[contains(normalize-space(), 'Log in')] " ]);
@@ -48,17 +62,32 @@ public function doAdministratorLogin()
4862 }
4963
5064 /**
51- * Function to Do frontend Login in Joomla!
65+ /**
66+ * Function to Do Frontend Login In Joomla!
67+ *
68+ * @param string|null $user Optional username. If not passed the one in acceptance.suite.yml will be used
69+ * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used
5270 */
53- public function doFrontEndLogin ()
71+ public function doFrontEndLogin ($ user = null , $ password = null )
5472 {
5573 $ I = $ this ;
74+
75+ if (is_null ($ user ))
76+ {
77+ $ user = $ this ->config ['username ' ];
78+ }
79+
80+ if (is_null ($ password ))
81+ {
82+ $ password = $ this ->config ['password ' ];
83+ }
84+
5685 $ this ->debug ('I open Joomla Frontend Login Page ' );
5786 $ I ->amOnPage ('/index.php?option=com_users&view=login ' );
5887 $ this ->debug ('Fill Username Text Field ' );
59- $ I ->fillField (['id ' => 'username ' ], $ this -> config [ ' username ' ] );
88+ $ I ->fillField (['id ' => 'username ' ], $ user );
6089 $ this ->debug ('Fill Password Text Field ' );
61- $ I ->fillField (['id ' => 'password ' ], $ this -> config [ ' password ' ] );
90+ $ I ->fillField (['id ' => 'password ' ], $ password );
6291 // @todo: update login button in joomla login screen to make this xPath more friendly
6392 $ this ->debug ('I click Login button ' );
6493 $ I ->click (['xpath ' => "//div[@class='login']/form/fieldset/div[4]/div/button " ]);
0 commit comments