Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions src/JoomlaBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function installExtensionFromDirectory($path, $type = 'Extension')
if ($type == 'Plugin')
{
$this->debug('Installing plugin was successful.' . $path);
}
}
}

/**
Expand Down Expand Up @@ -314,7 +314,7 @@ public function selectOptionInChosen($label, $option)

/**
* Function to Logout from Administrator Panel in Joomla!
*
*
* @return void
*/
public function doAdministratorLogout()
Expand Down Expand Up @@ -439,4 +439,43 @@ 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"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, Please update the xpath to be more specific

//* is not the best way to do it.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after the click I suggest a waitForElement, because the Refresh function could take time, isn't it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javigomez I've added waitforElement after clicking on the refresh button

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@puneet0191 I don't think this xpath can be more specific, actually it's same used on other method.

//*[@id=\"toolbar-refresh\"]/button

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues, I will clean the code.

Thanks :)

$I->waitForElement(['id' => 'j-main-container'], 30);
$I->searchForItem($languageName);
$I->waitForElement($this->searchResultLanguageName($languageName), 30);
$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');
}

/**
* 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 = "//form[@id='adminForm']/div/table/tbody/tr[1]/td[2]/label[contains(text(),'" . $languageName . "')]";

return $xpath;
}
}