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


PHP NodeElement::getTagName方法代码示例

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


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

示例1: __construct

 /**
  * @param RawTqContext $context
  *   Behat context.
  * @param string $selector
  *   Field selector.
  * @param bool $not
  *   Negate the condition.
  * @param string $expected
  *   Expected value.
  */
 public function __construct(RawTqContext $context, $selector, $not, $expected = '')
 {
     $this->not = (bool) $not;
     $this->context = $context;
     $this->selector = $selector;
     $this->expected = $expected;
     $this->element = $this->context->element('field', $selector);
     $this->value = $this->element->getValue();
     $this->tag = $this->element->getTagName();
 }
开发者ID:BR0kEN-,项目名称:TqExtension,代码行数:20,代码来源:FormValueAssertion.php

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

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

示例4: assertElementType

 /**
  * Checks that the given element is of the given type.
  *
  * @param NodeElement $element
  *   The element to check.
  * @param string $type
  *   The expected type.
  *
  * @throws ExpectationException
  *   Thrown when the given element is not of the expected type.
  */
 public function assertElementType(NodeElement $element, $type)
 {
     if ($element->getTagName() !== $type) {
         throw new ExpectationException("The element is not a '{$type}'' field.", $this->getSession());
     }
 }
开发者ID:janoka,项目名称:platform-dev,代码行数:17,代码来源:FeatureContext.php

示例5: testGetTagName

 public function testGetTagName()
 {
     $node = new NodeElement('html//h3', $this->session);
     $this->driver->expects($this->once())->method('getTagName')->with('html//h3')->will($this->returnValue('h3'));
     $this->assertEquals('h3', $node->getTagName());
 }
开发者ID:jordi12100,项目名称:Mink,代码行数:6,代码来源:NodeElementTest.php

