Example #1
0
 public function testCreateMenuItem()
 {
     $d = $this->driver;
     $cpPage = $this->doAdminLogin();
     // 		$genericPage = new GenericAdminPage($d, $this);
     $genericPage = $cpPage->clickMenu('Menu Manager');
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('Main Menu'));
     echo "found Main Menu";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('New'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[contains(@onclick, 'iframe')]"));
     echo "found select button";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     // switch to modal iframe
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Single Article'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[@value='Single Article']"));
     $salt = mt_rand();
     $d->findElement(By::id('jform_title'))->sendKeys('Test Menu Title ' . $salt);
     $el = $d->findElement(By::partialLinkText('Select / Change'))->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Australian Parks'));
     $text = $d->findElement(By::xPath("//body"))->getText();
     $this->assertTrue(strpos($text, '( ! ) Notice:') === false, '**PHP notice found on page.');
     $el->click();
     $el = $d->waitForElementUntilIsNotPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $d->findElement(By::xPath("//a[contains(@onclick, 'item.save')]"))->click();
     // Clean up
 }
Example #2
0
 public function testTinyTyping()
 {
     $d = $this->_driver;
     //get url
     $d->get($this->_testUrl . '/administrator');
     //access text input
     $webElement = $d->findElement(By::id("mod-login-username"));
     $webElement->clear();
     $webElement->sendKeys("admin");
     $webElement = $d->findElement(By::id("mod-login-password"));
     $webElement->clear();
     $webElement->sendKeys("password");
     //access button
     $d->findElement(By::partialLinkText("Log in"))->click();
     $d->waitForElementUntilIsPresent(By::partialLinkText('Add New Article'))->click();
     $salt = mt_rand();
     $d->waitForElementUntilIsPresent(By::id('jform_title'))->sendKeys('Article Title ' . $salt);
     $d->switchTo()->getFrameByName('jform_articletext_ifr');
     $d->findElement(By::id('tinymce'))->sendKeys('This is some article text.');
     $d->switchTo()->getDefaultFrame();
     $d->findElement(By::xPath("//a[contains(@onclick, 'article.save')]"))->click();
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('Article Title ' . $salt));
     $this->assertInstanceOf('SeleniumClient\\WebElement', $el);
     $el->click();
     $d->waitForElementUntilIsPresent(By::id('jform_title'));
     $select = new SelectElement($d->findElement(By::id("jform_state")));
     $select->selectByValue("2");
     $select = new SelectElement($d->findElement(By::id("jform_featured")));
     $select->selectByValue("1");
     sleep(5);
     // Clean up
 }
Example #3
0
 public function testDemo1()
 {
     //get url
     $this->_driver->get($this->_testUrl);
     //access text input
     $webElement = $this->_driver->findElement(By::id("txt1"));
     $webElement->clear();
     $webElement->sendKeys("Text sent 1");
     $this->assertEquals("Text sent 1", $webElement->getAttribute("value"));
     $webElement = $this->_driver->findElement(By::id("txt2"));
     $webElement->clear();
     $webElement->sendKeys("Text sent 2");
     $this->assertEquals("Text sent 2", $webElement->getAttribute("value"));
     //access listbox
     $selectElement = new SelectElement($this->_driver->findElement(By::id("sel1")));
     $selectElement->selectByValue("4");
     $this->assertTrue($selectElement->getElement()->findElement(By::xPath(".//option[@value = 4]"))->isSelected());
     //access checkbox
     $webElement = $this->_driver->findElement(By::cssSelector("html body table tbody tr td fieldset form p input#chk3"));
     $webElement->click();
     $this->assertTrue($webElement->isSelected());
     //access radio
     $webElement = $this->_driver->findElement(By::id("rd3"));
     $webElement->click();
     $this->assertTrue($webElement->isSelected());
     //access button
     $webElement = $this->_driver->findElement(By::id("btnSubmit"));
     $webElement->click();
     //access h2
     $webElement = $this->_driver->findElement(By::cssSelector("html body h2#h2FormReceptor"));
     $this->assertEquals("Form receptor", $webElement->getText());
     sleep(20);
 }
 /**
  * Login to back end and navigate to menu Language Manager.
  *
  * @since   3.0
  */
 public function setUp()
 {
     parent::setUp();
     $cpPage = $this->doAdminLogin();
     $this->tagManagerPage = $cpPage->clickMenu('Language Manager', 'LanguageManagerPage');
     $this->driver->findElement(By::xPath("//ul/li/a[@href='index.php?option=com_languages&view=languages']"))->click();
 }
