當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Locator::isID方法代碼示例

本文整理匯總了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'));
 }
開發者ID:corcre,項目名稱:elabftw,代碼行數:9,代碼來源:LocatorTest.php

示例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;
 }
開發者ID:racinmat,項目名稱:SPETestParser,代碼行數:45,代碼來源:Acceptance.php

示例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");
 }
開發者ID:neronmoon,項目名稱:Codeception,代碼行數:24,代碼來源:WebDriver.php

示例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;
 }
開發者ID:Eli-TW,項目名稱:Codeception,代碼行數:31,代碼來源:WebDriver.php

示例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;
 }
開發者ID:hendryguna,項目名稱:laravel-basic,代碼行數:15,代碼來源:WebDriver.php


注:本文中的Codeception\Util\Locator::isID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。