當前位置: 首頁>>代碼示例>>PHP>>正文


PHP NodeElement::getText方法代碼示例

本文整理匯總了PHP中Behat\Mink\Element\NodeElement::getText方法的典型用法代碼示例。如果您正苦於以下問題:PHP NodeElement::getText方法的具體用法?PHP NodeElement::getText怎麽用?PHP NodeElement::getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Behat\Mink\Element\NodeElement的用法示例。


在下文中一共展示了NodeElement::getText方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetText

 public function testGetText()
 {
     $expected = 'val1';
     $node = new NodeElement('text_tag', $this->session);
     $this->driver->expects($this->once())->method('getText')->with('text_tag')->will($this->returnValue($expected));
     $this->assertEquals($expected, $node->getText());
 }
開發者ID:jordi12100,項目名稱:Mink,代碼行數:7,代碼來源:NodeElementTest.php

示例2: assertNodeElementContainsText

 /**
  * Check if the given node has the given text.
  *
  * @param NodeElement $element
  * @param string      $text
  *
  * @throws \PHPUnit_Framework_AssertionFailedError
  */
 private function assertNodeElementContainsText(NodeElement $element, $text)
 {
     $actual = $element->getText();
     $regex = '/' . preg_quote($text, '/') . '/ui';
     $message = sprintf('The text "%s" was not found in the text of the %s.', $text, $actual);
     PHPUnit::assertTrue((bool) preg_match($regex, $actual), $message);
 }
開發者ID:EllynB,項目名稱:Incipio,代碼行數:15,代碼來源:FrontContext.php

示例3: deleteComment

 /**
  * @param NodeElement $comment
  *
  * @throws \LogicException
  */
 public function deleteComment(NodeElement $comment)
 {
     $link = $comment->find('css', 'span.remove-comment');
     if (null === $link) {
         throw new \LogicException(sprintf('Delete link of comment "%s" not found.', $comment->getText()));
     }
     $link->click();
 }
開發者ID:noglitchyo,項目名稱:pim-community-dev,代碼行數:13,代碼來源:Edit.php

