/**
* Gets an element within current page
* @param By $locator
* @param bool $polling
* @param int $elementId
* @throws Http\SeleniumNoSuchElementException
* @return Nearsoft\SeleniumClient\WebElement
*/
public function findElement(By $locator, $polling = false, $elementId = -1)
{
if (strpos($locator->getStrategy(), 'js selector ') === 0) {
$result = $this->findElements($locator, $polling, $elementId);
if (!$result) {
throw new Exceptions\NoSuchElement();
}
return $result[0];
} else {
$params = array('using' => $locator->getStrategy(), 'value' => $locator->getSelectorValue());
if ($elementId < 0) {
$command = new Commands\Command($this, 'element', $params);
} else {
$command = new Commands\Command($this, 'element_in_element', $params, array('element_id' => $elementId));
}
$command->setPolling($polling);
$results = $command->execute();
return new WebElement($this, $results['value']['ELEMENT']);
}
}