Example #5
0
 /**
  * Function to enter Username Password
  * 
  * @param string   $username	Username of the user
  * @param string   $password	Password of the user    
  * @return  void
  *
  */
 public function SiteLoginUser($username, $password)
 {
     $d = $this->driver;
     $d->findElement(By::xPath("//input[@id='username']"))->sendKeys($username);
     $d->findElement(By::xPath("//input[@id='password']"))->sendKeys($password);
     $d->findElement(By::xPath("//button[contains(text(), 'Log in')]"))->click();
 }
Example #6
0
 /**
  * @test
  */
 public function createMenuItem()
 {
     $cpPage = $this->doAdminLogin();
     $page = $cpPage->clickMenu('Main Menu');
     $page->clickButton('New');
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('New'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[contains(@onclick, 'iframe')]"));
     echo "found select button";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     // switch to modal iframe
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Single Article'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[@value='Single Article']"));
     $salt = mt_rand();
     $d->findElement(By::id('jform_title'))->sendKeys('Test Menu Title ' . $salt);
     $el = $d->findElement(By::partialLinkText('Select / Change'))->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Australian Parks'));
     $el->click();
     $el = $d->waitForElementUntilIsNotPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $d->findElement(By::xPath("//a[contains(@onclick, 'item.save')]"))->click();
     // Clean up
 }
 public function testUntilShouldWaitShouldThrowException()
 {
     $this->setExpectedException('SeleniumClient\\WebDriverWaitTimeoutException');
     $this->_driver->findElement(By::id("btnAppendDiv"))->click();
     $wait = new WebDriverWait(3);
     $label = $wait->until($this->_driver, "findElement", array(By::id("dDiv1-0"), true));
 }
Example #8
0
 public function testDemo2()
 {
     //click button/get alert text
     $this->_driver->get($this->_testUrl);
     $this->_driver->findElement(By::id("btnAlert"))->click();
     $this->assertEquals("Here is the alert", $this->_driver->getAlertText());
     $this->_driver->acceptAlert();
     //get main window handle
     $mainWindowHandle = $this->_driver->getCurrentWindowHandle();
     //open popup window / handle its elements
     $this->_driver->findElement(By::id("btnPopUp1"))->click();
     $this->_driver->switchTo()->getWindow("popup1");
     $webElement = $this->_driver->waitForElementUntilIsPresent(By::id("txt1"));
     $webElement->sendKeys("test window");
     $this->assertEquals("test window", $webElement->getAttribute("value"));
     $this->_driver->closeCurrentWindow();
     $this->_driver->switchTo()->getWindow($mainWindowHandle);
     //get iframe / handle its elements
     $this->_driver->getFrame("iframe1");
     $webElement = $this->_driver->waitForElementUntilIsPresent(By::id("txt1"));
     $webElement->sendKeys("test iframe");
     $this->assertEquals("test iframe", $webElement->getAttribute("value"));
     $this->_driver->switchTo()->getWindow($mainWindowHandle);
     //wait for element to be present
     $this->_driver->findElement(By::id("btnAppendDiv"))->click();
     $wait = new WebDriverWait(8);
     $label = $wait->until($this->_driver, "findElement", array(By::id("dDiv1-0"), true));
     $this->assertEquals("Some content", $label->getText());
     sleep(5);
 }
 public function deleteLevel($name)
 {
     $this->searchFor($name);
     $this->driver->findElement(By::name("checkall-toggle"))->click();
     $this->clickButton('toolbar-delete');
     $this->driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath));
     $this->searchFor();
 }
 public function testGetAlertShouldSendKeysToAlert()
 {
     $this->_driver->get($this->_url);
     $this->_driver->findElement(By::id("btnPrompt"))->click();
     $this->_alert->sendKeys("alert text");
     $this->_alert->accept();
     $alertText = $this->_alert->getText();
     $this->assertEquals("alert text", $alertText);
 }
 /**
  * Function which checks of edit icon is ppresent on the page or not
  *
  * @return True or Flase
  */
 public function isEditPresent()
 {
     $arrayElement = $this->driver->findElements(By::xPath("//a[contains(text(), 'Edit')]"));
     if (count($arrayElement > 0)) {
         return true;
     } else {
         return false;
     }
 }
