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


PHP NodeElement::findAll方法代码示例

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


在下文中一共展示了NodeElement::findAll方法的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: 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

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

示例4: reverseAll

 public static function reverseAll(NodeElement $content, Elements $elements = null)
 {
     $inputsElements = $content->findAll('css', 'input,select,textarea');
     if ($inputsElements) {
         foreach ($inputsElements as $inputsElement) {
             $input = self::reverse($inputsElement, $elements);
             if ($input) {
                 $elements->addInput($input);
             }
         }
     }
 }
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:12,代码来源:Inputs.php

示例5: reverseAll

 public static function reverseAll(NodeElement $content, Elements $elements)
 {
     $buttonElements = $content->findAll('css', 'button');
     if ($buttonElements) {
         foreach ($buttonElements as $buttonElement) {
             $button = new Button();
             self::reverse($buttonElement, $button, $elements);
             if (!$elements->isRegisteredButton($button)) {
                 $elements->addButton($button);
             }
         }
     }
 }
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:13,代码来源:Buttons.php

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

示例7: reverseActions

 private static function reverseActions(NodeElement $header, Header $head)
 {
     $actions = new Actions($head->getDt());
     $buttonsElems = $header->findAll('css', 'button');
     if ($buttonsElems) {
         /** @var NodeElement $element */
         foreach ($buttonsElems as $buttonElement) {
             $button = new Button();
             self::reverseButton($buttonElement, $button, self::$elements);
             if (!self::$elements->isRegisteredButton($button)) {
                 $actions->addButton($button);
             }
         }
     }
     $inputElems = $header->findAll('css', 'input,select,textarea');
     if ($inputElems) {
         /** @var NodeElement $element */
         foreach ($inputElems as $inputElement) {
             $input = self::reverseInput($inputElement, self::$elements);
             if ($input) {
                 $actions->addInput($input);
             }
         }
     }
 }
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:25,代码来源:DataTable.php

