Locate by JavaScript selector
public static jsSelector ( string $selectorValue, string $selectorDefinition = '$' ) : Nearsoft\SeleniumClient\By | ||
$selectorValue | string | |
$selectorDefinition | string | |
return | Nearsoft\SeleniumClient\By |
public function testFindElementByJsSelectorShouldGetChildElement() { $selectBox = $this->_driver->findElement(By::id("sel1")); $option = $selectBox->findElement(By::jsSelector('option[selected="selected"]', 'document.querySelector')); $this->assertEquals('Orange', $option->getText()); }
public function testFindElementsByJsSelector() { $inputs = $this->_driver->findElements(By::jsSelector('input', 'document.querySelectorAll')); $self = $this; array_walk($inputs, function ($input) use($self) { $self->assertTrue($input instanceof WebElement); }); $this->assertGreaterThan(0, count($inputs)); $this->setExpectedException('Nearsoft\\SeleniumClient\\Exceptions\\InvalidSelector'); $this->_driver->findElements(By::jsSelector('input')); }