当前位置: 首页>>代码示例>>PHP>>正文


PHP Locator::isCSS方法代码示例

本文整理汇总了PHP中Codeception\Util\Locator::isCSS方法的典型用法代码示例。如果您正苦于以下问题:PHP Locator::isCSS方法的具体用法?PHP Locator::isCSS怎么用?PHP Locator::isCSS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Codeception\Util\Locator的用法示例。


在下文中一共展示了Locator::isCSS方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: grabTextFrom

 public function grabTextFrom($cssOrXPathOrRegex)
 {
     $el = null;
     if (Locator::isCSS($cssOrXPathOrRegex)) {
         $el = $this->session->getPage()->find('css', $cssOrXPathOrRegex);
         if ($el) {
             return $el->getText();
         }
     }
     if (!$el and Locator::isXPath($cssOrXPathOrRegex)) {
         $el = @$this->session->getPage()->find('xpath', $cssOrXPathOrRegex);
         if ($el) {
             return $el->getText();
         }
     }
     if (@preg_match($cssOrXPathOrRegex, $this->session->getPage()->getContent(), $matches)) {
         return $matches[1];
     }
     throw new ElementNotFound($cssOrXPathOrRegex, 'CSS or XPath or Regex');
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:20,代码来源:Mink.php

示例4: filterByCSS

 /**
  * @param $locator
  * @return Crawler
  */
 protected function filterByCSS($locator)
 {
     if (!Locator::isCSS($locator)) {
         throw new MalformedLocatorException($locator, 'css');
     }
     return $this->getCrawler()->filter($locator);
 }
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:11,代码来源:InnerBrowser.php

示例5: 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

示例6: 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::isCSS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。