Locate by element's tag name
public static tagName ( String $selectorValue ) : Nearsoft\SeleniumClient\By | ||
$selectorValue | String | |
return | Nearsoft\SeleniumClient\By |
public function testFindElementsShouldGetOneOfFoundElementsText() { $selectBox = $this->_driver->findElement(By::id("sel1")); $selectBoxOptions = $selectBox->findElements(By::tagName("option")); foreach ($selectBoxOptions as $selectBoxOption) { $this->assertTrue($selectBoxOption instanceof WebElement); if ($selectBoxOption->getAttribute("value") == "4") { $selectBoxOption->click(); } } foreach ($selectBoxOptions as $selectBoxOption) { if ($selectBoxOption->getAttribute("selected") == "true") { $this->assertEquals("Black", $selectBoxOption->getText()); } } }
public function testFindElements() { $webElements = $this->_driver->findElements(By::tagName("input")); foreach ($webElements as $webElement) { $this->assertTrue($webElement instanceof WebElement); } $this->assertTrue(is_array($webElements)); $this->assertTrue(count($webElements) > 0); }