[wtr-general] "dd" element of HTML

3 views
Skip to first unread message

Niharika Patro

unread,
Feb 18, 2009, 5:25:25 AM2/18/09
to watir-...@googlegroups.com
Hi,

I have a "dd" (Data Definition) element inder a "dl" (Definition list).

The x-path for it is :  "/html/body/div[@id='vidmn']/div[@id='content']/div[@id='vid_pnp']/div[2]/div[@id='onecol']/div[@id='rel_outer']/div/dl[@id='pnp_relvid1']/dd[@id='rvid4']/div[@id='rel_4']/dl/dd[1]"

I want to declare the object in the repository file as :- @data = @browser.class(:xpath, "/html/body/div[@id='vidmn']/div[@id='content']/div[@id='vid_pnp']/div[2]/div[@id='onecol']/div[@id='rel_outer']/div/dl[@id='pnp_relvid1']/dd[@id='rvid4']/div[@id='rel_4']/dl/dd[1]")

What should be the class in the above definition ?

Kindly help me...

Regards
Niharika

John Kolokotronis

unread,
Feb 18, 2009, 5:56:48 AM2/18/09
to Watir General

I don't think there is a class for a "dd" element - but since you are
using xpath to identify your element anyway, you don't need it - just
use:

@browser.element_by_xpath("//yourxpathExpressionGoesHere")

And it might be a good idea to shorten that xpath if you it identifies
correctly further down the tree, like on the last div or something.

Regards,

John

Niharika Patro

unread,
Feb 18, 2009, 6:11:13 AM2/18/09
to watir-...@googlegroups.com
Thanks John :)

Yes, I would shorten the xpath to "//div[@id='rel_outer']/
div/dl[@id='pnp_relvid1']/dd[@id='rvid4']/div[@id='rel_4']/dl/dd[1]"

Regards
Niharika

Darin Duphorn

unread,
Feb 18, 2009, 9:20:13 AM2/18/09
to watir-...@googlegroups.com

 

I had the same thing.

 

Goto

 

C:\ruby\lib\ruby\gems\1.8\gems\watir-1.6.2\lib\watir

 

Open non_control_elements

 

 

Find This:

 

# this class is used to deal with Div tags in the html page. http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/div.asp?frame=true

  # It would not normally be created by users

  class Div < NonControlElement

    TAG = 'DIV'

  end

 

Place this under that line.

 

# this class is used by My Companhy instead of a div tag.

  class DD < NonControlElement

    TAG = 'DD'

  end

 

 

Include this in your script

 

def dd(how, what)

  return dd.new(self, how, what)

end

 

 

#I use it like this.

label_id = $ie.dd(:after?, $ie.label(:text,label)) 

 

Hope this helps.

 

 

Remember to add this to your documentation because when you update you may have to re-add

 

 

Darin

 

 


Niharika Patro

unread,
Feb 19, 2009, 2:07:09 AM2/19/09
to watir-...@googlegroups.com
Thanks Darin, the info is very useful :)

Regards
Niharika
Reply all
Reply to author
Forward
0 new messages