xPath() public static method

Locate by element's xPath
public static xPath ( String $selectorValue ) : Nearsoft\SeleniumClient\By
$selectorValue String
return Nearsoft\SeleniumClient\By
 public function testSelectByPartialTextShouldSelect()
 {
     $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());
 }
Beispiel #2
0
 public function testDemo1()
 {
     //get url
     $this->_driver->get($this->_testUrl);
     sleep(4);
     //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());
     //navigation
     $this->_driver->get('http://www.nearsoft.com');
     $this->_driver->navigate()->refresh();
     $this->_driver->navigate()->back();
     $this->_driver->navigate()->forward();
     sleep(5);
 }
 public function testGetTextShouldGetText()
 {
     $label = $this->_driver->findElement(By::xPath("/html/body/table/tbody/tr/td[2]/fieldset/p"));
     $this->assertEquals("Simple paragraph", $label->getText());
 }
 public function testFindElementsInElement()
 {
     $parentElement = $this->_driver->findElement(By::id("sel1"));
     $childElements = $this->_driver->findElements(By::xPath(".//option"), false, $parentElement->getElementId());
     $this->assertInternalType('array', $childElements);
     $this->assertInstanceOf('Nearsoft\\SeleniumClient\\WebElement', $childElements[1]);
 }
Beispiel #5
0
 private function findSaled()
 {
     $webProdano = $this->driver->findElements(By::xPath('//span[@class="prodano"]'));
     if (count($webProdano) > 0) {
         return true;
     } else {
         return false;
     }
 }