It works great!

@browser.h3(:text => "Brook").parent.parent.parent.button(:value => "View
Details").click

I didn't know about this. Can you tell me where is the best place to start
reading about .parent
.child


Thank you,
Cristina


On Thu, Mar 13, 2014 at 6:44 PM, Dan <[email protected]> wrote:

> I would recommend something like this actually.  If you have something
> that you know, like the name of the dog, you can work back up and down the
> tree.  Using index can be your only option sometimes, but it can be brittle.
>
> For example:
>
> b.h3(:text => "Hanna").parent.parent.button(:value => "View Details").click
>
> On Thursday, March 13, 2014 5:51:39 PM UTC-4, christina wrote:
>
>> Hi and thank you!
>>
>> I found the way:
>>
>> @browser.button(:value => 'View Details', :index => 0).click
>>
>> works great.
>>
>>
>>
>> On Thu, Mar 13, 2014 at 1:58 PM, c w <[email protected]> wrote:
>>
>>> Thank you!
>>>
>>> The question is when we go here http://puppies.herokuapp.com
>>>
>>> how can we click in an easy way on the View Detail button for Hanna? or
>>> any View Detail button as we do not have an id.
>>>
>>> Kind Regards,
>>> Cristina
>>>
>>>
>>> On Thu, Mar 13, 2014 at 6:03 AM, Oscar Rieken <[email protected]> wrote:
>>>
>>>> when you are using watir you almost never have to use xpath. you didnt
>>>> post any html so its kind of hard to give you a simpler way to locate
>>>> without using xpath. but I would probably try to break out just the
>>>> container and then locate the button inside of it.
>>>>
>>>>
>>>> On Wed, Mar 12, 2014 at 5:20 PM, c w <[email protected]> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am using the following and works.
>>>>> However my question is if there simple way to define these xpaths?
>>>>>
>>>>>
>>>>> When /^I click the first View Details button$/ do
>>>>>    @browser.button(:xpath, "/html/body/div[@id='
>>>>> container']/div[@id='wrapper']/div[@id='content']/div[@
>>>>> class='puppy_list'][1]/div[@class='list_line_odd']/div[@
>>>>> class='view']/form[@class='button_to']/div/input[@class='
>>>>> rounded_button']").click()
>>>>> end
>>>>>
>>>>> When /^I click the second View Details button$/ do
>>>>>   @browser.button(:xpath, "/html/body/div[@id='
>>>>> container']/div[@id='wrapper']/div[@id='content']/div[@
>>>>> class='puppy_list'][2]/div[@class='list_line_even']/div[@
>>>>> class='view']/form[@class='button_to']/div/input[@class='
>>>>> rounded_button']").click()
>>>>>
>>>>> end
>>>>>
>>>>>
>>>>> Kind Regards,
>>>>> Cristina
>>>>>
>>>>> --
>>>>> --
>>>>> Before posting, please read http://watir.com/support. 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.
>>>>>
>>>>
>>>>  --
>>>> --
>>>> Before posting, please read http://watir.com/support. 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.
>>>>
>>>
>>>
>>  --
> --
> Before posting, please read http://watir.com/support. 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.
>

-- 
-- 
Before posting, please read http://watir.com/support. 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.

Reply via email to