appfolio / ae_page_objects

Page Objects for Capybara
MIT License
28 stars 9 forks source link

Fix bug in collection item xpath generation #199

Closed choruk closed 7 years ago

choruk commented 7 years ago

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 commented 7 years ago

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

choruk commented 7 years ago

@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 commented 7 years ago

:+1: