Skip to content
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

Fix bug in collection item xpath generation #199

Merged
merged 2 commits into from
Jul 31, 2017

Conversation

choruk
Copy link
Contributor

@choruk choruk commented Jul 22, 2017

Without the parentheses, this xpath selector calculation is incorrect. As an example, lets say the item_xpath evaluates as ".//someLocator[1]". What this selector is actually specifying is: find all someLocator elements under the current node that are the first child of their parent element. What we really want to say is: find exactly the first someLocator element. In order to get this behavior, we need to wrap the part of the locator that is not the array indexing in parentheses, due to the order of precendence of the xpath operators ([] has higher precedence than //).

Without the parentheses, this xpath selector calculation is incorrect. As an example, lets say the item_xpath evaluates as ".//someLocator[1]". What this selector is actually specifying is: find all someLocator elements under the current node that are the first child of their parent element. What we really want to say is: find exactly the first someLocator element. In order to get this behavior, we need to wrap the part of the locator that is not the array indexing in parentheses, due to the order of precendence of the xpath operators ([] has higher precedence than //).
@dtognazzini
Copy link
Contributor

👍 I wonder if this was the root cause for #142. Any chance you'd mind adding a selenium test showing this to work?

- update form html to have an element in between the book field rows container and the individual book field row
- update page object to not have item_locator that is direct descendant of collection locator
@choruk
Copy link
Contributor Author

choruk commented Jul 25, 2017

@dtognazzini: It seems likely that this issue is the root cause for #142. I just pushed up a new commit that modifies the existing html / page objects to highlight this issue. If you take away my change of adding the parentheses, any test that tries to access an item in the books collection on the PageObjects::Authors::NewPage object will fail (one example is the test_complex_form test).

@dtognazzini
Copy link
Contributor

👍

Copy link

@haobo-chen haobo-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@choruk choruk merged commit 2d427c8 into master Jul 31, 2017
@choruk choruk deleted the cpFixCollectionItemXpathBug branch July 31, 2017 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants