You can do parent(index: 2). At least I'm pretty sure it is 0-based index,
it might be 3.
Even better, though, you can do: parent(class: 'tab'), which will grab the
first parent element that has a class 'tab'
On Sunday, July 22, 2018 at 11:20:08 PM UTC-5, NaviHan wrote:
>
> I have two tabs on the page with the html code as
>
> <div class="tabs types-tabs">
> <div class="inner-tabs">
> <div class="tab active">
> <div class="outer-tab">
> <div class="inner-tab">
> <span class="icon icon-header-bag-black"></span>
> <span class="tab-label" for="tab-online">Online</span>
> </div>
> </div>
> </div>
>
> <div class="tab">
> <div class="outer-tab">
> <div class="inner-tab">
> <span class="icon icon-in-store-house-icon"></span>
> <span class="tab-label" for="tab-instore">In-Store
> </span>
> </div>
> </div>
> </div>
>
> </div>
> </div>
>
> Based on the tab which is selected the <div class="tab active"> is set to
> "active"
>
> I defined the two tabs as below
>
> span(:online_tab, :for => 'tab-online')
> span(:instore_tab, :for => 'tab-instore')
>
>
> I need to traverse up the DOM from either of these spans to find if the
> user has selected it.
>
> Im using this snippet here to do that
>
> instore_tab_element.parent.parent.parent.attribute('class')
>
>
> Instead of using multiple "parent" is there a way to get to the nth parent?
>
--
--
Before posting, please read
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.