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


PHP Element\NodeElement类代码示例

本文整理汇总了PHP中Behat\Mink\Element\NodeElement的典型用法代码示例。如果您正苦于以下问题:PHP NodeElement类的具体用法?PHP NodeElement怎么用?PHP NodeElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: fillForm

 /**
  * Fuzz fill all form fields with random data
  *
  * @param Element\NodeElement $form
  */
 protected function fillForm(Element\NodeElement $form)
 {
     $inputs = $form->findAll('css', 'input[type="text"]');
     foreach ($inputs as $i) {
         /** @var  Element\NodeElement $i */
         if ($i->isVisible()) {
             if ($i->hasAttribute('name')) {
                 $name = $i->getAttribute('name');
                 $value = $this->getFakerValue($name);
             } else {
                 $value = $this->faker()->text();
             }
             $i->setValue($value);
         }
     }
     $passwords = $form->findAll('css', 'input[type="password"]');
     $password = $this->faker()->password;
     foreach ($passwords as $p) {
         if ($p->isVisible()) {
             $p->setValue($password);
         }
     }
     $selects = $form->findAll('css', 'select');
     foreach ($selects as $s) {
         /** @var  Element\NodeElement $s */
         if ($s->isVisible()) {
             $s->selectOption($s->find('css', 'option')->getAttribute('name'));
         }
     }
     $checkboxes = $form->findAll('css', 'checkbox');
     foreach ($checkboxes as $c) {
         /** @var  Element\NodeElement $c */
         if ($c->isVisible()) {
             $c->check();
         }
     }
     $radios = $form->findAll('css', 'input[type="radio"]');
     $radio_names = array();
     foreach ($radios as $r) {
         /** @var  Element\NodeElement $r */
         if ($r->isVisible()) {
             if ($r->hasAttribute('name')) {
                 $name = $r->getAttribute('name');
                 if (!isset($radio_names[$name])) {
                     $radio_names[$name] = true;
                     $r->click();
                 }
             }
         }
     }
 }
开发者ID:edmondscommerce,项目名称:behat-faker-context,代码行数:56,代码来源:FakerContext.php

示例2: __construct

 public function __construct(NodeElement $node, Session $session)
 {
     if (!$node->hasClass(self::NOTICE_CLASS)) {
         throw new \InvalidArgumentException(sprintf('Provided node does not have class %s', self::NOTICE_CLASS));
     }
     parent::__construct($node->getXpath(), $session);
 }
开发者ID:stephenharris,项目名称:WordPressBehatExtension,代码行数:7,代码来源:Notice.php

示例3: getNameProperty

 /**
  * Returns the name
  * @param NodeElement $slide
  * @return string
  */
 public function getNameProperty(NodeElement $slide)
 {
     $selectors = Helper::getRequiredSelectors($this, ['slideImage', 'slideLink', 'slideName']);
     $nameElement = $slide->find('css', $selectors['slideName']);
     $names = ['imageAlt' => $slide->find('css', $selectors['slideImage'])->getAttribute('alt'), 'linkTitle' => $slide->find('css', $selectors['slideLink'])->getAttribute('title'), 'name' => $nameElement->getText(), 'nameTitle' => $nameElement->getAttribute('title')];
     return Helper::getUnique($names);
 }
开发者ID:BucherStoerzbachGbR,项目名称:shopware,代码行数:12,代码来源:ArticleSlider.php

示例4: createFromNode

 public static function createFromNode(NodeElement $node)
 {
     $message = $node->find('css', '.noty_text')->getHtml();
     //$x = $node->getOuterHtml();
     $class = $node->getAttribute('class');
     switch ($class) {
         case 'noty_alert':
             $type = 'alert';
             break;
         case 'noty_warning':
             $type = 'warning';
             break;
         case 'noty_error':
             $type = 'error';
             break;
         case 'noty_information':
             $type = 'information';
             break;
         case 'noty_success':
             $type = 'success';
             break;
         default:
             $type = 'default';
     }
     return new NotyMessage($node, $type, $message);
 }
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:26,代码来源:NotyMessage.php

示例5: getEvaluation

 /**
  * Helper function how to read the evaluation from the evaluation element
  * @param  NodeElement $element
  * @return string
  */
 protected function getEvaluation($element)
 {
     $evaluation = $element->getAttribute('content');
     $evaluation = floatval($evaluation);
     $evaluation *= 2;
     return (string) $evaluation;
 }
开发者ID:BucherStoerzbachGbR,项目名称:shopware,代码行数:12,代码来源:Detail.php

示例6: fromNodeElement

 /**
  * Creates Element instance based on existing NodeElement instance.
  *
  * @param NodeElement  $node_element Node element.
  * @param IPageFactory $page_factory Page factory.
  *
  * @return static
  * @throws ElementException When page factory is missing.
  */
 public static function fromNodeElement(NodeElement $node_element, IPageFactory $page_factory = null)
 {
     if (!isset($page_factory)) {
         throw new ElementException('Page factory is required to create this element', ElementException::TYPE_PAGE_FACTORY_REQUIRED);
     }
     $selenium_selector = array(How::XPATH => $node_element->getXpath());
     return new static($selenium_selector, $page_factory);
 }
开发者ID:eltonoliveira,项目名称:qa-tools,代码行数:17,代码来源:AbstractElementContainer.php

示例7: parse

 public function parse(NodeElement $node)
 {
     $this->node = $node;
     $elems = $node->findAll('css', 'li');
     foreach ($elems as $elem) {
         $notyMessage = NotyMessage::createFromNode($elem);
         $this->messages[] = $notyMessage;
     }
 }
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:9,代码来源:NotyContainer.php

示例8: reverse

 public static function reverse(NodeElement $buttonNode, Button $buttonObj, Elements $elements = null)
 {
     if ($buttonNode->getTagName() === 'button') {
         $buttonObj->setNode($buttonNode);
     } else {
         throw new \LogicException('tag mismatch');
     }
     $parents = $buttonObj->getParents();
     $outer = $buttonNode->getOuterHtml();
     $label = $buttonNode->getText();
     if ($label) {
         $buttonObj->setLabel($label);
     } else {
         $x = 1;
     }
     //return;
     /*     $elem = [];
             $id = $button->getAttribute('id');
     
             $html = $button->getOuterHtml();
             $test = '/<[a-z]+\s([^>]*)/';
             if (preg_match($test, $html, $matches)) {
                 preg_match_all('/([a-z]+=".*?")/', $matches[1], $attribs1);
                 $attribs = preg_split('/ /', $matches[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
                 $elem['attr'] = $attribs;
             }
     
     
             if ($button->getTagName() === 'a') {
                 $href = $button->getAttribute('href');
                 $elem['href'] = $href;
             }
     
     
             if (!$id) {
     
                 $dt = $content->find('css', 'table.table-columnfilter');
                 if ($dt) {
                     //skip datatable;
                     //continue;
                 }
     
                 $label = $button->getText();
                 $xpath = $button->getXpath();
     
                 $elem['xpath'] = $xpath;
                 $elem['label'] = $label;
             } else {
                 $label = $button->getText();
     
                 $elements['buttons'][] = ['id' => $id, 'label' => $label];
             }
     
             $elements['buttons'][] = $elem;*/
 }
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:55,代码来源:Buttons.php

示例9: getOrderPositionData

 /**
  * Helper function returns the data of an order position
  * @param NodeElement $position
  * @param string[] $selectors
  * @return array
  */
 private function getOrderPositionData(NodeElement $position, array $selectors)
 {
     $data = [];
     foreach ($selectors as $key => $selector) {
         $element = $position->find('css', $selector);
         $data[$key] = $element->getText();
         if ($key !== 'product') {
             $data[$key] = Helper::floatValue($data[$key]);
         }
     }
     return $data;
 }
开发者ID:BucherStoerzbachGbR,项目名称:shopware,代码行数:18,代码来源:AccountOrder.php

示例10: getScopeData

 /**
  * @param NodeElement $scopeBlock
  *
  * @return array
  */
 protected function getScopeData(NodeElement $scopeBlock)
 {
     $ratio = $scopeBlock ? $scopeBlock->find('css', '.literal-progress')->getHtml() : '';
     $state = $scopeBlock ? explode('-', $scopeBlock->find('css', '.progress')->getAttribute('class'))[1] : '';
     $missingValuesBlocks = $scopeBlock ? $scopeBlock->findAll('css', '.missing-attributes [data-attribute]') : [];
     $missingValues = [];
     if (!empty($missingValuesBlocks)) {
         foreach ($missingValuesBlocks as $missingValuesBlock) {
             $attributeCode = $missingValuesBlock->getAttribute('data-attribute');
             $attributeLabel = $missingValuesBlock->getHtml();
             $missingValues[$attributeCode] = $attributeLabel;
         }
     }
     return ['ratio' => $ratio, 'state' => $state, 'missing_values' => $missingValues];
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:20,代码来源:PanelDecorator.php

示例11: findAll

 /**
  * @return NodeElement[]
  */
 public function findAll()
 {
     if (null === $this->parent) {
         throw new \RuntimeException(sprintf('An object "%s" instantiated incorrectly.', __CLASS__));
     }
     return $this->parent->findAll('xpath', (string) $this);
 }
开发者ID:BR0kEN-,项目名称:TqExtension,代码行数:10,代码来源:InaccurateText.php

示例12: findCommentMessage

 /**
  * @param NodeElement $element
  *
  * @return NodeElement|mixed|null
  */
 protected function findCommentMessage(NodeElement $element)
 {
     return $element->find('css', 'span.message');
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:9,代码来源:Edit.php

示例13: waitForModalToAppear

 /**
  * @param NodeElement $modalContainer
  * @param string $appearClass
  *
  * @todo it really shouldn't be here :)
  */
 protected function waitForModalToAppear(NodeElement $modalContainer, $appearClass = 'in')
 {
     $this->getDocument()->waitFor(1, function () use($modalContainer, $appearClass) {
         return false !== strpos($modalContainer->getAttribute('class'), $appearClass);
     });
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:12,代码来源:SymfonyPage.php

示例14: getColumnIndex

 /**
  * @param NodeElement $table
  * @param string $columnName
  *
  * @return int
  *
  * @throws \Exception If column was not found
  */
 private function getColumnIndex(NodeElement $table, $columnName)
 {
     $rows = $table->findAll('css', 'tr');
     if (!isset($rows[0])) {
         throw new \InvalidArgumentException('There are no rows!');
     }
     /** @var NodeElement $firstRow */
     $firstRow = $rows[0];
     $columns = $firstRow->findAll('css', 'th,td');
     foreach ($columns as $index => $column) {
         /** @var NodeElement $column */
         if (0 === stripos($column->getText(), $columnName)) {
             return $index;
         }
     }
     throw new \InvalidArgumentException(sprintf('Column with name "%s" not found!', $columnName));
 }
开发者ID:Mozan,项目名称:Sylius,代码行数:25,代码来源:TableManipulator.php

示例15: getRowCell

 /**
  * @param NodeElement $row
  * @param int         $position
  *
  * @throws \InvalidArgumentException
  *
  * @return NodeElement
  */
 protected function getRowCell($row, $position)
 {
     // $row->findAll('css', 'td') will not work in the case of nested table (like proposals changes)
     // because we only need to find the direct children cells
     $cells = $row->findAll('xpath', './td');
     if (!isset($cells[$position])) {
         throw new \InvalidArgumentException(sprintf('Trying to access cell %d of a row which has %d cell(s).', $position + 1, count($cells)));
     }
     return $cells[$position];
 }
开发者ID:pierallard,项目名称:pim-community-dev,代码行数:18,代码来源:Grid.php


注:本文中的Behat\Mink\Element\NodeElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。