本文整理汇总了PHP中Codeception\Util\Locator::isID方法的典型用法代码示例。如果您正苦于以下问题:PHP Locator::isID方法的具体用法?PHP Locator::isID怎么用?PHP Locator::isID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codeception\Util\Locator
的用法示例。
在下文中一共展示了Locator::isID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsId
public function testIsId()
{
$this->assertTrue(Locator::isID('#username'));
$this->assertTrue(Locator::isID('#user.name'));
$this->assertTrue(Locator::isID('#user-name'));
$this->assertFalse(Locator::isID('#user-name .field'));
$this->assertFalse(Locator::isID('.field'));
$this->assertFalse(Locator::isID('hello'));
}
示例2: match
/**
* @param $page
* @param $selector
* @param bool $throwMalformed
* @return array
*/
protected function match($page, $selector, $throwMalformed = true)
{
if (is_array($selector)) {
try {
return $page->findElements($this->getStrictLocator($selector));
} catch (InvalidSelectorException $e) {
throw new MalformedLocatorException(key($selector) . ' => ' . reset($selector), "Strict locator");
}
}
if ($selector instanceof WebDriverBy) {
try {
return $page->findElements($selector);
} catch (InvalidSelectorException $e) {
throw new MalformedLocatorException(sprintf("WebDriverBy::%s('%s')", $selector->getMechanism(), $selector->getValue()), 'WebDriver');
}
}
$isValidLocator = false;
$nodes = [];
try {
if (Locator::isID($selector)) {
$isValidLocator = true;
$nodes = $page->findElements(WebDriverBy::id(substr($selector, 1)));
}
if (empty($nodes) and Locator::isCSS($selector)) {
$isValidLocator = true;
$nodes = $page->findElements(WebDriverBy::cssSelector($selector));
}
if (empty($nodes) and Locator::isXPath($selector)) {
$isValidLocator = true;
$nodes = $page->findElements(WebDriverBy::xpath($selector));
}
} catch (InvalidSelectorException $e) {
throw new MalformedLocatorException($selector);
}
if (!$isValidLocator and $throwMalformed) {
throw new MalformedLocatorException($selector);
}
return $nodes;
}
示例3: getLocator
/**
* @param $selector
* @return WebDriverBy
* @throws \InvalidArgumentException
*/
protected function getLocator($selector)
{
if ($selector instanceof WebDriverBy) {
return $selector;
}
if (is_array($selector)) {
return $this->getStrictLocator($selector);
}
if (Locator::isID($selector)) {
return WebDriverBy::id(substr($selector, 1));
}
if (Locator::isCSS($selector)) {
return WebDriverBy::cssSelector($selector);
}
if (Locator::isXPath($selector)) {
return WebDriverBy::xpath($selector);
}
throw new \InvalidArgumentException("Only CSS or XPath allowed");
}
示例4: match
/**
* @param $page
* @param $selector
* @return array
*/
protected function match($page, $selector)
{
$nodes = array();
if (is_array($selector)) {
return $page->findElements($this->getWebDriverLocator($selector));
}
if ($selector instanceof \WebDriverBy) {
return $page->findElements($selector);
}
if (Locator::isID($selector)) {
$nodes = $page->findElements(\WebDriverBy::id(substr($selector, 1)));
}
if (!empty($nodes)) {
return $nodes;
}
if (Locator::isCSS($selector)) {
$nodes = $page->findElements(\WebDriverBy::cssSelector($selector));
}
if (!empty($nodes)) {
return $nodes;
}
if (Locator::isXPath($selector)) {
$nodes = $page->findElements(\WebDriverBy::xpath($selector));
}
return $nodes;
}
示例5: match
/**
* @param $page
* @param $selector
* @return array
*/
protected function match($page, $selector)
{
$nodes = array();
if (Locator::isID($selector)) $nodes = $page->findElements(\WebDriverBy::id(substr($selector, 1)));
if (!empty($nodes)) return $nodes;
if (Locator::isCSS($selector)) $nodes = $page->findElements(\WebDriverBy::cssSelector($selector));
if (!empty($nodes)) return $nodes;
if (Locator::isXPath($selector)) $nodes = $page->findElements(\WebDriverBy::xpath($selector));
return $nodes;
}