{"action":"created","issue":{"url":"https://api.github.com/repos/watir/watir/issues/451","repository_url":"https://api.github.com/repos/watir/watir","labels_url":"https://api.github.com/repos/watir/watir/issues/451/labels{/name}","comments_url":"https://api.github.com/repos/watir/watir/issues/451/comments","events_url":"https://api.github.com/repos/watir/watir/issues/451/events","html_url":"https://github.com/watir/watir/pull/451","id":174931233,"number":451,"title":"Parents & Siblings with XPath","user":{"login":"titusfortner","id":777185,"avatar_url":"https://avatars.githubusercontent.com/u/777185?v=3","gravatar_id":"","url":"https://api.github.com/users/titusfortner","html_url":"https://github.com/titusfortner","followers_url":"https://api.github.com/users/titusfortner/followers","following_url":"https://api.github.com/users/titusfortner/following{/other_user}","gists_url":"https://api.github.com/users/titusfortner/gists{/gist_id}","starred_url":"https://api.github.com/users/titusfortner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titusfortner/subscriptions","organizations_url":"https://api.github.com/users/titusfortner/orgs","repos_url":"https://api.github.com/users/titusfortner/repos","events_url":"https://api.github.com/users/titusfortner/events{/privacy}","received_events_url":"https://api.github.com/users/titusfortner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-09-04T04:46:20Z","updated_at":"2016-09-08T08:08:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/watir/watir/pulls/451","html_url":"https://github.com/watir/watir/pull/451","diff_url":"https://github.com/watir/watir/pull/451.diff","patch_url":"https://github.com/watir/watir/pull/451.patch"},"body":"This PR meets all of my proposed [criteria for new features](http://watirtight.com/2016/08/25/focus-of-watir.html#evaluation).\r\n[Associated watirspecs PR](https://github.com/watir/watirspec/pull/85)\r\n\r\n1. Being able to easily locate elements is one of the core purposes of Watir. While this feature idea was rejected by Jari in #270, I'd love for Watir to have a mantra of \"No More XPath!\" It would be great if there weren't any use cases for when XPath is the best way to locate an element. I think I've previously addressed his other two concerns with this alternate implementation. (Also of note is that the new `parent` implementation addresses Jari's 3rd concern for siblings).\r\n\r\n2. Our current javascript implementation causes issues when trying to evaluate the presence of a parent element. You can not call `#exist?` on a parent element that doesn't exist. See [this Stack Overflow question](http://stackoverflow.com/questions/38577957/rspec-and-watir-webdriver-assert-element-not-present/) for an example of when this is a problem faced by a real user.\r\n\r\n3. This solves #424 to my satisfaction. With XPath we don't need to make it recursive, and `parent(1)` is better than needing to include `grandparent` and `grandpa` and `granddad`, etc. :)\r\n\r\n4. Demand for this comes both from Blackbaud which made extensive usage of the feature and the people commenting in [Justin's blog](https://jkotests.wordpress.com/2013/08/21/locate-a-sibling-from-a-watir-element/)\r\n\r\n5. Also, since these elements (including parent) are not initialized with Selenium Element objects, they can be re-looked up if the browser is refreshed or they go stale, etc."},"comment":{"url":"https://api.github.com/repos/watir/watir/issues/comments/245524414","html_url":"https://github.com/watir/watir/pull/451#issuecomment-245524414","issue_url":"https://api.github.com/repos/watir/watir/issues/451","id":245524414,"user":{"login":"p0deje","id":665846,"avatar_url":"https://avatars.githubusercontent.com/u/665846?v=3","gravatar_id":"","url":"https://api.github.com/users/p0deje","html_url":"https://github.com/p0deje","followers_url":"https://api.github.com/users/p0deje/followers","following_url":"https://api.github.com/users/p0deje/following{/other_user}","gists_url":"https://api.github.com/users/p0deje/gists{/gist_id}","starred_url":"https://api.github.com/users/p0deje/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p0deje/subscriptions","organizations_url":"https://api.github.com/users/p0deje/orgs","repos_url":"https://api.github.com/users/p0deje/repos","events_url":"https://api.github.com/users/p0deje/events{/privacy}","received_events_url":"https://api.github.com/users/p0deje/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T08:08:20Z","updated_at":"2016-09-08T08:08:20Z","body":"My proposal is to actually make it fully compatible with existing Watir API and support all the locators. Current solution \"pretends\" to support locators (e.g. tag_name, index), but then why won't it work with class, text, data-* attributes or any other Watir locator.\r\n\r\nFor me, all the new methods should behave like `#element` and support all its locators.\r\n\r\nI see this API like this:\r\n\r\n```ruby\r\nbrowser.span.parent\r\nbrowser.span.parent(index: 1)\r\nbrowser.span.parent(class: 'foo')\r\nbrowser.span.parents\r\n\r\nbrowser.span.child\r\nbrowser.span.child(index: 1)\r\nbrowser.span.child(class: 'foo')\r\nbrowser.span.children\r\n\r\nbrowser.span.sibling      # next sibling\r\nbrowser.span.sibling(index: 1)      # second sibling\r\nbrowser.span.sibling(index: -1)     # previous sibling\r\nbrowser.span.siblings # all siblings\r\n```\r\n\r\nI'm not sure about `#sibling` as it's a bit confusing, need to think about it.\r\n\r\nAlso, is `#child` searches for immediate children or all of them? If all of them, than we can simply alias it to `#element`, it would be the same, won't it?"}}
{"actor":{"display_login":"p0deje"}}