• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Element\NodeElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getTextProperty

 /**
  * Returns the text preview of the blog article
  * @param NodeElement $article
  * @return null|string
  */
 public function getTextProperty(NodeElement $article)
 {
     $selector = Helper::getRequiredSelector($this, 'articleText');
     return $article->find('css', $selector)->getText();
 }
开发者ID:BucherStoerzbachGbR,项目名称:shopware,代码行数:10,代码来源:BlogArticle.php


示例17: findParentByClass

 /**
  * Returns the closest parent element having a specific class attribute.
  *
  * @param  NodeElement $el
  * @param  String  $class
  * @return Element|null
  */
 protected function findParentByClass(NodeElement $el, $class)
 {
     $container = $el->getParent();
     while ($container && $container->getTagName() != 'body') {
         if ($container->isVisible() && in_array($class, explode(' ', $container->getAttribute('class')))) {
             return $container;
         }
         $container = $container->getParent();
     }
     return null;
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:18,代码来源:CmsUiContext.php


示例18: get_field_node_type

 /**
  * Recursive method to find the field type.
  *
  * Depending on the field the felement class node is in a level or in another. We
  * look recursively for a parent node with a 'felement' class to find the field type.
  *
  * @param NodeElement $fieldnode The current node.
  * @param Session $session The behat browser session
  * @return mixed A NodeElement if we continue looking for the element type and String or false when we are done.
  */
 protected static function get_field_node_type(NodeElement $fieldnode, Session $session)
 {
     // Special handling for availability field which requires custom JavaScript.
     if ($fieldnode->getAttribute('name') === 'availabilityconditionsjson') {
         return 'availability';
     }
     if ($fieldnode->getTagName() == 'html') {
         return false;
     }
     // If the type is explictly set on the element pointed to by the label - use it.
     if ($type = $fieldnode->getParent()->getAttribute('data-fieldtype')) {
         if ($type == 'tags') {
             return 'autocomplete';
         }
         return $type;
     }
     // We look for a parent node with 'felement' class.
     if ($class = $fieldnode->getParent()->getAttribute('class')) {
         if (strstr($class, 'felement') != false) {
             // Remove 'felement f' from class value.
             return substr($class, 10);
         }
         // Stop propagation through the DOM, if it does not have a felement is not part of a moodle form.
         if (strstr($class, 'fcontainer') != false) {
             return false;
         }
     }
     return self::get_field_node_type($fieldnode->getParent(), $session);
 }
开发者ID:janeklb,项目名称:moodle,代码行数:39,代码来源:behat_field_manager.php


示例19: fillTextField

 /**
  * Fills a text field element with $value, identified by its $label.
  *
  * @param NodeElement $label
  * @param string      $value
  */
 protected function fillTextField(NodeElement $label, $value)
 {
     if (!$label->getAttribute('for') && null !== $label->channel) {
         $label = $label->getParent()->find('css', sprintf('[data-scope="%s"] label', $label->channel));
     }
     $for = $label->getAttribute('for');
     $field = $this->find('css', sprintf('#%s', $for));
     $field->setValue($value);
 }
开发者ID:pierallard,项目名称:pim-community-dev,代码行数:15,代码来源:Form.php


示例20: openFilter

 /**
  * Open the filter
  *
  * @param NodeElement $filter
  *
  * @throws \InvalidArgumentException
  */
 public function openFilter(NodeElement $filter)
 {
     if ($element = $filter->find('css', 'button')) {
         $element->click();
     } else {
         throw new \InvalidArgumentException('Impossible to open filter or maybe its type is not yet implemented');
     }
 }
开发者ID:bengrol,项目名称:pim-community-dev,代码行数:15,代码来源:Grid.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Currency\CurrencyManager类代码示例发布时间:2022-05-23
下一篇:
PHP Mink\Session类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap