The reason code like this
puts $browser.dt(:text,"Account ID").dd(:xpath,"following-
sibling::*").text
is failing is because you are in effect saying, take this DT element I've
identifed, look INSIDE it for a DD that is defined thusly But the DD is a
sibling of the DT, not contained within the DT, so it's never going to get
found that way.
If you want to look for something using an xpath statement using a
following-sibling specifier, you'd want to look inside the DL, and fully
specify the sibling object..
On Friday, June 22, 2012 12:01:39 AM UTC-7, gajendra wrote:
>
> Hi,
>
> I tried the following thing, but getting an error
> *HTML *Code
>
> <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>
>
>
> *Watir code*
>
> puts $browser.dl(:class =>
> "col_3").dt(:text,"Account ID").text
>
> puts
> $browser.dt(:text,"Account ID").dd(:xpath,"following-sibling::*").text
>
> puts " "
>
> puts $browser.dl(:class =>
> "col_3").dt(:text,"System Account ID").text
>
> puts
> $browser.dt(:text,"System Account
> ID").dd(:xpath,"following-sibling::*").text
>
> puts " "
>
>
> *Error*
>
>
> C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:66:in
>
> `assert_exists': Unable to locate element, using {:tag_name=>["dd"],
> :xpath=>"following-sibling::*"} (Watir::Exception::UnknownObjectException)
> from
> C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.0.0/lib/watir-classic/element.rb:125:in
>
> `text'
> from alertmessage.rb:31:in `<main>'
>
>
> Could you please let me know how to fix this?
>
>
> Regards
>
> Gajendra
>
>
> On Thu, Jun 21, 2012 at 12:38 PM, Gajendra Jain
> <[email protected]>wrote:
>
>> Thanks. Could you please let me know how to create an HASH from the <DL>
>> tag.
>>
>> or Is it possible to know how many <DT> tags available under <DL> tag?
>>
>>
>>
>>
>> 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]