示例#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
 }
 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());
 }