jsSelector() public static method

Locate by JavaScript selector
public static jsSelector ( string $selectorValue, string $selectorDefinition = '$' ) : Nearsoft\SeleniumClient\By
$selectorValue string
$selectorDefinition string
return Nearsoft\SeleniumClient\By
コード例 #1
0
 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());
 }
コード例 #2
0
 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'));
 }