示例4: getComment

 /**
  * @param NodeElement $element
  * @return string
  */
 protected function getComment(NodeElement $element)
 {
     return $element->getText();
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:8,代碼來源:BlogComment.php

示例5: fillMultiSelect2Field

 /**
  * Fills a multivalues Select2 field with $value, identified by its $label.
  * It deletes existing selected values from field if not present in $value.
  *
  * $value can be a string of multiple values. Each value must be separated with comma, eg :
  * 'Hot, Dry, Fresh'
  *
  * @param NodeElement $label
  * @param string      $value
  *
  * @throws \InvalidArgumentException
  */
 protected function fillMultiSelect2Field(NodeElement $label, $value)
 {
     $allValues = explode(',', $value);
     $selectedValues = $label->getParent()->findAll('css', '.select2-search-choice');
     $selectedTextValues = array_map(function ($selectedValue) {
         return $selectedValue->getText();
     }, $selectedValues);
     // Delete tag from right to left to prevent select2 DOM change
     $selectedValues = array_reverse($selectedValues);
     foreach ($selectedValues as $selectedValue) {
         if (false === in_array($selectedValue->getText(), $allValues)) {
             $closeButton = $selectedValue->find('css', 'a');
             if (!$closeButton) {
                 throw new \InvalidArgumentException(sprintf('Could not find "%s" close button for "%s"', trim($selectedValue->getText()), $label->getText()));
             }
             $closeButton->click();
         }
     }
     $allValues = array_filter($allValues);
     if (1 === count($allValues) && null !== $label->getParent()->find('css', 'select')) {
         $value = array_shift($allValues);
         $this->fillSelectField($label, $value);
     }
     // Fill in remaining values
     $remainingValues = array_diff($allValues, $selectedTextValues);
     foreach ($remainingValues as $value) {
         if (trim($value)) {
             $label->click();
             $label->click();
             $option = $this->spin(function () use($value) {
                 return $this->find('css', sprintf('.select2-result:not(.select2-selected) .select2-result-label:contains("%s")', trim($value)));
             }, sprintf('Could not find option "%s" for "%s"', trim($value), $label->getText()));
             $option->click();
         }
     }
 }
開發者ID:userz58,項目名稱:pim-community-dev,代碼行數:48,代碼來源:Form.php

示例6: fillMultiSelect2Field

 /**
  * Fills a multivalues Select2 field with $value, identified by its $label.
  * It deletes existing selected values from field if not present in $value.
  *
  * $value can be a string of multiple values. Each value must be separated with comma, eg :
  * 'Hot, Dry, Fresh'
  *
  * @param NodeElement $label
  * @param string      $value
  *
  * @throws \InvalidArgumentException
  */
 protected function fillMultiSelect2Field(NodeElement $label, $value)
 {
     $allValues = explode(',', $value);
     $selectedValues = $label->getParent()->findAll('css', '.select2-search-choice');
     $selectedTextValues = array_map(function ($selectedValue) {
         return $selectedValue->getText();
     }, $selectedValues);
     // Delete tag from right to left to prevent select2 DOM change
     $selectedValues = array_reverse($selectedValues);
     foreach ($selectedValues as $selectedValue) {
         if (false === in_array($selectedValue->getText(), $allValues)) {
             $closeButton = $selectedValue->find('css', 'a');
             if (!$closeButton) {
                 throw new \InvalidArgumentException(sprintf('Could not find "%s" close button for "%s"', trim($selectedValue->getText()), $label->getText()));
             }
             $closeButton->click();
         }
     }
     // Removing tags in MultiSelect2 drops an "animation" with opacity, we must
     // wait for it to completly vanish in order to reopen select list
     $this->getSession()->wait(2000);
     $allValues = array_filter($allValues);
     if (1 === count($allValues) && null !== $label->getParent()->find('css', 'select')) {
         $value = array_shift($allValues);
         $this->fillSelectField($label, $value);
     }
     // Fill in remaining values
     $remainingValues = array_diff($allValues, $selectedTextValues);
     foreach ($remainingValues as $value) {
         if (trim($value)) {
             $label->getParent()->find('css', 'input[type="text"]')->click();
             $this->getSession()->wait(100000, "\$('div:contains(\"Searching\")').length == 0");
             $option = $this->find('css', sprintf('.select2-result:not(.select2-selected) .select2-result-label:contains("%s")', trim($value)));
             if (!$option) {
                 throw new \InvalidArgumentException(sprintf('Could not find option "%s" for "%s"', trim($value), $label->getText()));
             }
             $option->click();
         }
     }
 }
開發者ID:somane,項目名稱:pim-community-dev,代碼行數:52,代碼來源:Form.php

示例7: fillTextField

 /**
  * Fills a text field element with $value, identified by its container or label.
  *
  * @param NodeElement $fieldContainerOrLabel
  * @param string      $value
  *
  * @throws ElementNotFoundException
  */
 protected function fillTextField(NodeElement $fieldContainerOrLabel, $value)
 {
     $field = $fieldContainerOrLabel->find('css', 'div.field-input input');
     // no field found, we're using a label
     if (!$field) {
         $field = $fieldContainerOrLabel->getParent()->getParent()->find('css', 'div.field-input input');
     }
     if (!$field) {
         $field = $fieldContainerOrLabel->getParent()->find('css', 'div.controls input');
     }
     if (null === $field) {
         throw new ElementNotFoundException(sprintf('No text field can be found from "%s".', $fieldContainerOrLabel->getText()));
     }
     $field->setValue($value);
     $this->getSession()->executeScript('$(\'.field-input input[type="text"]\').trigger(\'change\');');
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:24,代碼來源:ProductEditForm.php

示例8: getAttributesFromElement

 private function getAttributesFromElement(NodeElement $element)
 {
     $attr = array();
     $attr['id'] = strtolower($element->getAttribute('id'));
     $attr['name'] = strtolower($element->getAttribute('name'));
     $attr['label'] = strtolower($element->getAttribute('label'));
     $attr['value'] = strtolower($element->getAttribute('value'));
     $attr['text'] = strtolower($element->getText());
     $attr['title'] = strtolower($element->getAttribute('title'));
     return $attr;
 }
開發者ID:wizzbitnl,項目名稱:CCDNForumForumBundle,代碼行數:11,代碼來源:FeatureContext.php


注:本文中的Behat\Mink\Element\NodeElement::getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。