Example #12
0
 public function getTabIds()
 {
     $tabs = $this->driver->findElements(By::xPath("//div[@class='tab-content'][@id='myTabContent']/div"));
     $return = array();
     foreach ($tabs as $tab) {
         $return[] = $tab->getAttribute('id');
     }
     return $return;
 }
Example #13
0
 protected function getModuleType()
 {
     $elements = $this->driver->findElements(By::xPath("//span[@class = 'label']"));
     if (count($elements >= 2)) {
         return $elements[1]->getText();
     } else {
         return false;
     }
 }
 /**
  * Function which returns Title array of Articles on the Home page of Front End
  *
  *
  * @return  Array of Article Titles Visible
  */
 public function getArticleTitles()
 {
     $arrayElement = $this->driver->findElements(By::xPath("//h2//a[contains(text(), '')]"));
     $arrayTitles = array();
     for ($i = 0; $i < count($arrayElement); $i++) {
         $arrayTitles[$i] = $arrayElement[$i]->getText();
     }
     return $arrayTitles;
 }
 /**
  * Clears post-installation messages by navigating to that screen and back
  *
  * @return  null
  */
 public function clearInstallMessages()
 {
     $clearButtons = $this->driver->findElements(By::xPath("//a[contains(text(), 'Hide this message')]"));
     while (count($clearButtons) > 0) {
         $clearButtons[0]->click();
         $page = $this->test->getPageObject('PostinstallPage');
         $clearButtons = $this->driver->findElements(By::xPath("//a[contains(text(), 'Hide this message')]"));
     }
 }
 public function deleteStyle($name)
 {
     $this->searchFor($name);
     $row_number = $this->getRowNumber($name) - 1;
     $el = $this->driver->findElement(By::xPath(".//input[@id='cb" . $row_number . "']"));
     $el->click();
     $this->clickButton('toolbar-delete');
     $this->driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath));
 }
 /**
  * Function which changes the articles texts and returns back to the siteContentFeaturedPage after saving the changes
  *
  * @var string articleText
  *
  * @return  null
  */
 public function editArticle($articleText)
 {
     $d = $this->driver;
     $guiEditor = $this->driver->findElement(By::xPath("//a[contains(@onclick, 'mceToggleEditor')]"));
     $guiEditor->click();
     $d->findElement(By::xPath("//textarea[@id='jform_articletext']"))->clear();
     $d->findElement(By::xPath("//textarea[@id='jform_articletext']"))->sendKeys($articleText);
     $d->findElement(By::xPath("//button[@type='button'][@class='btn btn-primary']"))->click();
 }
 public function getFieldValue($label)
 {
     $result = false;
     if ($label == 'ID') {
         $result = $this->driver->findElement(By::id('jform_user_id'))->getAttribute('value');
     } else {
         $result = parent::getFieldValue($label);
     }
     return $result;
 }
 public function testSelectByPartialTextShouldSelect()
 {
     $this->_driver->get($this->_url);
     $select = new SelectElement($this->_driver->findElement(By::id("sel1")));
     $select->selectByPartialText("Red");
     $this->assertTrue($select->getElement()->findElement(By::xPath("option[@value = 2]"))->isSelected());
     $select = new SelectElement($this->_driver->findElement(By::id("sel2")));
     $select->selectByPartialText("peppers");
     $this->assertTrue($select->getElement()->findElement(By::xPath("option[@value = 'greenpeppers']"))->isSelected());
 }
 /**
  * Gets the titles of modules in sliders
  *
  * @return  array of stdClass objects
  */
 public function getModuleTitles()
 {
     $container = $this->driver->findElement(By::Id('panel-sliders'));
     $elements = $container->findElements(By::tagName('h3'));
     $return = array();
     foreach ($elements as $element) {
         $object = new stdClass();
         $object->text = $element->getText();
     }
 }