示例6: reverse

 public static function reverse(NodeElement $content, Elements $elements = null)
 {
     $tag = $content->getTagName();
     if ($tag === 'select') {
         $input = new Select();
     } elseif ($tag === 'textarea') {
         $input = new Textarea();
     } elseif ($tag === 'input') {
         $input = new Input();
         $input->setNode($content);
         switch ($input->getAttribute('type')) {
             case 'checkbox':
                 $input = new Checkbox();
                 break;
             case 'submit':
                 $input = new Submit();
                 break;
             case 'text':
                 $input = new Text();
                 break;
             case 'radio':
                 $input = new Radio();
                 break;
             case 'file':
                 $input = new File();
                 break;
             case 'hidden':
                 return false;
             case 'search':
                 $input = new Text();
                 $input->setLabel('dtsearch');
                 $input->setNode($content);
                 return $input;
                 break;
             default:
                 //hidden
                 $x = 1;
                 return false;
                 break;
         }
     } else {
         //hidden
         $x = 1;
         return false;
     }
     /** @var Input $input */
     $input->setNode($content);
     if ($elements && $elements->isRegisteredInput($input)) {
         return false;
     }
     $outer = $content->getOuterHtml();
     $inner = $content->getHtml();
     $txt = $content->getText();
     $parents = $input->getParents();
     $res = self::findLabelByParent($input);
     if ($res) {
         $input->setLabel($res);
         return $input;
     }
     $res = self::findLabelByPlaceholder($input);
     if ($res) {
         $input->setLabel($res);
         return $input;
     }
     $res = self::findLabelByStdForm($input);
     if ($res) {
         $input->setLabel($res);
         return $input;
     }
     $res = self::findLabelByValue($input);
     if ($res) {
         $input->setLabel($res);
         return $input;
     }
     if (!$input->getId() && !$input->getName()) {
         if (false !== $input->hasClass('dtSearch')) {
             //datatables column filter
             $x = 1;
         }
         /*   $dt = $content->find('css', 'table.table-columnfilter');
              if ($dt) {
                  //skip datatable;
                  $x =1;
              }*/
         $class = $content->getAttribute('class');
         if ($class && $class === 'select2-search__field') {
             $x = 1;
         }
         if (false !== strpos($content->getParent()->getParent()->getAttribute('class'), 'CodeMirror')) {
             $x = 1;
             $p = $content->getParent()->getParent()->getParent()->getParent();
         } else {
             if ($input->getType() === 'search') {
                 $x = 1;
             }
             $x = 1;
             $p = $content;
         }
         $label = $p->find('css', 'label');
         if ($label) {
//.........这里部分代码省略.........
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:101,代码来源:Inputs.php

示例7: guess_field_type

 /**
  * Guesses a basic field type and returns it.
  *
  * This method is intended to detect HTML form fields when no
  * maharaform-specific elements have been detected.
  *
  * @param NodeElement $fieldnode
  * @param Session $session
  * @return string|bool The field type or false.
  */
 public static function guess_field_type(NodeElement $fieldnode, Session $session)
 {
     // Textareas are considered text based elements.
     $tagname = strtolower($fieldnode->getTagName());
     if ($tagname == 'textarea') {
         // If there is an iframe with $id + _ifr there a TinyMCE editor loaded.
         $xpath = '//iframe[@id="' . $fieldnode->getAttribute('id') . '_ifr"]';
         if ($session->getPage()->find('xpath', $xpath)) {
             return 'editor';
         }
         return 'textarea';
     } else {
         if ($tagname == 'input') {
             $type = $fieldnode->getAttribute('type');
             switch ($type) {
                 case 'text':
                 case 'password':
                 case 'email':
                 case 'file':
                     return 'text';
                 case 'checkbox':
                     return 'checkbox';
                     break;
                 case 'radio':
                     return 'radio';
                     break;
                 default:
                     // Here we return false because all text-based
                     // fields should be included in the first switch case.
                     return false;
             }
         } else {
             if ($tagname == 'select') {
                 // Select tag.
                 return 'select';
             }
         }
     }
     // We can not provide a closer field type.
     return false;
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:51,代码来源:BehatFieldManager.php

示例8: parseAttribs

 /**
  * @param $node
  */
 public static function parseAttribs(NodeElement $node)
 {
     $tagName = $node->getTagName();
     $outer = $node->getOuterHtml();
     $dom = new \DOMDocument();
     $dom->loadHTML('<?xml encoding="UTF-8">' . $outer);
     $sxe = simplexml_import_dom($dom);
     /** @var \SimpleXMLElement $tag */
     $tag = $sxe->body->{$tagName};
     $a = (array) $tag->attributes();
     $attributes = $a['@attributes'];
     return $attributes;
 }
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:16,代码来源:Element.php

示例9: findRow

 /**
  * Find and return the row (<tr>) where the passed element is
  * This is useful when you intend to know if another element is in the same
  * row
  *
  * @param \Behat\Mink\Element\NodeElement $element The element in the intended row
  *
  * @return \Behat\Mink\Element\NodeElement The <tr> element node
  *
  * @throws \PHPUnit_Framework_AssertionFailedError
  */
 public function findRow(NodeElement $element)
 {
     $initialTag = $element->getTagName();
     while (strtolower($element->getTagName()) !== "tr" && strtolower($element->getTagName()) !== "body") {
         $element = $element->getParent();
     }
     Assertion::assertEquals(strtolower($element->getTagName()), "tr", "Couldn't find a parent of '{$initialTag}' that is a table row");
     return $element;
 }
开发者ID:ezsystems,项目名称:behatbundle,代码行数:20,代码来源:Context.php

示例10: reverse

 public static function reverse(NodeElement $selectNode, InputSelect $select)
 {
     if ($selectNode->getTagName() === 'select') {
         $select->setNode($selectNode);
     } else {
         throw new LogicException('tag mismatch');
     }
     $parents = $select->getParents();
     if ($select->hasAttribute('name')) {
         $select->setName($select->getAttribute('name'));
     }
     $res = self::findLabelByParent($select);
     if (!$res) {
         $x = 1;
     }
     $select->setLabel($res);
     //return;
     /*if (!$id && !$name) {
                 if (false !== strpos($selectNode->getAttribute('class'), 'dtSearch')) { //datatables column filter
                     continue;
                 }
     
                 $dt = $content->find('css', 'table.table-columnfilter');
                 if ($dt) {
                     //skip datatable;
                     continue;
                 }
                 $class = $selectNode->getAttribute('class');
                 if ($class && $class == 'select2-search__field') {
                     continue;
                 }
                 if (false !== strpos($selectNode->getParent()->getParent()->getAttribute('class'), 'CodeMirror')) {
                     continue;
                     $p = $selectNode->getParent()->getParent()->getParent()->getParent();
                 } else {
                     if ($type == 'search') {
                         continue;
                     }
                     $x = 1;
                     $p = $selectNode;
                 }
     
     
                 $label = $p->find('css', 'label');
                 if ($label) {
                     $label = $label->getText();
                 } else {
                     $label = $selectNode->getAttribute('placeholder');
                 }
                 self::addNotNull($elem, 'label', $label);
     
                 $xpath = $selectNode->getXpath();
                 self::addNotNull($elem, 'xpath', $xpath);
     
             } else {
                 if (false !== strpos($name, '_length')) { //datatables per page
                     continue;
                 }
                 if ($name) {
                     $label = $selectNode->find('css', 'label[for="' . $name . '"]');
                     if (!$label) {
                         if ($type == 'checkbox') {
                             $p = $selectNode->getParent()->getParent()->getParent();
                             $h = $p->getHtml();
                             $h = $p->getOuterHtml();
     
                             $label = $p->getText();
                         }
                     }
                 } else {
     
                     $label = $selectNode->find('css', 'label[for=' . $id . ']');
                 }
                 if (!is_string($label)) {
     
                     if ($label) {
                         $label = $label->getText();
                     } else {
                         $label = $selectNode->getValue();
                     }
                 }
                 self::addNotNull($elem, 'label', $label);
             }
     
             $elements['inputs'][] = $elem;*/
 }
开发者ID:dafik,项目名称:cc-tests-reverse,代码行数:86,代码来源:Select.php


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