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 <cristin...@gmail.com 
> <javascript:>>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 <bis...@gmail.com<javascript:>
>> > 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 <cristin...@gmail.com <javascript:>
>>> > 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.
>>>>  
>>>> watir-...@googlegroups.com <javascript:>
>>>> http://groups.google.com/group/watir-general
>>>> watir-genera...@googlegroups.com <javascript:>
>>>>
>>>> --- 
>>>> 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 watir-genera...@googlegroups.com <javascript:>.
>>>> 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.
>>>  
>>> watir-...@googlegroups.com <javascript:>
>>> http://groups.google.com/group/watir-general
>>> watir-genera...@googlegroups.com <javascript:>
>>>
>>> --- 
>>> 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 watir-genera...@googlegroups.com <javascript:>.
>>> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--- 
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 watir-general+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to