예제 #1
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);
 }
예제 #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
 }
예제 #3
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));
 }
예제 #5
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
 }
예제 #6
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);
 }
예제 #7
0
 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);
 }
 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());
 }
 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;
 }
예제 #10
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();
 }
예제 #11
0
 /**
  * Gets all module types available
  *
  * @return  array  associative array of 'site' or 'administrator' => module name
  */
 public function getModuleTypes()
 {
     $result = array();
     $clients = array('Site', 'Administrator');
     foreach ($clients as $client) {
         $this->setFilter('filter_client_id', $client);
         $this->clickButton('toolbar-new');
         $this->driver->waitForElementUntilIsPresent(By::xPath("//h2[contains(., 'Select a Module Type')]"));
         $el = $this->driver->findElement(By::id('new-modules-list'));
         $moduleElements = $el->findElements(By::xPath("//a/strong"));
         foreach ($moduleElements as $element) {
             $result[] = array('client' => strtolower($client), 'name' => $element->getText());
         }
         $this->driver->findElement(By::xPath("//button[contains(., 'Cancel')]"))->click();
         $moduleManagerPage = $this->test->getPageObject('ModuleManagerPage');
     }
     return $result;
 }
예제 #12
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
 }
예제 #13
0
 public function searchFor($search = false)
 {
     if ($search) {
         $el = $this->driver->findElement(By::id('filter_search'));
         $el->clear();
         $el->sendKeys($search);
         $this->driver->findElement(By::xPath("//button[@data-original-title='Search' or @title='Search']"))->click();
     } else {
         $this->driver->findElement(By::xPath("//div[@id='filter-bar']//button[@title='Clear' or @title='Reset' or @data-original-title='Reset']"))->click();
     }
     return $this->test->getPageObject(get_class($this));
 }
예제 #14
0
 /**
  * Gets array of visible links in the menu container
  * This is normally the header menu for back-end manager screens
  *
  * @return  array of stdClass objects
  */
 public function getVisibleMenuLinks()
 {
     $menuContainer = $this->driver->findElement(By::id('menu'));
     $menus = $menuContainer->findElements(By::tagName('a'));
     $return = array();
     foreach ($menus as $menu) {
         if ($text = $menu->getText()) {
             $menuObject = new stdClass();
             $menuObject->text = $text;
             $menuObject->href = $menu->getAttribute('href');
             $menuObject->id = $menu->getElementId();
             $return[] = $menuObject;
         }
     }
     return $return;
 }
예제 #15
0
 /**
  * function to set request variable
  *
  * @param   string   $value stores  value
  *
  * @return void
  */
 public function setRequestVariable($value)
 {
     $this->selectTab('Details');
     $d = $this->driver;
     $d->findElement(By::xPath("//a[contains(@class, 'modal btn')][contains(@rel, 'iframe')]"))->click();
     $frameElement = $d->waitForElementUntilIsPresent(By::xPath("//iframe[contains(@src, 'layout=modal')]"));
     $d->switchTo()->getFrameByWebElement($frameElement);
     $filter = $d->waitForElementUntilIsPresent(By::id('filter_search'));
     $filter->clear();
     $filter->sendKeys($value);
     $d->findElement(By::xPath("//button[@data-original-title = 'Search']"))->click();
     $d->waitForElementUntilIsPresent(By::xPath("//button[@data-original-title = 'Search']"));
     $d->findElement(By::xPath("//a[contains(text(), '" . $value . "')]"))->click();
     $d->waitForElementUntilIsNotPresent(By::xPath("//iframe[contains(@src, 'layout=modal')]"));
     $d->switchTo()->getDefaultFrame();
 }
 public function testSendKeysShouldRetrieveHebrewText()
 {
     $textarea1 = $this->_driver->findElement(By::id("txtArea1"));
     $textarea1->sendKeys("יאיר 34557");
     $this->assertEquals("יאיר 34557", $textarea1->getAttribute("value"));
 }
예제 #17
0
 protected function setTextAreaValues(array $values)
 {
     // Check whether this field uses a GUI editor
     // First see if we are inside a tab
     $tab = $this->driver->findElements(By::xPath("//div[@class='tab-pane active']"));
     if (isset($tab) && is_array($tab) && count($tab) == 1) {
         $guiEditor = $tab[0]->findElements(By::xPath("//div[@class='tab-pane active']//a[contains(@onclick, 'mceToggleEditor')]"));
     } else {
         $guiEditor = $this->driver->findElements(By::xPath("//a[contains(@onclick, 'mceToggleEditor')]"));
     }
     if (isset($guiEditor) && is_array($guiEditor) && count($guiEditor) == 1 && $guiEditor[0]->isDisplayed()) {
         $guiEditor[0]->click();
     }
     $inputElement = $this->driver->findElement(By::id($values['id']));
     $inputElement->clear();
     $inputElement->sendKeys($values['value']);
     if (isset($guiEditor) && is_array($guiEditor) && count($guiEditor) == 1 && $guiEditor[0]->isDisplayed()) {
         $guiEditor[0]->click();
     }
 }
예제 #18
0
 /**
  * Prepare wiki text for filters tab
  *
  */
 public function toWikiHelpFilters($groupId)
 {
     $el = $this->driver->findElement(By::xPath("//a[contains(@href, '#page-filters')]"));
     $el->click();
     $tabText = $el->getText();
     $heading = $this->driver->findElement(By::xPath("//div[@id='page-filters']//legend"))->getText();
     $subText = $this->driver->findElement(By::xPath("//div[@id='page-filters']//p"))->getText();
     $id = "jform_filters" . $groupId . "_filter_type";
     $toolTip = $this->getToolTip($tabText, $id);
     $subHeading = $this->driver->findElement(By::xPath("//table[@id='filter-config']//th[2]"))->getText();
     $filterOptions = $this->getOptionText($this->driver->findElement(By::id($id)));
     sleep(1);
     $helpText[] = "====" . $heading . "====\n";
     $helpText[] = $subText . "\n";
     $helpText[] = "*'''" . $subHeading . ":''' (" . implode("/", $filterOptions) . ")\n";
     $helpText[] = $toolTip;
     return $helpText;
 }
예제 #19
0
 public function testWaitForElementUntilIsNotPresent()
 {
     $this->_driver->get($this->_url);
     $webElement = $this->_driver->findElement(By::id("btnHideThis"));
     $webElement->click();
     $this->_driver->waitForElementUntilIsNotPresent(By::id("btnHideThis"), 10);
     $this->assertFalse($webElement->isDisplayed());
 }
예제 #20
0
 public function searchFor($search = false)
 {
     if ($search) {
         $el = $this->driver->findElement(By::id('filter_search'));
         $el->clear();
         $el->sendKeys($search);
         // In some cases we have to click the button twice since using bootstrap tooltips. (Not sure why.)
         $this->driver->findElement(By::xPath("//button[@data-original-title='Search' or @title='Search']"))->click();
         $page = $this->test->getPageObject(get_class($this));
         $this->driver->findElement(By::xPath("//button[@data-original-title='Search' or @title='Search']"))->click();
     } else {
         $this->driver->findElement(By::xPath("//div[@id='filter-bar']//button[@title='Clear' or @title='Reset' or @data-original-title='Reset' or @data-original-title='Clear']"))->click();
     }
     return $this->test->getPageObject(get_class($this));
 }
 public function trashAndDelete($name)
 {
     $currentMenu = $this->getCurrentMenu();
     $this->searchFor($name);
     $this->checkAll();
     $this->driver->findElement(By::id('filter_search'))->click();
     $this->clickButton('toolbar-trash');
     $this->test->getPageObject('MenuItemsManagerPage');
     $this->setFilter('Status', 'Trashed');
     $this->checkAll();
     $this->driver->findElement(By::id('filter_search'))->click();
     $this->clickButton('toolbar-delete');
     $this->test->getPageObject('MenuItemsManagerPage');
     $this->setFilter('Status', 'Select Status');
     $this->test->getPageObject('MenuItemsManagerPage');
 }
예제 #22
0
 public function delete($name)
 {
     $this->searchFor($name);
     $el = $this->driver->findElement(By::name("checkall-toggle"));
     while (!$el->isSelected()) {
         $el->click();
     }
     $this->driver->findElement(By::id("filter_search"))->click();
     sleep(2);
     $this->clickButton('toolbar-delete');
     $this->driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath));
     $this->searchFor();
 }
예제 #23
0
 public function setField($label, $value)
 {
     switch ($label) {
         case 'Host Name':
             $id = 'jform_db_host';
             break;
         case 'Username':
             $id = 'jform_db_user';
             break;
         case 'Password':
             $id = 'jform_db_pass';
             break;
         case 'Database Name':
             $id = 'jform_db_name';
             break;
         case 'Table Prefix':
             $id = 'jform_db_prefix';
             break;
         case 'Site Name':
             $id = 'jform_site_name';
             break;
         case 'Your Email':
             $id = 'jform_admin_email';
             break;
         case 'Admin Username':
             $id = 'jform_admin_user';
             break;
         case 'Admin Password':
             $id = 'jform_admin_password';
             break;
         case 'Confirm Admin Password':
             $id = 'jform_admin_password2';
             break;
     }
     $this->driver->findElement(By::id($id))->clear();
     $this->driver->findElement(By::id($id))->sendKeys($value);
 }
예제 #24
0
 protected function setTextValues(array $values)
 {
     $this->selectTab($values['tab']);
     $inputElement = $this->driver->findElement(By::id($values['id']));
     $inputElement->clear();
     $inputElement->sendKeys($values['value']);
 }