Example #21
0
 /**
  * @test
  */
 public function getAllInputFields_ScreenDisplayed_EqualExpected()
 {
     $this->moduleManagerPage->clickButton('toolbar-new');
     $this->driver->waitForElementUntilIsPresent(By::xPath("//a[contains(., 'Articles Categories')]"))->click();
     $moduleEditPage = $this->getPageObject('ModuleEditPage');
     $testElements = $moduleEditPage->getAllInputFields($moduleEditPage->tabs);
     $actualFields = $this->getActualFieldsFromElements($testElements);
     $this->assertEquals($moduleEditPage->inputFields, $actualFields);
     $moduleEditPage->clickButton('toolbar-cancel');
     $this->moduleManagerPage = $this->getPageObject('ModuleManagerPage');
 }
Example #22
0
 private function executeLogin($userName, $password)
 {
     $webElement = $this->driver->findElement(By::id("mod-login-username"));
     $webElement->clear();
     $webElement->sendKeys($this->cfg->username);
     $webElement = $this->driver->findElement(By::id("mod-login-password"));
     $webElement->clear();
     $webElement->sendKeys($this->cfg->password);
     //access button
     $this->driver->findElement(By::xPath("//button[contains(., 'Log in')]"))->click();
 }
 public function getAllInputFields($tabIds = array())
 {
     $return = array();
     $labels = $this->driver->findElements(By::xPath("//fieldset/div[@class='control-group']/div/label"));
     $tabId = 'none';
     foreach ($labels as $label) {
         if (($inputField = $this->getInputField($tabId, $label)) !== false) {
             $return[] = $inputField;
         }
     }
     return $return;
 }
 public function getState($name)
 {
     $result = false;
     $row = $this->getRowNumber($name);
     $text = $this->driver->findElement(By::xPath("//tbody/tr[" . $row . "]/td[4]/a"))->getAttribute(@onclick);
     if (strpos($text, 'users.unblock') > 0) {
         $result = 'unpublished';
     }
     if (strpos($text, 'users.block') > 0) {
         $result = 'published';
     }
     return $result;
 }
 public function deleteUserNotes($name)
 {
     $this->searchFor($name);
     $this->userNotesManagerPage->checkAll();
     $this->clickButton('toolbar-trash');
     $this->driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath));
     $this->searchFor();
     $this->setFilter('Status', 'Trashed');
     $this->userNotesManagerPage->checkAll();
     $this->clickButton('Empty trash');
     $this->driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath));
     $this->setFilter('Status', 'Select Status');
     $this->driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath));
 }
Example #26
0
 public function setGroups(array $groupNames)
 {
     if (count($groupNames) == 0) {
         return;
     }
     // Uncheck any checked boxes
     $elements = $this->driver->findElements(By::xPath("//input[@checked='checked']"));
     foreach ($elements as $el) {
         $el->click();
     }
     foreach ($groupNames as $name) {
         $this->driver->findElement(By::xPath("//label[contains(., '{$name}')]"))->click();
     }
 }
