On Thursday, June 21, 2012 12:08:16 AM UTC-7, gajendra wrote:
>
> Thanks. Could you please let me know how to create an HASH from the <DL> 
> tag.
>

OK, given the HTML looks like this

<dl class="col_3">

<dt>Account ID</dt>

<dd>INTRAWARE</dd>

<dt>System Account ID</dt>

<dd>7124712</dd>

<dt>Account Name</dt>

<dd>Intraware, Inc</dd>

<dt>Account Status</dt>

<dd>ACTIVE</dd>

<dt>Account Note</dt>

<dd>Content</dd>

<dt>Number of Active Members</dt>

<dd>79</dd>
</dl>

Then this should do what you want:

    keys = browser.dl(:class => 'col_3').dts
    values =  browser.dl(:class => 'col_3').dds

    list_as_a_hash = Hash[keys.zip values]

    #test it out...
    puts list_as_a_hash['Account Status']




> or Is it possible to know how many <DT> tags available under <DL> tag?
>

 the .length method will return the number of elements in an array, or most 
collections

 So if you had the code I gave above, then 

    keys.length
or 
    browser.dl(:class => 'col_3').dts.length

should return the number of DT's in the DL 

 

>
> On Thu, Jun 21, 2012 at 12:06 AM, Chuck van der Linden 
> <[email protected]>wrote:
>
>> This one is tricky because the Delimited List behaves in HTML a little 
>> like the DT is wrapped around the DD, but in fact they are just one after 
>> the other.
>>
>> I think we may need to consider if there could be some better means when 
>> dealing with these elements to have an association between the DT and the 
>> DD such that you could do something that looked like
>>
>>   browser.dt(:how => 'what').dd  and it would return the DD that is 
>> associated with that DT, as if the DT was a container.
>>
>>   Or perhaps there would be a way to treat a DL a bit like a hash (or 
>> maybe a method to create a hash from a DL) where the DT is the key, and the 
>> DD is the value
>>
>> In the meantime, you may have to do something similar to either making a 
>> hash out of the list contents, or building a list of the DT's, finding the 
>> one you want to determine its index, and then pluck out the DD you want.
>>
>>
>>
>> On Wednesday, June 20, 2012 3:27:11 AM UTC-7, gajendra wrote:
>>>
>>> Is there any way where i can find the index of the DT tag in the web 
>>> page? 
>>> There are so many values gets populated based on the value from the 
>>> previous screen. 
>>>
>>> In general the field like Account Name, System Account Id etc are 
>>> dynamic it may change the position in the webpage. So i need some generic 
>>> function/Statement where i pass the Value/Text of <DT> and it should 
>>> return me the value/text of <DD>
>>>
>>> Regards,
>>> Gajendra
>>>
>>> On Wed, Jun 20, 2012 at 3:48 PM, Željko Filipin <[email protected]>wrote:
>>>
>>>> On Wed, Jun 20, 2012 at 12:09 PM, Gajendra Jain <
>>>> [email protected]> wrote:
>>>> > But When i tried <DT> Account Name</DT>, i got the same value 
>>>> 37914766, Where as my expected value should be AccountName1
>>>>
>>>> Try this:
>>>>
>>>> browser.dt(:text => "Account Name ").parent.dd(:index => 1).text
>>>>
>>>> Željko
>>>> --
>>>> filipin.eu 
>>>>
>>>> -- 
>>>> 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<http://groups.google.com/group/watir-general>
>>>> watir-general+unsubscribe@**googlegroups.com<watir-general%[email protected]>
>>>>
>>>
>>>  -- 
>> 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]
>>
>
>

-- 
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]

Reply via email to