From 03c8b6ffa5c758d1dcd25f818a6997caeccd051d Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Mon, 15 May 2017 23:48:24 +0530 Subject: [PATCH 01/14] Adding a new Locator Class, these are ProtoStar Locators, Joomla 3.x Default Tempate --- src/locator/Locators.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/locator/Locators.php diff --git a/src/locator/Locators.php b/src/locator/Locators.php new file mode 100644 index 0000000..9491474 --- /dev/null +++ b/src/locator/Locators.php @@ -0,0 +1,29 @@ + 'username']; + + public static $loginPassword = ['id' => 'password']; + + public static $loginButton = ['xpath' => "//div[@class='login']/form/fieldset/div[4]/div/button"]; + + public static $frontEndLoginSuccess = ['xpath' => "//form[@id='login-form']/div[@class='logout-button']"]; + + public static $frontEndLogoutButton = ['xpath' => "//div[@class='logout']//button[contains(text(), 'Log out')]"]; + + public static $frontEndLoginForm = ['xpath' => "//div[@class='login']//button[contains(text(), 'Log in')]"]; + + public static $adminLoginPageUrl = '/administrator/index.php'; + + public static $adminLoginUserName = ['id' => 'mod-login-username']; + + public static $adminLoginPassword = ['id' => 'mod-login-password']; + + public static $adminLoginButton = ['xpath' => "//button[contains(normalize-space(), 'Log in')]"]; + + public static $controlPanelLocator = ['css' => 'h1.page-title']; + + public static $frontEndLoginUrl = '/index.php?option=com_users&view=login'; + +} \ No newline at end of file From 8a689f5e5002060e3abd52d55bccd0fff6ec02d3 Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Mon, 15 May 2017 23:55:54 +0530 Subject: [PATCH 02/14] Updating Joomla Browser --- src/JoomlaBrowser.php | 67 +++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index e5cf096..ef8a097 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -38,6 +38,38 @@ class JoomlaBrowser extends WebDriver 'language' ); + protected $locatorObject; + + /** + * Function to instantiate the Locator Class, In case of a custom Template, + * path to the custom Template Locator could be passed in Acceptance.suite.yml file + * + * for example: If the Class is present at _support/Page/Acceptance folder, simple add a new Parameter in acceptance.suite.yml file + * + * locator class: 'Page\Acceptance\Bootstrap2TemplateLocators' + * + * Locator could be set to null like this + * + * locator class: null + * + * When set to null, Joomla Browser will use the custom Locators present inside Locators.php + * + * @return \Locators + */ + public function instantiateLocator() + { + if (!(isset($this->config['locator class'])) || is_null($this->config['locator class'])) + { + $this->locatorObject = new \Locators(); + } + else{ + $temp = $this->config['locator class']; + $this->locatorObject = new $temp; + } + + return $this->locatorObject; + } + /** * Function to Do Admin Login In Joomla! * @@ -49,6 +81,8 @@ class JoomlaBrowser extends WebDriver public function doAdministratorLogin($user = null, $password = null) { $I = $this; + $locator = $this->instantiateLocator(); + if (is_null($user)) { @@ -61,18 +95,18 @@ public function doAdministratorLogin($user = null, $password = null) } $this->debug('I open Joomla Administrator Login Page'); - $I->amOnPage('/administrator/index.php'); - $I->waitForElement(['id' => 'mod-login-username'], 60); + $I->amOnPage($locator::$adminLoginPageUrl); + $I->waitForElement($locator::$adminLoginUserName, 60); $this->debug('Fill Username Text Field'); - $I->fillField(['id' => 'mod-login-username'], $user); + $I->fillField($locator::$adminLoginUserName, $user); $this->debug('Fill Password Text Field'); - $I->fillField(['id' => 'mod-login-password'], $password); + $I->fillField($locator::$adminLoginPassword, $password); // @todo: update login button in joomla login screen to make this xPath more friendly $this->debug('I click Login button'); - $I->click(['xpath' => "//button[contains(normalize-space(), 'Log in')]"]); + $I->click($locator::$adminLoginButton); $this->debug('I wait to see Administrator Control Panel'); - $I->waitForText('Control Panel', 4, ['css' => 'h1.page-title']); + $I->waitForText('Control Panel', 4, $locator::$controlPanelLocator); } /** @@ -86,6 +120,7 @@ public function doAdministratorLogin($user = null, $password = null) public function doFrontEndLogin($user = null, $password = null) { $I = $this; + $locatorObject = $this->instantiateLocator(); if (is_null($user)) { @@ -98,17 +133,18 @@ public function doFrontEndLogin($user = null, $password = null) } $this->debug('I open Joomla Frontend Login Page'); - $I->amOnPage('/index.php?option=com_users&view=login'); + $I->amOnPage($locatorObject::$frontEndLoginUrl); $this->debug('Fill Username Text Field'); - $I->fillField(['id' => 'username'], $user); + $I->fillField($locatorObject::$loginUserName, $user); $this->debug('Fill Password Text Field'); - $I->fillField(['id' => 'password'], $password); + $I->fillField($locatorObject::$loginPassword, $password); // @todo: update login button in joomla login screen to make this xPath more friendly $this->debug('I click Login button'); - $I->click(['xpath' => "//div[@class='login']/form/fieldset/div[4]/div/button"]); + $I->click($locatorObject::$loginButton); $this->debug('I wait to see Frontend Member Profile Form with the Logout button in the module'); - $I->waitForElement(['xpath' => "//form[@id='login-form']/div[@class='logout-button']"], 60); + + $I->waitForElement($locatorObject::$frontEndLoginSuccess, 60); } /** @@ -119,13 +155,14 @@ public function doFrontEndLogin($user = null, $password = null) public function doFrontendLogout() { $I = $this; + $locator = $this->instantiateLocator(); $this->debug('I open Joomla Frontend Login Page'); - $I->amOnPage('/index.php?option=com_users&view=login'); + $I->amOnPage($locator::$frontEndLoginUrl); $this->debug('I click Logout button'); - $I->click(['xpath' => "//div[@class='logout']//button[contains(text(), 'Log out')]"]); + $I->click($locator::$frontEndLogoutButton); $this->debug('I wait to see Login form'); - $I->waitForElement(['xpath' => "//div[@class='login']//button[contains(text(), 'Log in')]"], 30); - $I->seeElement(['xpath' => "//div[@class='login']//button[contains(text(), 'Log in')]"]); + $I->waitForElement($locator::$frontEndLoginForm, 30); + $I->seeElement($locator::$frontEndLoginForm); } /** From 31343e047b7abc71d640f07c7bc4122e4b6a2d07 Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Wed, 21 Jun 2017 22:07:31 +0530 Subject: [PATCH 03/14] Fixing Comments --- src/JoomlaBrowser.php | 61 +++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index ef8a097..b3acdb2 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -9,6 +9,8 @@ namespace Codeception\Module; use Codeception\Module\WebDriver; +require_once('locator/Locators.php'); +const TIMEOUT = 60; /** * Joomla Browser class to perform test suits for Joomla. @@ -58,11 +60,12 @@ class JoomlaBrowser extends WebDriver */ public function instantiateLocator() { - if (!(isset($this->config['locator class'])) || is_null($this->config['locator class'])) + if (empty($this->config['locator class'])) { $this->locatorObject = new \Locators(); } - else{ + else + { $temp = $this->config['locator class']; $this->locatorObject = new $temp; } @@ -96,7 +99,7 @@ public function doAdministratorLogin($user = null, $password = null) $this->debug('I open Joomla Administrator Login Page'); $I->amOnPage($locator::$adminLoginPageUrl); - $I->waitForElement($locator::$adminLoginUserName, 60); + $I->waitForElement($locator::$adminLoginUserName, TIMEOUT); $this->debug('Fill Username Text Field'); $I->fillField($locator::$adminLoginUserName, $user); $this->debug('Fill Password Text Field'); @@ -144,7 +147,7 @@ public function doFrontEndLogin($user = null, $password = null) $I->click($locatorObject::$loginButton); $this->debug('I wait to see Frontend Member Profile Form with the Logout button in the module'); - $I->waitForElement($locatorObject::$frontEndLoginSuccess, 60); + $I->waitForElement($locatorObject::$frontEndLoginSuccess, TIMEOUT); } /** @@ -191,14 +194,14 @@ public function installJoomla() // Select a random language to force reloading of the lang strings after selecting English $I->selectOptionInChosenWithTextField('#jform_language', 'Spanish (Español)'); - $I->waitForText('Configuración principal', 60, 'h3'); + $I->waitForText('Configuración principal', TIMEOUT, 'h3'); // Wait for chosen to render the field $I->debug('I select en-GB as installation language'); $I->debug('Wait for chosen to render the Languages list field'); $I->wait(2); $I->selectOptionInChosenWithTextField('#jform_language', 'English (United Kingdom)'); - $I->waitForText('Main Configuration', 60, 'h3'); + $I->waitForText('Main Configuration', TIMEOUT, 'h3'); $this->debug('I fill Site Name'); $I->fillField(['id' => 'jform_site_name'], 'Joomla CMS test'); $this->debug('I fill Site Description'); @@ -221,7 +224,7 @@ public function installJoomla() $I->click(['link' => 'Next']); $this->debug('I Fill the form for creating the Joomla site Database'); - $I->waitForText('Database Configuration', 60, ['css' => 'h3']); + $I->waitForText('Database Configuration', TIMEOUT, ['css' => 'h3']); $this->debug('I select MySQLi'); $I->selectOption(['id' => 'jform_db_type'], $this->config['database type']); @@ -244,7 +247,7 @@ public function installJoomla() $I->waitForElementVisible(['id' => 'jform_sample_file-lbl'], 30); $this->debug('I install joomla with or without sample data'); - $I->waitForText('Finalisation', 60, ['xpath' => '//h3']); + $I->waitForText('Finalisation', TIMEOUT, ['xpath' => '//h3']); // @todo: installation of sample data needs to be created @@ -254,7 +257,7 @@ public function installJoomla() // Wait while Joomla gets installed $this->debug('I wait for Joomla being installed'); - $I->waitForText('Congratulations! Joomla! is now installed.', 60, ['xpath' => '//h3']); + $I->waitForText('Congratulations! Joomla! is now installed.', TIMEOUT, ['xpath' => '//h3']); } /** @@ -272,7 +275,7 @@ public function installJoomlaRemovingInstallationFolder() $I->click(['xpath' => "//input[@value='Remove installation folder']"]); $I->debug('I wait for Removing Installation Folder button to become disabled'); - $I->waitForJS("return jQuery('form#adminForm input[name=instDefault]').attr('disabled') == 'disabled';", 60); + $I->waitForJS("return jQuery('form#adminForm input[name=instDefault]').attr('disabled') == 'disabled';", TIMEOUT); $I->debug('Joomla is now installed'); $I->see('Congratulations! Joomla! is now installed.', ['xpath' => '//h3']); @@ -301,7 +304,7 @@ public function installJoomlaMultilingualSite($languages = array()) $this->debug('I go to Install Languages page'); $I->click(['id' => 'instLangs']); - $I->waitForText('Install Language packages', 60, ['xpath' => '//h3']); + $I->waitForText('Install Language packages', TIMEOUT, ['xpath' => '//h3']); foreach ($languages as $language) { @@ -310,14 +313,14 @@ public function installJoomlaMultilingualSite($languages = array()) } $I->click(['link' => 'Next']); - $I->waitForText('Multilingual', 60, ['xpath' => '//h3']); + $I->waitForText('Multilingual', TIMEOUT, ['xpath' => '//h3']); $I->selectOptionInRadioField('Activate the multilingual feature', 'Yes'); $I->waitForElementVisible(['id' => 'jform_activatePluginLanguageCode-lbl']); $I->selectOptionInRadioField('Install localised content', 'Yes'); $I->selectOptionInRadioField('Enable the language code plugin', 'Yes'); $I->click(['link' => 'Next']); - $I->waitForText('Congratulations! Joomla! is now installed.', 60, ['xpath' => '//h3']); + $I->waitForText('Congratulations! Joomla! is now installed.', TIMEOUT, ['xpath' => '//h3']); $this->debug('Removing Installation Folder'); $I->click(['xpath' => "//input[@value='Remove installation folder']"]); @@ -340,7 +343,7 @@ public function setErrorReportingToDevelopment() $this->debug('I open Joomla Global Configuration Page'); $I->amOnPage('/administrator/index.php?option=com_config'); $this->debug('I wait for Global Configuration title'); - $I->waitForText('Global Configuration', 60, ['css' => '.page-title']); + $I->waitForText('Global Configuration', TIMEOUT, ['css' => '.page-title']); $this->debug('I open the Server Tab'); $I->click(['link' => 'Server']); $this->debug('I wait for error reporting dropdown'); @@ -348,7 +351,7 @@ public function setErrorReportingToDevelopment() $this->debug('I click on save'); $I->click(['xpath' => "//div[@id='toolbar-apply']//button"]); $this->debug('I wait for global configuration being saved'); - $I->waitForText('Global Configuration', 60, ['css' => '.page-title']); + $I->waitForText('Global Configuration', TIMEOUT, ['css' => '.page-title']); $I->see('Configuration successfully saved.', ['id' => 'system-message-container']); } @@ -389,7 +392,7 @@ public function installExtensionFromFolder($path, $type = 'Extension') $this->debug('I enter the Path'); $I->fillField(['id' => 'install_directory'], $path); $I->click(['id' => 'installbutton_directory']); - $I->waitForText('was successful', '60', ['id' => 'system-message-container']); + $I->waitForText('was successful', 'TIMEOUT', ['id' => 'system-message-container']); $this->debug("$type successfully installed from $path"); } @@ -601,10 +604,10 @@ public function doAdministratorLogout() $I = $this; $I->click(['xpath' => "//ul[@class='nav nav-user pull-right']//li//a[@class='dropdown-toggle']"]); $this->debug("I click on Top Right corner toggle to Logout from Admin"); - $I->waitForElement(['xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']"], 60); + $I->waitForElement(['xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']"], TIMEOUT); $I->click(['xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']"]); - $I->waitForElement(['id' => 'mod-login-username'], 60); - $I->waitForText('Log in', 60, ['xpath' => "//fieldset[@class='loginform']//button"]); + $I->waitForElement(['id' => 'mod-login-username'], TIMEOUT); + $I->waitForText('Log in', TIMEOUT, ['xpath' => "//fieldset[@class='loginform']//button"]); } /** @@ -664,7 +667,7 @@ public function uninstallExtension($extensionName) $I->searchForItem($extensionName); $I->waitForText( 'There are no extensions installed matching your query.', - 60, + TIMEOUT, ['class' => 'alert-no-items'] ); $I->see('There are no extensions installed matching your query.', ['class' => 'alert-no-items']); @@ -747,7 +750,7 @@ public function installLanguage($languageName) $I->waitForElement($this->searchResultLanguageName($languageName), 30); $I->click(['id' => "cb0"]); $I->click(['xpath' => "//div[@id='toolbar-upload']/button"]); - $I->waitForText('was successful.', 60, ['id' => 'system-message-container']); + $I->waitForText('was successful.', TIMEOUT, ['id' => 'system-message-container']); $I->see('No Matching Results', ['class' => 'alert-no-items']); $this->debug($languageName . ' successfully installed'); } @@ -913,23 +916,23 @@ public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Ma $I->debug("I open the menus page"); $I->amOnPage('administrator/index.php?option=com_menus&view=menus'); - $I->waitForText('Menus', '60', ['css' => 'H1']); + $I->waitForText('Menus', 'TIMEOUT', ['css' => 'H1']); $this->checkForPhpNoticesOrWarnings(); $I->debug("I click in the menu: $menu"); $I->click(['link' => $menu]); - $I->waitForText('Menus: Items', '60', ['css' => 'H1']); + $I->waitForText('Menus: Items', 'TIMEOUT', ['css' => 'H1']); $this->checkForPhpNoticesOrWarnings(); $I->debug("I click new"); $I->click("New"); - $I->waitForText('Menus: New Item', '60', ['css' => 'h1']); + $I->waitForText('Menus: New Item', 'TIMEOUT', ['css' => 'h1']); $this->checkForPhpNoticesOrWarnings(); $I->fillField(['id' => 'jform_title'], $menuTitle); $I->debug("Open the menu types iframe"); $I->click(['link' => "Select"]); - $I->waitForElement(['id' => 'menuTypeModal'], '60'); + $I->waitForElement(['id' => 'menuTypeModal'], 'TIMEOUT'); $I->wait(1); $I->switchToIFrame("Menu Item Type"); @@ -937,12 +940,12 @@ public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Ma // Open the category $I->wait(1); - $I->waitForElement(['link' => $menuCategory], '60'); + $I->waitForElement(['link' => $menuCategory], 'TIMEOUT'); $I->click(['link' => $menuCategory]); $I->debug("Choose the menu item type: $menuItem"); $I->wait(1); - $I->waitForElement(['xpath' => "//a[contains(text()[normalize-space()], '$menuItem')]"], '60'); + $I->waitForElement(['xpath' => "//a[contains(text()[normalize-space()], '$menuItem')]"], 'TIMEOUT'); $I->click(['xpath' => "//div[@id='collapseTypes']//a[contains(text()[normalize-space()], '$menuItem')]"]); $I->debug('I switch back to the main window'); $I->switchToIFrame(); @@ -953,7 +956,7 @@ public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Ma $I->debug('I save the menu'); $I->click("Save"); - $I->waitForText('Menu item successfully saved', '60', ['id' => 'system-message-container']); + $I->waitForText('Menu item successfully saved', 'TIMEOUT', ['id' => 'system-message-container']); } /** @@ -1020,7 +1023,7 @@ public function disableStatistics() $I = $this; $this->debug('I click on never'); $I->wait(1); - $I->waitForElement(['link' => 'Never'], 60); + $I->waitForElement(['link' => 'Never'], TIMEOUT); $I->click(['link' => 'Never']); } } From 1731087fa14ce82a666367c6888e4857a7810801 Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Wed, 21 Jun 2017 22:15:01 +0530 Subject: [PATCH 04/14] Commiting the file again --- src/JoomlaBrowser.php | 120 ++++++++++++++++++++++++++++-------------- 1 file changed, 80 insertions(+), 40 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 7b7c351..876d239 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -9,6 +9,8 @@ namespace Codeception\Module; use Codeception\Module\WebDriver; +require_once('locator/Locators.php'); +const TIMEOUT = 60; /** * Joomla Browser class to perform test suits for Joomla. @@ -38,6 +40,39 @@ class JoomlaBrowser extends WebDriver 'language' ); + protected $locatorObject; + + /** + * Function to instantiate the Locator Class, In case of a custom Template, + * path to the custom Template Locator could be passed in Acceptance.suite.yml file + * + * for example: If the Class is present at _support/Page/Acceptance folder, simple add a new Parameter in acceptance.suite.yml file + * + * locator class: 'Page\Acceptance\Bootstrap2TemplateLocators' + * + * Locator could be set to null like this + * + * locator class: null + * + * When set to null, Joomla Browser will use the custom Locators present inside Locators.php + * + * @return \Locators + */ + public function instantiateLocator() + { + if (empty($this->config['locator class'])) + { + $this->locatorObject = new \Locators(); + } + else + { + $temp = $this->config['locator class']; + $this->locatorObject = new $temp; + } + + return $this->locatorObject; + } + /** * Function to Do Admin Login In Joomla! * @@ -49,6 +84,8 @@ class JoomlaBrowser extends WebDriver public function doAdministratorLogin($user = null, $password = null) { $I = $this; + $locator = $this->instantiateLocator(); + if (is_null($user)) { @@ -61,18 +98,18 @@ public function doAdministratorLogin($user = null, $password = null) } $this->debug('I open Joomla Administrator Login Page'); - $I->amOnPage('/administrator/index.php'); - $I->waitForElement(['id' => 'mod-login-username'], 60); + $I->amOnPage($locator::$adminLoginPageUrl); + $I->waitForElement($locator::$adminLoginUserName, TIMEOUT); $this->debug('Fill Username Text Field'); - $I->fillField(['id' => 'mod-login-username'], $user); + $I->fillField($locator::$adminLoginUserName, $user); $this->debug('Fill Password Text Field'); - $I->fillField(['id' => 'mod-login-password'], $password); + $I->fillField($locator::$adminLoginPassword, $password); // @todo: update login button in joomla login screen to make this xPath more friendly $this->debug('I click Login button'); - $I->click(['xpath' => "//button[contains(normalize-space(), 'Log in')]"]); + $I->click($locator::$adminLoginButton); $this->debug('I wait to see Administrator Control Panel'); - $I->waitForText('Control Panel', 4, ['css' => 'h1.page-title']); + $I->waitForText('Control Panel', 4, $locator::$controlPanelLocator); } /** @@ -86,6 +123,7 @@ public function doAdministratorLogin($user = null, $password = null) public function doFrontEndLogin($user = null, $password = null) { $I = $this; + $locatorObject = $this->instantiateLocator(); if (is_null($user)) { @@ -98,17 +136,18 @@ public function doFrontEndLogin($user = null, $password = null) } $this->debug('I open Joomla Frontend Login Page'); - $I->amOnPage('/index.php?option=com_users&view=login'); + $I->amOnPage($locatorObject::$frontEndLoginUrl); $this->debug('Fill Username Text Field'); - $I->fillField(['id' => 'username'], $user); + $I->fillField($locatorObject::$loginUserName, $user); $this->debug('Fill Password Text Field'); - $I->fillField(['id' => 'password'], $password); + $I->fillField($locatorObject::$loginPassword, $password); // @todo: update login button in joomla login screen to make this xPath more friendly $this->debug('I click Login button'); - $I->click(['xpath' => "//div[@class='login']/form/fieldset/div[4]/div/button"]); + $I->click($locatorObject::$loginButton); $this->debug('I wait to see Frontend Member Profile Form with the Logout button in the module'); - $I->waitForElement(['xpath' => "//form[@id='login-form']/div[@class='logout-button']"], 60); + + $I->waitForElement($locatorObject::$frontEndLoginSuccess, TIMEOUT); } /** @@ -119,13 +158,14 @@ public function doFrontEndLogin($user = null, $password = null) public function doFrontendLogout() { $I = $this; + $locator = $this->instantiateLocator(); $this->debug('I open Joomla Frontend Login Page'); - $I->amOnPage('/index.php?option=com_users&view=login'); + $I->amOnPage($locator::$frontEndLoginUrl); $this->debug('I click Logout button'); - $I->click(['xpath' => "//div[@class='logout']//button[contains(text(), 'Log out')]"]); + $I->click($locator::$frontEndLogoutButton); $this->debug('I wait to see Login form'); - $I->waitForElement(['xpath' => "//div[@class='login']//button[contains(text(), 'Log in')]"], 30); - $I->seeElement(['xpath' => "//div[@class='login']//button[contains(text(), 'Log in')]"]); + $I->waitForElement($locator::$frontEndLoginForm, 30); + $I->seeElement($locator::$frontEndLoginForm); } /** @@ -154,14 +194,14 @@ public function installJoomla() // Select a random language to force reloading of the lang strings after selecting English $I->selectOptionInChosenWithTextField('#jform_language', 'Spanish (Español)'); - $I->waitForText('Configuración principal', 60, 'h3'); + $I->waitForText('Configuración principal', TIMEOUT, 'h3'); // Wait for chosen to render the field $I->debug('I select en-GB as installation language'); $I->debug('Wait for chosen to render the Languages list field'); $I->wait(2); $I->selectOptionInChosenWithTextField('#jform_language', 'English (United Kingdom)'); - $I->waitForText('Main Configuration', 60, 'h3'); + $I->waitForText('Main Configuration', TIMEOUT, 'h3'); $this->debug('I fill Site Name'); $I->fillField(['id' => 'jform_site_name'], 'Joomla CMS test'); $this->debug('I fill Site Description'); @@ -184,7 +224,7 @@ public function installJoomla() $I->click(['link' => 'Next']); $this->debug('I Fill the form for creating the Joomla site Database'); - $I->waitForText('Database Configuration', 60, ['css' => 'h3']); + $I->waitForText('Database Configuration', TIMEOUT, ['css' => 'h3']); $this->debug('I select MySQLi'); $I->selectOption(['id' => 'jform_db_type'], $this->config['database type']); @@ -207,7 +247,7 @@ public function installJoomla() $I->waitForElementVisible(['id' => 'jform_sample_file-lbl'], 30); $this->debug('I install joomla with or without sample data'); - $I->waitForText('Finalisation', 60, ['xpath' => '//h3']); + $I->waitForText('Finalisation', TIMEOUT, ['xpath' => '//h3']); // @todo: installation of sample data needs to be created @@ -217,7 +257,7 @@ public function installJoomla() // Wait while Joomla gets installed $this->debug('I wait for Joomla being installed'); - $I->waitForText('Congratulations! Joomla! is now installed.', 60, ['xpath' => '//h3']); + $I->waitForText('Congratulations! Joomla! is now installed.', TIMEOUT, ['xpath' => '//h3']); } /** @@ -235,7 +275,7 @@ public function installJoomlaRemovingInstallationFolder() $I->click(['xpath' => "//input[@value='Remove installation folder']"]); $I->debug('I wait for Removing Installation Folder button to become disabled'); - $I->waitForJS("return jQuery('form#adminForm input[name=instDefault]').attr('disabled') == 'disabled';", 60); + $I->waitForJS("return jQuery('form#adminForm input[name=instDefault]').attr('disabled') == 'disabled';", TIMEOUT); $I->debug('Joomla is now installed'); $I->see('Congratulations! Joomla! is now installed.', ['xpath' => '//h3']); @@ -264,7 +304,7 @@ public function installJoomlaMultilingualSite($languages = array()) $this->debug('I go to Install Languages page'); $I->click(['id' => 'instLangs']); - $I->waitForText('Install Language packages', 60, ['xpath' => '//h3']); + $I->waitForText('Install Language packages', TIMEOUT, ['xpath' => '//h3']); foreach ($languages as $language) { @@ -273,14 +313,14 @@ public function installJoomlaMultilingualSite($languages = array()) } $I->click(['link' => 'Next']); - $I->waitForText('Multilingual', 60, ['xpath' => '//h3']); + $I->waitForText('Multilingual', TIMEOUT, ['xpath' => '//h3']); $I->selectOptionInRadioField('Activate the multilingual feature', 'Yes'); $I->waitForElementVisible(['id' => 'jform_activatePluginLanguageCode-lbl']); $I->selectOptionInRadioField('Install localised content', 'Yes'); $I->selectOptionInRadioField('Enable the language code plugin', 'Yes'); $I->click(['link' => 'Next']); - $I->waitForText('Congratulations! Joomla! is now installed.', 60, ['xpath' => '//h3']); + $I->waitForText('Congratulations! Joomla! is now installed.', TIMEOUT, ['xpath' => '//h3']); $this->debug('Removing Installation Folder'); $I->click(['xpath' => "//input[@value='Remove installation folder']"]); @@ -303,7 +343,7 @@ public function setErrorReportingToDevelopment() $this->debug('I open Joomla Global Configuration Page'); $I->amOnPage('/administrator/index.php?option=com_config'); $this->debug('I wait for Global Configuration title'); - $I->waitForText('Global Configuration', 60, ['css' => '.page-title']); + $I->waitForText('Global Configuration', TIMEOUT, ['css' => '.page-title']); $this->debug('I open the Server Tab'); $I->click(['link' => 'Server']); $this->debug('I wait for error reporting dropdown'); @@ -311,7 +351,7 @@ public function setErrorReportingToDevelopment() $this->debug('I click on save'); $I->click(['xpath' => "//div[@id='toolbar-apply']//button"]); $this->debug('I wait for global configuration being saved'); - $I->waitForText('Global Configuration', 60, ['css' => '.page-title']); + $I->waitForText('Global Configuration', TIMEOUT, ['css' => '.page-title']); $I->see('Configuration saved.', ['id' => 'system-message-container']); } @@ -352,7 +392,7 @@ public function installExtensionFromFolder($path, $type = 'Extension') $this->debug('I enter the Path'); $I->fillField(['id' => 'install_directory'], $path); $I->click(['id' => 'installbutton_directory']); - $I->waitForText('was successful', '60', ['id' => 'system-message-container']); + $I->waitForText('was successful', 'TIMEOUT', ['id' => 'system-message-container']); $this->debug("$type successfully installed from $path"); } @@ -564,10 +604,10 @@ public function doAdministratorLogout() $I = $this; $I->click(['xpath' => "//ul[@class='nav nav-user pull-right']//li//a[@class='dropdown-toggle']"]); $this->debug("I click on Top Right corner toggle to Logout from Admin"); - $I->waitForElement(['xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']"], 60); + $I->waitForElement(['xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']"], TIMEOUT); $I->click(['xpath' => "//li[@class='dropdown open']/ul[@class='dropdown-menu']//a[text() = 'Logout']"]); - $I->waitForElement(['id' => 'mod-login-username'], 60); - $I->waitForText('Log in', 60, ['xpath' => "//fieldset[@class='loginform']//button"]); + $I->waitForElement(['id' => 'mod-login-username'], TIMEOUT); + $I->waitForText('Log in', TIMEOUT, ['xpath' => "//fieldset[@class='loginform']//button"]); } /** @@ -627,7 +667,7 @@ public function uninstallExtension($extensionName) $I->searchForItem($extensionName); $I->waitForText( 'There are no extensions installed matching your query.', - 60, + TIMEOUT, ['class' => 'alert-no-items'] ); $I->see('There are no extensions installed matching your query.', ['class' => 'alert-no-items']); @@ -710,7 +750,7 @@ public function installLanguage($languageName) $I->waitForElement($this->searchResultLanguageName($languageName), 30); $I->click(['id' => "cb0"]); $I->click(['xpath' => "//div[@id='toolbar-upload']/button"]); - $I->waitForText('was successful.', 60, ['id' => 'system-message-container']); + $I->waitForText('was successful.', TIMEOUT, ['id' => 'system-message-container']); $I->see('No Matching Results', ['class' => 'alert-no-items']); $this->debug($languageName . ' successfully installed'); } @@ -876,23 +916,23 @@ public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Ma $I->debug("I open the menus page"); $I->amOnPage('administrator/index.php?option=com_menus&view=menus'); - $I->waitForText('Menus', '60', ['css' => 'H1']); + $I->waitForText('Menus', 'TIMEOUT', ['css' => 'H1']); $this->checkForPhpNoticesOrWarnings(); $I->debug("I click in the menu: $menu"); $I->click(['link' => $menu]); - $I->waitForText('Menus: Items', '60', ['css' => 'H1']); + $I->waitForText('Menus: Items', 'TIMEOUT', ['css' => 'H1']); $this->checkForPhpNoticesOrWarnings(); $I->debug("I click new"); $I->click("New"); - $I->waitForText('Menus: New Item', '60', ['css' => 'h1']); + $I->waitForText('Menus: New Item', 'TIMEOUT', ['css' => 'h1']); $this->checkForPhpNoticesOrWarnings(); $I->fillField(['id' => 'jform_title'], $menuTitle); $I->debug("Open the menu types iframe"); $I->click(['link' => "Select"]); - $I->waitForElement(['id' => 'menuTypeModal'], '60'); + $I->waitForElement(['id' => 'menuTypeModal'], 'TIMEOUT'); $I->wait(1); $I->switchToIFrame("Menu Item Type"); @@ -900,12 +940,12 @@ public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Ma // Open the category $I->wait(1); - $I->waitForElement(['link' => $menuCategory], '60'); + $I->waitForElement(['link' => $menuCategory], 'TIMEOUT'); $I->click(['link' => $menuCategory]); $I->debug("Choose the menu item type: $menuItem"); $I->wait(1); - $I->waitForElement(['xpath' => "//a[contains(text()[normalize-space()], '$menuItem')]"], '60'); + $I->waitForElement(['xpath' => "//a[contains(text()[normalize-space()], '$menuItem')]"], 'TIMEOUT'); $I->click(['xpath' => "//div[@id='collapseTypes']//a[contains(text()[normalize-space()], '$menuItem')]"]); $I->debug('I switch back to the main window'); $I->switchToIFrame(); @@ -916,7 +956,7 @@ public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Ma $I->debug('I save the menu'); $I->click("Save"); - $I->waitForText('Menu item successfully saved', '60', ['id' => 'system-message-container']); + $I->waitForText('Menu item successfully saved', 'TIMEOUT', ['id' => 'system-message-container']); } /** @@ -983,7 +1023,7 @@ public function disableStatistics() $I = $this; $this->debug('I click on never'); $I->wait(1); - $I->waitForElement(['link' => 'Never'], 60); + $I->waitForElement(['link' => 'Never'], TIMEOUT); $I->click(['link' => 'Never']); } } From efef9dfcea01052e1c262fc3f0e8ad1b924544ea Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Fri, 23 Jun 2017 00:01:53 +0530 Subject: [PATCH 05/14] Updating Page Class, Non Static --- src/locator/Locators.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/locator/Locators.php b/src/locator/Locators.php index 9491474..2f5afa2 100644 --- a/src/locator/Locators.php +++ b/src/locator/Locators.php @@ -1,29 +1,30 @@ 'username']; + public $loginUserName = ['id' => 'username']; - public static $loginPassword = ['id' => 'password']; + public $loginPassword = ['id' => 'password']; - public static $loginButton = ['xpath' => "//div[@class='login']/form/fieldset/div[4]/div/button"]; + public $loginButton = ['xpath' => "//div[@class='login']/form/fieldset/div[4]/div/button"]; - public static $frontEndLoginSuccess = ['xpath' => "//form[@id='login-form']/div[@class='logout-button']"]; + public $frontEndLoginSuccess = ['xpath' => "//form[@id='login-form']/div[@class='logout-button']"]; - public static $frontEndLogoutButton = ['xpath' => "//div[@class='logout']//button[contains(text(), 'Log out')]"]; + public $frontEndLogoutButton = ['xpath' => "//div[@class='logout']//button[contains(text(), 'Log out')]"]; - public static $frontEndLoginForm = ['xpath' => "//div[@class='login']//button[contains(text(), 'Log in')]"]; + public $frontEndLoginForm = ['xpath' => "//div[@class='login']//button[contains(text(), 'Log in')]"]; - public static $adminLoginPageUrl = '/administrator/index.php'; + public $adminLoginPageUrl = '/administrator/index.php'; - public static $adminLoginUserName = ['id' => 'mod-login-username']; + public $adminLoginUserName = ['id' => 'mod-login-username']; - public static $adminLoginPassword = ['id' => 'mod-login-password']; + public $adminLoginPassword = ['id' => 'mod-login-password']; - public static $adminLoginButton = ['xpath' => "//button[contains(normalize-space(), 'Log in')]"]; + public $adminLoginButton = ['xpath' => "//button[contains(normalize-space(), 'Log in')]"]; - public static $controlPanelLocator = ['css' => 'h1.page-title']; + public $controlPanelLocator = ['css' => 'h1.page-title']; - public static $frontEndLoginUrl = '/index.php?option=com_users&view=login'; + public $frontEndLoginUrl = '/index.php?option=com_users&view=login'; } \ No newline at end of file From 350bb6aee81d70683c2b4a9822d74a6307f81557 Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Fri, 23 Jun 2017 00:02:46 +0530 Subject: [PATCH 06/14] Updating Joomla Browser --- src/JoomlaBrowser.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 876d239..9a1f925 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -7,7 +7,7 @@ */ namespace Codeception\Module; - +use Joomla\Browser\Locators\Locators; use Codeception\Module\WebDriver; require_once('locator/Locators.php'); const TIMEOUT = 60; @@ -40,7 +40,7 @@ class JoomlaBrowser extends WebDriver 'language' ); - protected $locatorObject; + protected $locator; /** * Function to instantiate the Locator Class, In case of a custom Template, @@ -62,15 +62,15 @@ public function instantiateLocator() { if (empty($this->config['locator class'])) { - $this->locatorObject = new \Locators(); + $this->locator = new Locators; } else { $temp = $this->config['locator class']; - $this->locatorObject = new $temp; + $this->locator = new $temp; } - return $this->locatorObject; + return $this->locator; } /** @@ -98,18 +98,18 @@ public function doAdministratorLogin($user = null, $password = null) } $this->debug('I open Joomla Administrator Login Page'); - $I->amOnPage($locator::$adminLoginPageUrl); - $I->waitForElement($locator::$adminLoginUserName, TIMEOUT); + $I->amOnPage($locator->adminLoginPageUrl); + $I->waitForElement($locator->adminLoginUserName, TIMEOUT); $this->debug('Fill Username Text Field'); - $I->fillField($locator::$adminLoginUserName, $user); + $I->fillField($locator->adminLoginUserName, $user); $this->debug('Fill Password Text Field'); - $I->fillField($locator::$adminLoginPassword, $password); + $I->fillField($locator->adminLoginPassword, $password); // @todo: update login button in joomla login screen to make this xPath more friendly $this->debug('I click Login button'); - $I->click($locator::$adminLoginButton); + $I->click($locator->adminLoginButton); $this->debug('I wait to see Administrator Control Panel'); - $I->waitForText('Control Panel', 4, $locator::$controlPanelLocator); + $I->waitForText('Control Panel', 4, $locator->controlPanelLocator); } /** @@ -123,7 +123,7 @@ public function doAdministratorLogin($user = null, $password = null) public function doFrontEndLogin($user = null, $password = null) { $I = $this; - $locatorObject = $this->instantiateLocator(); + $locator = $this->instantiateLocator(); if (is_null($user)) { @@ -136,18 +136,18 @@ public function doFrontEndLogin($user = null, $password = null) } $this->debug('I open Joomla Frontend Login Page'); - $I->amOnPage($locatorObject::$frontEndLoginUrl); + $I->amOnPage($locator->frontEndLoginUrl); $this->debug('Fill Username Text Field'); - $I->fillField($locatorObject::$loginUserName, $user); + $I->fillField($locator->loginUserName, $user); $this->debug('Fill Password Text Field'); - $I->fillField($locatorObject::$loginPassword, $password); + $I->fillField($locator->loginPassword, $password); // @todo: update login button in joomla login screen to make this xPath more friendly $this->debug('I click Login button'); - $I->click($locatorObject::$loginButton); + $I->click($locator->loginButton); $this->debug('I wait to see Frontend Member Profile Form with the Logout button in the module'); - $I->waitForElement($locatorObject::$frontEndLoginSuccess, TIMEOUT); + $I->waitForElement($locator->frontEndLoginSuccess, TIMEOUT); } /** @@ -160,12 +160,12 @@ public function doFrontendLogout() $I = $this; $locator = $this->instantiateLocator(); $this->debug('I open Joomla Frontend Login Page'); - $I->amOnPage($locator::$frontEndLoginUrl); + $I->amOnPage($locator->frontEndLoginUrl); $this->debug('I click Logout button'); - $I->click($locator::$frontEndLogoutButton); + $I->click($locator->frontEndLogoutButton); $this->debug('I wait to see Login form'); - $I->waitForElement($locator::$frontEndLoginForm, 30); - $I->seeElement($locator::$frontEndLoginForm); + $I->waitForElement($locator->frontEndLoginForm, 30); + $I->seeElement($locator->frontEndLoginForm); } /** From 2845f47952099088be8465a47bcc0f3d8f630a11 Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Thu, 29 Jun 2017 14:41:37 +0530 Subject: [PATCH 07/14] Committing few changes --- src/JoomlaBrowser.php | 2 -- src/locator/Locators.php | 10 +++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 9a1f925..72e400a 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -9,7 +9,6 @@ namespace Codeception\Module; use Joomla\Browser\Locators\Locators; use Codeception\Module\WebDriver; -require_once('locator/Locators.php'); const TIMEOUT = 60; /** @@ -86,7 +85,6 @@ public function doAdministratorLogin($user = null, $password = null) $I = $this; $locator = $this->instantiateLocator(); - if (is_null($user)) { $user = $this->config['username']; diff --git a/src/locator/Locators.php b/src/locator/Locators.php index 2f5afa2..ab2ff11 100644 --- a/src/locator/Locators.php +++ b/src/locator/Locators.php @@ -1,7 +1,15 @@ 'username']; From 8793259e1596b2830e8d68af2776282636da898b Mon Sep 17 00:00:00 2001 From: puneet0191 Date: Thu, 29 Jun 2017 14:43:18 +0530 Subject: [PATCH 08/14] Updating the Namespace based on composer autoloader details --- src/JoomlaBrowser.php | 2 +- src/locator/Locators.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 72e400a..ac9ca30 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -7,7 +7,7 @@ */ namespace Codeception\Module; -use Joomla\Browser\Locators\Locators; +use Codeception\Module\Locators\Locators; use Codeception\Module\WebDriver; const TIMEOUT = 60; diff --git a/src/locator/Locators.php b/src/locator/Locators.php index ab2ff11..289370f 100644 --- a/src/locator/Locators.php +++ b/src/locator/Locators.php @@ -1,5 +1,5 @@ Date: Thu, 3 Aug 2017 17:21:08 +0200 Subject: [PATCH 09/14] Clean up --- src/JoomlaBrowser.php | 680 ++++++++++++++++++++++-------------------- 1 file changed, 360 insertions(+), 320 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index ac9ca30..535a377 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -7,8 +7,10 @@ */ namespace Codeception\Module; + use Codeception\Module\Locators\Locators; use Codeception\Module\WebDriver; + const TIMEOUT = 60; /** @@ -21,7 +23,8 @@ class JoomlaBrowser extends WebDriver /** * The module required fields, to be set in the suite .yml configuration file. * - * @var array + * @var array + * @since 3.0.0 */ protected $requiredFields = array( 'url', @@ -39,8 +42,32 @@ class JoomlaBrowser extends WebDriver 'language' ); + /** + * The locator + * + * @var Codeception\Module\Locators\Locators + * @since 3.7.4.2 + */ protected $locator; + /** + * Module constructor. + * + * Requires module container (to provide access between modules of suite) and config. + * + * @param ModuleContainer $moduleContainer The module container + * @param array $config The optional config + * + * @since 3.7.4.2 + */ + public function __construct(ModuleContainer $moduleContainer, $config = null) + { + parent::__construct($moduleContainer, $config); + + // Instantiate the locator + $this->instantiateLocator(); + } + /** * Function to instantiate the Locator Class, In case of a custom Template, * path to the custom Template Locator could be passed in Acceptance.suite.yml file @@ -55,21 +82,21 @@ class JoomlaBrowser extends WebDriver * * When set to null, Joomla Browser will use the custom Locators present inside Locators.php * - * @return \Locators + * @return void + * + * @since 3.0.0 */ - public function instantiateLocator() + protected function instantiateLocator() { if (empty($this->config['locator class'])) { $this->locator = new Locators; - } - else - { - $temp = $this->config['locator class']; - $this->locator = new $temp; + + return; } - return $this->locator; + $class = $this->config['locator class']; + $this->locator = new $class; } /** @@ -79,12 +106,10 @@ public function instantiateLocator() * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used * * @return void + * @since 3.0.0 */ public function doAdministratorLogin($user = null, $password = null) { - $I = $this; - $locator = $this->instantiateLocator(); - if (is_null($user)) { $user = $this->config['username']; @@ -96,18 +121,18 @@ public function doAdministratorLogin($user = null, $password = null) } $this->debug('I open Joomla Administrator Login Page'); - $I->amOnPage($locator->adminLoginPageUrl); - $I->waitForElement($locator->adminLoginUserName, TIMEOUT); + $this->amOnPage($this->locator->adminLoginPageUrl); + $this->waitForElement($this->locator->adminLoginUserName, TIMEOUT); $this->debug('Fill Username Text Field'); - $I->fillField($locator->adminLoginUserName, $user); + $this->fillField($this->locator->adminLoginUserName, $user); $this->debug('Fill Password Text Field'); - $I->fillField($locator->adminLoginPassword, $password); + $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'); - $I->click($locator->adminLoginButton); + $this->click($this->locator->adminLoginButton); $this->debug('I wait to see Administrator Control Panel'); - $I->waitForText('Control Panel', 4, $locator->controlPanelLocator); + $this->waitForText('Control Panel', 4, $this->locator->controlPanelLocator); } /** @@ -117,12 +142,10 @@ public function doAdministratorLogin($user = null, $password = null) * @param string|null $password Optional password. If not passed the one in acceptance.suite.yml will be used * * @return void + * @since 3.0.0 */ public function doFrontEndLogin($user = null, $password = null) { - $I = $this; - $locator = $this->instantiateLocator(); - if (is_null($user)) { $user = $this->config['username']; @@ -134,149 +157,145 @@ public function doFrontEndLogin($user = null, $password = null) } $this->debug('I open Joomla Frontend Login Page'); - $I->amOnPage($locator->frontEndLoginUrl); + $this->amOnPage($this->locator->frontEndLoginUrl); $this->debug('Fill Username Text Field'); - $I->fillField($locator->loginUserName, $user); + $this->fillField($this->locator->loginUserName, $user); $this->debug('Fill Password Text Field'); - $I->fillField($locator->loginPassword, $password); + $this->fillField($this->locator->loginPassword, $password); // @todo: update login button in joomla login screen to make this xPath more friendly $this->debug('I click Login button'); - $I->click($locator->loginButton); + $this->click($this->locator->loginButton); $this->debug('I wait to see Frontend Member Profile Form with the Logout button in the module'); - $I->waitForElement($locator->frontEndLoginSuccess, TIMEOUT); + $this->waitForElement($this->locator->frontEndLoginSuccess, TIMEOUT); } /** * Function to Do frontend Logout in Joomla! * * @return void + * + * @since 3.0.0 */ public function doFrontendLogout() { - $I = $this; - $locator = $this->instantiateLocator(); $this->debug('I open Joomla Frontend Login Page'); - $I->amOnPage($locator->frontEndLoginUrl); + $this->amOnPage($this->locator->frontEndLoginUrl); $this->debug('I click Logout button'); - $I->click($locator->frontEndLogoutButton); + $this->click($this->locator->frontEndLogoutButton); $this->debug('I wait to see Login form'); - $I->waitForElement($locator->frontEndLoginForm, 30); - $I->seeElement($locator->frontEndLoginForm); + $this->waitForElement($this->locator->frontEndLoginForm, 30); + $this->seeElement($this->locator->frontEndLoginForm); } /** * Installs Joomla * * @return void + * @since 3.0.0 */ public function installJoomla() { - $I = $this; - - // Install Joomla CMS'); - $this->debug('I open Joomla Installation Configuration Page'); - $I->amOnPage('/installation/index.php'); + $this->amOnPage('/installation/index.php'); $this->debug('I check that FTP tab is not present in installation. Otherwise it means that I have not enough ' - . 'permissions to install joomla and execution will be stoped'); - $I->dontSeeElement(['id' => 'ftp']); + . 'permissions to install joomla and execution will be stoped'); + $this->dontSeeElement(['id' => 'ftp']); // I Wait for the text Main Configuration, meaning that the page is loaded $this->debug('I wait for Main Configuration'); - $I->waitForElement('#jform_language', 10); - $I->debug('Wait for chosen to render the Languages list field'); - $I->wait(2); - $I->debug('I select dk-DK as installation language'); + $this->waitForElement('#jform_language', 10); + $this->debug('Wait for chosen to render the Languages list field'); + $this->wait(2); + $this->debug('I select dk-DK as installation language'); // Select a random language to force reloading of the lang strings after selecting English - $I->selectOptionInChosenWithTextField('#jform_language', 'Spanish (Español)'); - $I->waitForText('Configuración principal', TIMEOUT, 'h3'); + $this->selectOptionInChosenWithTextField('#jform_language', 'Spanish (Español)'); + $this->waitForText('Configuración principal', TIMEOUT, 'h3'); // Wait for chosen to render the field - $I->debug('I select en-GB as installation language'); - $I->debug('Wait for chosen to render the Languages list field'); - $I->wait(2); - $I->selectOptionInChosenWithTextField('#jform_language', 'English (United Kingdom)'); - $I->waitForText('Main Configuration', TIMEOUT, 'h3'); + $this->debug('I select en-GB as installation language'); + $this->debug('Wait for chosen to render the Languages list field'); + $this->wait(2); + $this->selectOptionInChosenWithTextField('#jform_language', 'English (United Kingdom)'); + $this->waitForText('Main Configuration', TIMEOUT, 'h3'); $this->debug('I fill Site Name'); - $I->fillField(['id' => 'jform_site_name'], 'Joomla CMS test'); + $this->fillField(['id' => 'jform_site_name'], 'Joomla CMS test'); $this->debug('I fill Site Description'); - $I->fillField(['id' => 'jform_site_metadesc'], 'Site for testing Joomla CMS'); + $this->fillField(['id' => 'jform_site_metadesc'], 'Site for testing Joomla CMS'); // I get the configuration from acceptance.suite.yml (see: tests/_support/acceptancehelper.php) $this->debug('I fill Admin Email'); - $I->fillField(['id' => 'jform_admin_email'], $this->config['admin email']); + $this->fillField(['id' => 'jform_admin_email'], $this->config['admin email']); $this->debug('I fill Admin Username'); - $I->fillField(['id' => 'jform_admin_user'], $this->config['username']); + $this->fillField(['id' => 'jform_admin_user'], $this->config['username']); $this->debug('I fill Admin Password'); - $I->fillField(['id' => 'jform_admin_password'], $this->config['password']); + $this->fillField(['id' => 'jform_admin_password'], $this->config['password']); $this->debug('I fill Admin Password Confirmation'); - $I->fillField(['id' => 'jform_admin_password2'], $this->config['password']); + $this->fillField(['id' => 'jform_admin_password2'], $this->config['password']); $this->debug('I click Site Offline: no'); // ['No Site Offline'] - $I->click(['xpath' => "//fieldset[@id='jform_site_offline']/label[@for='jform_site_offline1']"]); + $this->click(['xpath' => "//fieldset[@id='jform_site_offline']/label[@for='jform_site_offline1']"]); $this->debug('I click Next'); - $I->click(['link' => 'Next']); + $this->click(['link' => 'Next']); $this->debug('I Fill the form for creating the Joomla site Database'); - $I->waitForText('Database Configuration', TIMEOUT, ['css' => 'h3']); + $this->waitForText('Database Configuration', TIMEOUT, ['css' => 'h3']); $this->debug('I select MySQLi'); - $I->selectOption(['id' => 'jform_db_type'], $this->config['database type']); + $this->selectOption(['id' => 'jform_db_type'], $this->config['database type']); $this->debug('I fill Database Host'); - $I->fillField(['id' => 'jform_db_host'], $this->config['database host']); + $this->fillField(['id' => 'jform_db_host'], $this->config['database host']); $this->debug('I fill Database User'); - $I->fillField(['id' => 'jform_db_user'], $this->config['database user']); + $this->fillField(['id' => 'jform_db_user'], $this->config['database user']); $this->debug('I fill Database Password'); - $I->fillField(['id' => 'jform_db_pass'], $this->config['database password']); + $this->fillField(['id' => 'jform_db_pass'], $this->config['database password']); $this->debug('I fill Database Name'); - $I->fillField(['id' => 'jform_db_name'], $this->config['database name']); + $this->fillField(['id' => 'jform_db_name'], $this->config['database name']); $this->debug('I fill Database Prefix'); - $I->fillField(['id' => 'jform_db_prefix'], $this->config['database prefix']); + $this->fillField(['id' => 'jform_db_prefix'], $this->config['database prefix']); $this->debug('I click Remove Old Database '); - $I->selectOptionInRadioField('Old Database Process', 'Remove'); + $this->selectOptionInRadioField('Old Database Process', 'Remove'); $this->debug('I click Next'); - $I->click(['link' => 'Next']); + $this->click(['link' => 'Next']); $this->debug('I wait Joomla to remove the old database if exist'); - $I->wait(1); - $I->waitForElementVisible(['id' => 'jform_sample_file-lbl'], 30); + $this->wait(1); + $this->waitForElementVisible(['id' => 'jform_sample_file-lbl'], 30); $this->debug('I install joomla with or without sample data'); - $I->waitForText('Finalisation', TIMEOUT, ['xpath' => '//h3']); + $this->waitForText('Finalisation', TIMEOUT, ['xpath' => '//h3']); // @todo: installation of sample data needs to be created // No sample data - $I->selectOption(['id' => 'jform_sample_file'], ['id' => 'jform_sample_file0']); - $I->click(['link' => 'Install']); + $this->selectOption(['id' => 'jform_sample_file'], ['id' => 'jform_sample_file0']); + $this->click(['link' => 'Install']); // Wait while Joomla gets installed $this->debug('I wait for Joomla being installed'); - $I->waitForText('Congratulations! Joomla! is now installed.', TIMEOUT, ['xpath' => '//h3']); + $this->waitForText('Congratulations! Joomla! is now installed.', TIMEOUT, ['xpath' => '//h3']); } /** * Install Joomla removing the Installation folder at the end of the execution * * @return void + * @since 3.0.0 */ public function installJoomlaRemovingInstallationFolder() { - $I = $this; - - $I->installJoomla(); + $this->installJoomla(); $this->debug('Removing Installation Folder'); - $I->click(['xpath' => "//input[@value='Remove installation folder']"]); + $this->click(['xpath' => "//input[@value='Remove installation folder']"]); - $I->debug('I wait for Removing Installation Folder button to become disabled'); - $I->waitForJS("return jQuery('form#adminForm input[name=instDefault]').attr('disabled') == 'disabled';", TIMEOUT); + $this->debug('I wait for Removing Installation Folder button to become disabled'); + $this->waitForJS("return jQuery('form#adminForm input[name=instDefault]').attr('disabled') == 'disabled';", TIMEOUT); - $I->debug('Joomla is now installed'); - $I->see('Congratulations! Joomla! is now installed.', ['xpath' => '//h3']); + $this->debug('Joomla is now installed'); + $this->see('Congratulations! Joomla! is now installed.', ['xpath' => '//h3']); } /** @@ -284,9 +303,10 @@ public function installJoomlaRemovingInstallationFolder() * * @param array $languages Array containing the language names to be installed * - * @example: $I->installJoomlaMultilingualSite(['Spanish', 'French']); + * @example: $this->installJoomlaMultilingualSite(['Spanish', 'French']); * * @return void + * @since 3.0.0 */ public function installJoomlaMultilingualSite($languages = array()) { @@ -296,61 +316,60 @@ public function installJoomlaMultilingualSite($languages = array()) $languages[] = 'French'; } - $I = $this; - - $I->installJoomla(); + $this->installJoomla(); $this->debug('I go to Install Languages page'); - $I->click(['id' => 'instLangs']); - $I->waitForText('Install Language packages', TIMEOUT, ['xpath' => '//h3']); + $this->click(['id' => 'instLangs']); + $this->waitForText('Install Language packages', TIMEOUT, ['xpath' => '//h3']); foreach ($languages as $language) { - $I->debug('I mark the checkbox of the language: ' . $language); - $I->click(['xpath' => "//label[contains(text()[normalize-space()], '$language')]"]); + $this->debug('I mark the checkbox of the language: ' . $language); + $this->click(['xpath' => "//label[contains(text()[normalize-space()], '$language')]"]); } - $I->click(['link' => 'Next']); - $I->waitForText('Multilingual', TIMEOUT, ['xpath' => '//h3']); - $I->selectOptionInRadioField('Activate the multilingual feature', 'Yes'); - $I->waitForElementVisible(['id' => 'jform_activatePluginLanguageCode-lbl']); - $I->selectOptionInRadioField('Install localised content', 'Yes'); - $I->selectOptionInRadioField('Enable the language code plugin', 'Yes'); - $I->click(['link' => 'Next']); + $this->click(['link' => 'Next']); + $this->waitForText('Multilingual', TIMEOUT, ['xpath' => '//h3']); + $this->selectOptionInRadioField('Activate the multilingual feature', 'Yes'); + $this->waitForElementVisible(['id' => 'jform_activatePluginLanguageCode-lbl']); + $this->selectOptionInRadioField('Install localised content', 'Yes'); + $this->selectOptionInRadioField('Enable the language code plugin', 'Yes'); + $this->click(['link' => 'Next']); - $I->waitForText('Congratulations! Joomla! is now installed.', TIMEOUT, ['xpath' => '//h3']); + $this->waitForText('Congratulations! Joomla! is now installed.', TIMEOUT, ['xpath' => '//h3']); $this->debug('Removing Installation Folder'); - $I->click(['xpath' => "//input[@value='Remove installation folder']"]); + $this->click(['xpath' => "//input[@value='Remove installation folder']"]); // @todo https://github.com/joomla-projects/joomla-browser/issues/45 - $I->wait(2); + $this->wait(2); $this->debug('Joomla is now installed'); - $I->see('Congratulations! Joomla! is now installed.', ['xpath' => '//h3']); + $this->see('Congratulations! Joomla! is now installed.', ['xpath' => '//h3']); } /** - * Sets in Adminitrator->Global Configuration the Error reporting to Development + * Sets in Administrator->Global Configuration the Error reporting to Development * {@internal doAdminLogin() before} * * @return void + * + * @since 3.0.0 */ public function setErrorReportingToDevelopment() { - $I = $this; $this->debug('I open Joomla Global Configuration Page'); - $I->amOnPage('/administrator/index.php?option=com_config'); + $this->amOnPage('/administrator/index.php?option=com_config'); $this->debug('I wait for Global Configuration title'); - $I->waitForText('Global Configuration', TIMEOUT, ['css' => '.page-title']); + $this->waitForText('Global Configuration', TIMEOUT, ['css' => '.page-title']); $this->debug('I open the Server Tab'); - $I->click(['link' => 'Server']); + $this->click(['link' => 'Server']); $this->debug('I wait for error reporting dropdown'); - $I->selectOptionInChosen('Error Reporting', 'Development'); + $this->selectOptionInChosen('Error Reporting', 'Development'); $this->debug('I click on save'); - $I->click(['xpath' => "//div[@id='toolbar-apply']//button"]); + $this->click(['xpath' => "//div[@id='toolbar-apply']//button"]); $this->debug('I wait for global configuration being saved'); - $I->waitForText('Global Configuration', TIMEOUT, ['css' => '.page-title']); - $I->see('Configuration saved.', ['id' => 'system-message-container']); + $this->waitForText('Global Configuration', TIMEOUT, ['css' => '.page-title']); + $this->see('Configuration saved.', ['id' => 'system-message-container']); } /** @@ -363,7 +382,9 @@ public function setErrorReportingToDevelopment() * * @deprecated since Joomla 3.4.4-dev. Use installExtensionFromFolder($path, $type = 'Extension') instead. * - * @return void + * @return void + * + * @since 3.0.0 */ public function installExtensionFromDirectory($path, $type = 'Extension') { @@ -380,17 +401,19 @@ public function installExtensionFromDirectory($path, $type = 'Extension') * {@internal doAdminLogin() before} * * @return void + * + * @since 3.0.0 */ public function installExtensionFromFolder($path, $type = 'Extension') { - $I = $this; - $I->amOnPage('/administrator/index.php?option=com_installer'); - $I->waitForText('Extensions: Install', '30', ['css' => 'H1']); - $I->click(['link' => 'Install from Folder']); + + $this->amOnPage('/administrator/index.php?option=com_installer'); + $this->waitForText('Extensions: Install', '30', ['css' => 'H1']); + $this->click(['link' => 'Install from Folder']); $this->debug('I enter the Path'); - $I->fillField(['id' => 'install_directory'], $path); - $I->click(['id' => 'installbutton_directory']); - $I->waitForText('was successful', 'TIMEOUT', ['id' => 'system-message-container']); + $this->fillField(['id' => 'install_directory'], $path); + $this->click(['id' => 'installbutton_directory']); + $this->waitForText('was successful', 'TIMEOUT', ['id' => 'system-message-container']); $this->debug("$type successfully installed from $path"); } @@ -403,17 +426,18 @@ public function installExtensionFromFolder($path, $type = 'Extension') * {@internal doAdminLogin() before} * * @return void + * + * @since 3.0.0 */ public function installExtensionFromUrl($url, $type = 'Extension') { - $I = $this; - $I->amOnPage('/administrator/index.php?option=com_installer'); - $I->waitForText('Extensions: Install', '30', ['css' => 'H1']); - $I->click(['link' => 'Install from URL']); + $this->amOnPage('/administrator/index.php?option=com_installer'); + $this->waitForText('Extensions: Install', '30', ['css' => 'H1']); + $this->click(['link' => 'Install from URL']); $this->debug('I enter the url'); - $I->fillField(['id' => 'install_url'], $url); - $I->click(['id' => 'installbutton_url']); - $I->waitForText('was successful', '30', ['id' => 'system-message-container']); + $this->fillField(['id' => 'install_url'], $url); + $this->click(['id' => 'installbutton_url']); + $this->waitForText('was successful', '30', ['id' => 'system-message-container']); if ($type == 'Extension') { @@ -439,23 +463,23 @@ public function installExtensionFromUrl($url, $type = 'Extension') * {@internal doAdminLogin() before} * * @return void + * + * @since 3.0.0 */ public function checkForPhpNoticesOrWarnings($page = null) { - $I = $this; - if ($page) { - $I->amOnPage($page); + $this->amOnPage($page); } - $I->dontSeeInPageSource('Notice:'); - $I->dontSeeInPageSource('Notice:'); - $I->dontSeeInPageSource('Warning:'); - $I->dontSeeInPageSource('Warning:'); - $I->dontSeeInPageSource('Strict standards:'); - $I->dontSeeInPageSource('Strict standards:'); - $I->dontSeeInPageSource('The requested page can\'t be found'); + $this->dontSeeInPageSource('Notice:'); + $this->dontSeeInPageSource('Notice:'); + $this->dontSeeInPageSource('Warning:'); + $this->dontSeeInPageSource('Warning:'); + $this->dontSeeInPageSource('Strict standards:'); + $this->dontSeeInPageSource('Strict standards:'); + $this->dontSeeInPageSource('The requested page can\'t be found'); } /** @@ -465,15 +489,17 @@ public function checkForPhpNoticesOrWarnings($page = null) * @param string $option The text in the