@@ -347,7 +347,7 @@ public function selectOptionInChosen($label, $option)
347347
348348 /**
349349 * Function to Logout from Administrator Panel in Joomla!
350- *
350+ *
351351 * @return void
352352 */
353353 public function doAdministratorLogout ()
@@ -472,4 +472,43 @@ public function checkAllResults()
472472 $ this ->debug ("Selecting Checkall button " );
473473 $ I ->click (['xpath ' => "//thead//input[@name='checkall-toggle' or @name='toggle'] " ]);
474474 }
475+
476+ /**
477+ * Function to install a language through the interface
478+ *
479+ * @param string $languageName Name of the language you want to install
480+ *
481+ * @return void
482+ */
483+ public function installLanguage ($ languageName )
484+ {
485+ $ I = $ this ;
486+ $ I ->amOnPage ('administrator/index.php?option=com_installer&view=languages ' );
487+ $ this ->debug ('I check for Notices and Warnings ' );
488+ $ this ->checkForPhpNoticesOrWarnings ();
489+ $ this ->debug ('Refreshing languages ' );
490+ $ I ->click (['xpath ' => "//*[@id= \"toolbar-refresh \"]/button " ]);
491+ $ I ->waitForElement (['id ' => 'j-main-container ' ], 30 );
492+ $ I ->searchForItem ($ languageName );
493+ $ I ->waitForElement ($ this ->searchResultLanguageName ($ languageName ), 30 );
494+ $ I ->click (['id ' => "cb0 " ]);
495+ $ I ->click (['xpath ' => "//*[@id='toolbar-upload']/button " ]);
496+ $ I ->waitForText ('was successful. ' , 30 , ['id ' => 'system-message-container ' ]);
497+ $ I ->see ('No Matching Results ' ,['class ' => 'alert-no-items ' ]);
498+ $ this ->debug ($ languageName . ' successfully installed ' );
499+ }
500+
501+ /**
502+ * Function to return Path for the Language Name to be searched for
503+ *
504+ * @param String $languageName Name of the language
505+ *
506+ * @return string
507+ */
508+ private function searchResultLanguageName ($ languageName )
509+ {
510+ $ xpath = "//form[@id='adminForm']/div/table/tbody/tr[1]/td[2]/label[contains(text(),' " . $ languageName . "')] " ;
511+
512+ return $ xpath ;
513+ }
475514}
0 commit comments