-
Notifications
You must be signed in to change notification settings - Fork 284
More methods for NodeElement children manipulations #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
cc1ce2e
96f97b1
4d7d991
c499b97
0f20bfe
d832fd6
ef96fdb
ca4a9e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,91 @@ public function getParent() | |
| { | ||
| return $this->find('xpath', '..'); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Returns All child elements(including descendant) to the current one. | ||
| * | ||
| * @return NodeElements|null | ||
| */ | ||
| public function getAllChildren() | ||
| { | ||
| return $this->findAll('xpath', 'descendant::*'); | ||
| } | ||
|
|
||
| /** | ||
| * Returns All direct child elements(NOT including deeper descendant) to the current one. | ||
| * | ||
| * @return NodeElements|null | ||
| */ | ||
| public function getDirectChildren() | ||
| { | ||
| return $this->findAll('xpath', 'child::*'); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the first child element to the current one. | ||
| * | ||
| * @return NodeElement|null | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend using |
||
| */ | ||
| public function getFirstChild() | ||
| { | ||
| $elements = $this->findAll('xpath', 'child::*'); | ||
| return $elements[0]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just replacing |
||
| } | ||
|
|
||
| /** | ||
| * Returns the last direct child element to the current one. | ||
| * | ||
| * @return NodeElement|null | ||
| */ | ||
| public function getLastChild() | ||
| { | ||
| $elements = $this->findAll('xpath', 'child::*'); | ||
| return $elements[count($elements) - 1]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
|
|
||
| /** | ||
| * Returns all preceding sibling elements to the current one. | ||
| * | ||
| * @return NodeElements|null | ||
| */ | ||
| public function getPreviousSiblings() | ||
| { | ||
| return $this->findAll('xpath', 'preceding-sibling::*'); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the preceding sibling element close to the current one. | ||
| * | ||
| * @return NodeElement|null | ||
| */ | ||
| public function getPreviousSibling() | ||
| { | ||
| $elements = $this->findAll('xpath', 'preceding-sibling::*'); | ||
| return $elements[count($elements) - 1]; | ||
| } | ||
|
|
||
| /** | ||
| * Returns all following sibling elements to the current one. | ||
| * | ||
| * @return NodeElements|null | ||
| */ | ||
| public function getNextSiblings() | ||
| { | ||
| return $this->findAll('xpath', 'following-sibling::*'); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the following sibling element close to the current one. | ||
| * | ||
| * @return NodeElement|null | ||
| */ | ||
| public function getNextSibling() | ||
| { | ||
| $elements = $this->findAll('xpath', 'following-sibling::*'); | ||
| return $elements[0]; | ||
| } | ||
|
|
||
| /** | ||
| * Returns current node tag name. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,31 @@ public function findById($id) | |
|
|
||
| return $this->find('named', array('id', $id)); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Finds element by its name. | ||
| * | ||
| * @param string name element name | ||
| * @return NodeElement|NodeElements|null | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| */ | ||
| public function findByName($name) | ||
| { | ||
| $name = $this->getSelectorsHandler()->xpathLiteral($name); | ||
| return $this->find('xpath', ".//*[@name=$name]"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It appears that method is displaced. The actual xpath should be defined in the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. called this method public function find($selector, $locator) in .../Mink/src/Behat/Mink/Element/Element.php
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please rephrase, I don't get what you mean.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aik099 please refer to public function getParent()
{
return $this->find('xpath', '..');
}in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now it's odd. I still don't get what you mean. Have you understood my original comment about
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what I mean: https://github.com/Behat/Mink/blob/master/src/Behat/Mink/Element/TraversableElement.php#L33 The
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, got you now.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course it's not there. I'm telling that you should add it there and then use it. |
||
| } | ||
|
|
||
| /** | ||
| * Finds elements by its tag. | ||
| * | ||
| * @param string tag element tag | ||
| * @return NodeElements|null | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be |
||
| */ | ||
| public function findByTag($tag) | ||
| { | ||
| $tag = $this->getSelectorsHandler()->xpathLiteral($tag); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get. Why you need to perform Xpath-safe escaping of the string if it is a CSS selector? Also since this method doesn't do anything special and people can really give any CSS string instead tag, then it creates more confusion, than benefits it can provide. |
||
| return $this->findAll('css', $tag); | ||
| } | ||
|
|
||
| /** | ||
| * Checks whether element has a link with specified locator. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct indentation. I guess you're using TABs here (in in other places in this PR), which doesn't comply with PSR-2.