示例8: getRowCell

 /**
  * @param NodeElement $row
  * @param int         $position
  *
  * @return NodeElement
  */
 protected function getRowCell($row, $position)
 {
     $cells = $row->findAll('xpath', '/td');
     $visibleCells = [];
     foreach ($cells as $cell) {
         $style = $cell->getAttribute('style');
         if (!$style || !preg_match('/display: ?none;/', $style)) {
             $visibleCells[] = $cell;
         }
     }
     $cells = $visibleCells;
     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:bengrol,项目名称:pim-community-dev,代码行数:22,代码来源:Grid.php

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

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

示例11: testFindAllParentUnion

 public function testFindAllParentUnion()
 {
     $node = new NodeElement('some_xpath | another_xpath', $this->session);
     $xpath = "some_tag1 | some_tag2";
     $expectedPrefixed = "(some_xpath | another_xpath)/some_tag1 | (some_xpath | another_xpath)/some_tag2";
     $this->driver->expects($this->exactly(1))->method('find')->will($this->returnValueMap(array(array($expectedPrefixed, array(2, 3, 4)))));
     $this->selectors->expects($this->exactly(1))->method('selectorToXpath')->will($this->returnValueMap(array(array('xpath', $xpath, $xpath))));
     $this->assertEquals(3, count($node->findAll('xpath', $xpath)));
 }
开发者ID:jordi12100,项目名称:Mink,代码行数:9,代码来源:NodeElementTest.php

示例12: getRowsWithFields

 /**
  * @param NodeElement $table
  * @param array $fields
  * @param bool $onlyFirstOccurence
  *
  * @return NodeElement[]
  *
  * @throws \Exception If columns or rows were not found
  */
 protected function getRowsWithFields(NodeElement $table, array $fields, $onlyFirstOccurence = false)
 {
     $rows = $table->findAll('css', 'tr');
     if (!isset($rows[0])) {
         throw new \Exception('There are no rows!');
     }
     $fields = $this->replaceColumnNamesWithColumnIds($table, $fields);
     $foundRows = [];
     /** @var NodeElement[] $rows */
     $rows = $table->findAll('css', 'tr');
     foreach ($rows as $row) {
         $found = true;
         /** @var NodeElement[] $columns */
         $columns = $row->findAll('css', 'th,td');
         foreach ($fields as $index => $searchedValue) {
             if (!isset($columns[$index])) {
                 throw new \InvalidArgumentException(sprintf('There is no column with index %d', $index));
             }
             $containing = false;
             $searchedValue = trim($searchedValue);
             if (0 === strpos($searchedValue, '%') && strlen($searchedValue) - 1 === strrpos($searchedValue, '%')) {
                 $searchedValue = substr($searchedValue, 1, strlen($searchedValue) - 2);
                 $containing = true;
             }
             $position = stripos(trim($columns[$index]->getText()), $searchedValue);
             if ($containing && false === $position || !$containing && 0 !== $position) {
                 $found = false;
                 break;
             }
         }
         if ($found) {
             $foundRows[] = $row;
             if ($onlyFirstOccurence) {
                 break;
             }
         }
     }
     return $foundRows;
 }
开发者ID:Mozan,项目名称:Sylius,代码行数:48,代码来源:DefaultContext.php

示例13: getColumnIndex

 /**
  * @param NodeElement $table
  * @param string $fieldName
  *
  * @return int
  *
  * @throws \InvalidArgumentException
  */
 private function getColumnIndex(NodeElement $table, $fieldName)
 {
     $rows = $table->findAll('css', 'tr');
     Assert::notEmpty($rows, 'There are no rows!');
     /** @var NodeElement $headerRow */
     $headerRow = $rows[0];
     $headers = $headerRow->findAll('css', 'th,td');
     /** @var NodeElement $column */
     foreach ($headers as $index => $column) {
         $columnFieldName = $this->getColumnFieldName($column);
         if ($fieldName === $columnFieldName) {
             return $index;
         }
     }
     throw new \InvalidArgumentException(sprintf('Column with name "%s" not found!', $fieldName));
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:24,代码来源:TableAccessor.php

示例14: getRowsWithFields

 /**
  * @param NodeElement $table
  * @param array $fields
  * @param boolean $onlyFirstOccurence
  *
  * @return NodeElement[]
  *
  * @throws \Exception If columns or rows were not found
  */
 protected function getRowsWithFields(NodeElement $table, array $fields, $onlyFirstOccurence = false)
 {
     $rows = $table->findAll('css', 'tr');
     if (!isset($rows[0])) {
         throw new \Exception("There are no rows!");
     }
     $fields = $this->replaceColumnNamesWithColumnIds($table, $fields);
     $foundRows = array();
     /** @var NodeElement[] $rows */
     $rows = $table->findAll('css', 'tr');
     foreach ($rows as $row) {
         $found = true;
         /** @var NodeElement[] $columns */
         $columns = $row->findAll('css', 'th,td');
         foreach ($fields as $index => $searchedValue) {
             if (!isset($columns[$index])) {
                 throw new \InvalidArgumentException(sprintf('There is no column with index %d', $index));
             }
             if (0 !== stripos(trim($columns[$index]->getText()), trim($searchedValue))) {
                 $found = false;
                 break;
             }
         }
         if ($found) {
             $foundRows[] = $row;
             if ($onlyFirstOccurence) {
                 break;
             }
         }
     }
     return $foundRows;
 }
开发者ID:rainyang,项目名称:Sylius,代码行数:41,代码来源:DefaultContext.php

示例15: collectionShouldHaveElements

 /**
  * @Given /^("[^"]*" collection) should have (\d+) elements$/
  */
 public function collectionShouldHaveElements(NodeElement $collection, $elementsCount)
 {
     $elements = $collection->findAll('xpath', '/*/*[@class = "form-group"]');
     expect(count($elements))->toBe($elementsCount);
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:8,代码来源:AdminContext.php


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