From 379f5c2f70f2821c9efa9a8742aac7fdec579c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Escobar=20Gonz=C3=A1lez?= Date: Tue, 21 Jul 2015 10:11:38 +0200 Subject: [PATCH 1/3] Adding function to install languages through the interface. --- src/JoomlaBrowser.php | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 6f11a45..3f28526 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -256,7 +256,7 @@ public function installExtensionFromDirectory($path, $type = 'Extension') if ($type == 'Plugin') { $this->debug('Installing plugin was successful.' . $path); - } + } } /** @@ -314,7 +314,7 @@ public function selectOptionInChosen($label, $option) /** * Function to Logout from Administrator Panel in Joomla! - * + * * @return void */ public function doAdministratorLogout() @@ -439,4 +439,41 @@ public function checkAllResults() $this->debug("Selecting Checkall button"); $I->click(['xpath' => "//thead//input[@name='checkall-toggle' or @name='toggle']"]); } + + /** + * Function to install a language through the interface + * + * @param string $languageName Name of the language you want to install + * + * @return void + */ + public function installLanguage($languageName) + { + $I = $this; + $I->amOnPage('administrator/index.php?option=com_installer&view=languages'); + $this->debug('I check for Notices and Warnings'); + $this->checkForPhpNoticesOrWarnings(); + $this->debug('Refreshing languages'); + $I->click(['xpath' => "//*[@id=\"toolbar-refresh\"]/button"]); + $I->searchForItem($languageName); + $I->waitForElement($this->searchResultLanguageName($languageName), 30); + $I->click(['xpath' => "//input[@id='cb0']"]); + $I->click(['xpath' => "//*[@id=\"toolbar-upload\"]/button"]); + $I->see('was successful.', ['id' => 'system-message-container']); + $this->debug($languageName . ' successfully installed'); + } + + /** + * Function to return Path for the Language Name to be searched for + * + * @param String $languageName Name of the language + * + * @return string + */ + private function searchResultLanguageName($languageName) + { + $xpath = "//*[@id=\"j-main-container\"]/table/tbody/tr[1]/td[2]/label[contains(text(),'" . $languageName . "')]"; + + return $xpath; + } } From 6f27d331d84719b0b58653f82212645823205bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Escobar=20Gonz=C3=A1lez?= Date: Tue, 21 Jul 2015 10:14:23 +0200 Subject: [PATCH 2/3] Adding function to install languages through the interface. --- src/JoomlaBrowser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 3f28526..78744cf 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -459,7 +459,7 @@ public function installLanguage($languageName) $I->waitForElement($this->searchResultLanguageName($languageName), 30); $I->click(['xpath' => "//input[@id='cb0']"]); $I->click(['xpath' => "//*[@id=\"toolbar-upload\"]/button"]); - $I->see('was successful.', ['id' => 'system-message-container']); + $I->waitForText('was successful.',30,['id' => 'system-message-container']); $this->debug($languageName . ' successfully installed'); } From 2ce736a55aa99dd73c7cbe1338c2abb52af9c73d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Escobar=20Gonz=C3=A1lez?= Date: Tue, 21 Jul 2015 10:47:21 +0200 Subject: [PATCH 3/3] Adding some improvements to the install language function. --- src/JoomlaBrowser.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 78744cf..05be1e7 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -455,11 +455,13 @@ public function installLanguage($languageName) $this->checkForPhpNoticesOrWarnings(); $this->debug('Refreshing languages'); $I->click(['xpath' => "//*[@id=\"toolbar-refresh\"]/button"]); + $I->waitForElement(['id' => 'j-main-container'], 30); $I->searchForItem($languageName); $I->waitForElement($this->searchResultLanguageName($languageName), 30); - $I->click(['xpath' => "//input[@id='cb0']"]); - $I->click(['xpath' => "//*[@id=\"toolbar-upload\"]/button"]); - $I->waitForText('was successful.',30,['id' => 'system-message-container']); + $I->click(['id' => "cb0"]); + $I->click(['xpath' => "//*[@id='toolbar-upload']/button"]); + $I->waitForText('was successful.', 30, ['id' => 'system-message-container']); + $I->see('No Matching Results',['class' => 'alert-no-items']); $this->debug($languageName . ' successfully installed'); } @@ -472,7 +474,7 @@ public function installLanguage($languageName) */ private function searchResultLanguageName($languageName) { - $xpath = "//*[@id=\"j-main-container\"]/table/tbody/tr[1]/td[2]/label[contains(text(),'" . $languageName . "')]"; + $xpath = "//form[@id='adminForm']/div/table/tbody/tr[1]/td[2]/label[contains(text(),'" . $languageName . "')]"; return $xpath; }