Example #27
0
 /**
  * constructor function
  *
  * @param   Webdriver                 $driver  Driver for this test.
  * @param   JoomlaWebdriverTestClass  $test    Test class object (needed to create page class objects)
  * @param   string                    $url     Optional URL to load when object is created. Only use for initial page load.
  */
 public function __construct(Webdriver $driver, $test, $url = null)
 {
     $this->driver = $driver;
     /* @var $test JoomlaWebdriverTestCase */
     $this->test = $test;
     $cfg = new SeleniumConfig();
     // Save current configuration
     $this->cfg = $cfg;
     if ($url) {
         $this->driver->get($url);
     }
     $element = $driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath), 5);
     if (isset($this->url)) {
         $test->assertContains($this->url, $driver->getCurrentPageUrl(), 'URL for page does not match expected value.');
     }
 }
Example #28
0
 public function testCreateMenuItem()
 {
     //get url
     $this->_driver->get($this->_testUrl . '/administrator');
     //access text input
     $webElement = $this->_driver->findElement(By::id("mod-login-username"));
     $webElement->clear();
     $webElement->sendKeys("admin");
     $webElement = $this->_driver->findElement(By::id("mod-login-password"));
     $webElement->clear();
     $webElement->sendKeys("password");
     //access button
     $this->_driver->findElement(By::partialLinkText("Log in"))->click();
     $d = $this->_driver;
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('Menu Manager'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('Main Menu'));
     echo "found Main Menu";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('New'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[contains(@onclick, 'iframe')]"));
     echo "found select button";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     // switch to modal iframe
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Single Article'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[@value='Single Article']"));
     $salt = mt_rand();
     $d->findElement(By::id('jform_title'))->sendKeys('Test Menu Title ' . $salt);
     $el = $d->findElement(By::partialLinkText('Select / Change'))->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Australian Parks'));
     $el->click();
     $el = $d->waitForElementUntilIsNotPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $d->findElement(By::xPath("//a[contains(@onclick, 'item.save')]"))->click();
     // Clean up
 }
Example #29
0
 public function install($cfg)
 {
     $this->setField('Site Name', $cfg->site_name);
     $this->setField('Your Email', $cfg->admin_email);
     $this->setField('Admin Username', $cfg->username);
     $this->setField('Admin Password', $cfg->password);
     $this->setField('Confirm Admin Password', $cfg->password);
     $this->driver->findElement(By::xPath("//li[@id='database']/a"))->click();
     $this->driver->waitForElementUntilIsPresent(By::xPath("//li[@id='database'][@class='step active']"));
     $this->setDatabaseType($cfg->db_type);
     $this->setField('Host Name', $cfg->db_host);
     $this->setField('Username', $cfg->db_user);
     $this->setField('Password', $cfg->db_pass);
     $this->setField('Database Name', $cfg->db_name);
     $this->setField('Table Prefix', $cfg->db_prefix);
     $this->driver->findElement(By::xPath("//label[@for='jform_db_old1']"))->click();
     $this->driver->findElement(By::xPath("//li[@id='summary']/a"))->click();
     $this->driver->waitForElementUntilIsPresent(By::xPath("//li[@id='summary'][@class='step active']"));
     if ($cfg->sample_data && isset($cfg->sample_data_file)) {
         $this->setSampleData($cfg->sample_data_file);
     } else {
         $this->setSampleData('None');
     }
     $this->driver->findElement(By::xPath("//a[@title='Install']"))->click();
     $this->driver->waitForElementUntilIsPresent(By::xPath("//input[contains(@onclick, 'Install.removeFolder')]"), 60);
 }
 /**
  * Function which returns the meta description
  *
  * @return  string   Meta description
  */
 public function getMetaDescription()
 {
     $d = $this->driver;
     return $d->findElement(By::xPath("//textarea[@id='jform_MetaDesc']"))->getText();
 }