<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2>Thanks Bret -- took a few more lines in 1.4.2 (as I
mentioned earlier I haven't had success with 1.5 -- receive error on
IE.attach) -- anyway here's the code if anyone wants it -- including a test and
the html for the test file. Basically someone can see what methods/classes
were required to add the element.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2>I think that meta programming idea sounds really cool,
and I'd think could allow for dynamic extension for new/different
tags -- especially since this code is an exact dupe of div (and span and p
and others I suspect) -- just replacing li for div (correct case of
course).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2># feature tests for Li's<BR># revision: $Revision: 1.17
$</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2>$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
if $0 == __FILE__<BR>require 'setup'</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2>#EXTEND WATIR FOR LI TAGS -- cloned directly from
corresponding DIV code<BR>module Watir
<BR> module SupportsSubElements<BR>
def li(how, what)<BR> return
Li.new(self, how, what)<BR>
end<BR>
<BR> def
lis<BR> return
Lis.new(self)<BR> end<BR>
end<BR> class IE <BR> def
show_lis<BR> lis =
document.getElementsByTagName("LI")<BR>
puts "Found #{lis.length} li
tags"<BR>
index=1<BR> lis.each do
|d|<BR> puts
"#{index} id=#{d.invoke('id')}
class=#{d.invoke("className")}"<BR>
index+=1<BR>
end<BR> end<BR> end<BR>
<BR> class Li < SpanDivCommon <BR>
TAG = 'LI'<BR> def tag; TAG;
end<BR> def self.tag; TAG; end<BR>
end<BR> <BR> class Lis <
ElementCollections<BR> include
CommonCollection<BR> def element_class; Li;
end<BR> <BR> def
set_show_items<BR>
super<BR>
@show_attributes.delete(
"name")<BR>
@show_attributes.add( "className" , 20)<BR>
end<BR> end<BR>end<BR>#END EXTEND</FONT></SPAN></DIV>
<DIV> </DIV><SPAN class=849100103-12072006>
<DIV dir=ltr align=left><BR><FONT face=Arial color=#0000ff size=2>#TEST FOR LI
EXTEND<SPAN class=849100103-12072006> -- taken from P test cases</SPAN><BR>class
TC_Lis < Test::Unit::TestCase<BR> include
Watir<BR> <BR> def
setup()<BR> $ie.goto($htmlRoot +
"li.html")<BR> end<BR>
<BR> def test_li<BR>
assert($ie.li(:id,
'number1').exists?)<BR>
assert($ie.li(:index, 3).exists?)<BR>
assert($ie.li(:title,
'test_3').exists?)<BR>
<BR> assert_false($ie.li(:id,
'missing').exists?)<BR>
assert_false($ie.li(:index,
8).exists?)<BR>
assert_false($ie.li(:title,
'test_55').exists?)<BR>
<BR> assert_raises(
UnknownObjectException) {$ie.li(:id , 'missing').class_name
}<BR> assert_raises(
UnknownObjectException) {$ie.li(:id , 'missing').text
}<BR> assert_raises(
UnknownObjectException) {$ie.li(:id , 'missing').title
}<BR> assert_raises(
UnknownObjectException) {$ie.li(:id , 'missing').to_s
}<BR> assert_raises(
UnknownObjectException) {$ie.li(:id , 'missing').disabled
}<BR>
<BR> assert_equal( 'redText' ,
$ie.li(:index,1).class_name)<BR>
assert_equal( 'LI_tag_1' ,
$ie.li(:index,1).title)<BR>
assert_equal( 'This text is in a li with an id of number2' ,
$ie.li(:index,2).text)<BR> end<BR>
<BR> def
test_li_iterator<BR> assert_equal( 3,
$ie.lis.length)<BR> assert_equal(
'italicText',
$ie.lis[2].class_name)<BR>
assert_equal( 'number3',
$ie.lis[3].id)<BR>
<BR>
count=1<BR> $ie.lis.each do
|li|<BR>
assert_equal('number'+count.to_s ,
li.id)<BR>
count+=1<BR>
end<BR> assert_equal( count-1 ,
$ie.lis.length)<BR> end</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2>end<BR>#END
TEST</FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV dir=ltr align=left></SPAN><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2>HTML for test file 'li.html'</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"><BR><html><BR><head><BR>
<title>Test page for Div</title></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2><STYLE
TYPE="text/css"><BR> DIV
{font-size: 24pt;}<BR> .redText
{color: red;}<BR> .blueText {color:
blue;}<BR> .italicText {font-style:
italic;}</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><SPAN class=849100103-12072006><FONT face=Arial
color=#0000ff size=2> SPAN {font-size:
18pt;}<BR> .redText {color:
red;}<BR> .blueText {color:
blue;}<BR> .italicText {font-style:
italic;}</FONT></SPAN></DIV>
<DIV> </DIV><SPAN class=849100103-12072006><FONT face=Arial color=#0000ff
size=2>
<DIV dir=ltr align=left><BR>
P{font-size: 24pt;}<BR> .redText
{color: red;}<BR> .blueText {color:
blue;}<BR> .italicText {font-style:
italic;}</DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><BR></STYLE></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><BR></head><BR><body><BR>CVS Revision:
"$Revision: 1.5 $"<BR><br><BR><br><BR><ul><BR><li id =
number1 title = "LI_tag_1" class=redText >This text is in a li with an id of
number1 and title of LI_tag_1</p><BR><br><BR><li id = number2
title = "LI_tag_2" class=italicText >This text is in a li with an id of
number2</p><BR><br><BR><li id = number3 title = "test_3"
class=blueText >This text is in a li with an id of
number3</p><BR></ul><BR></body><BR></html></FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> wtr-general-bounces@rubyforge.org
[mailto:wtr-general-bounces@rubyforge.org] <B>On Behalf Of </B>Bret
Pettichord<BR><B>Sent:</B> Tuesday, July 11, 2006 5:03 PM<BR><B>To:</B>
wtr-general@rubyforge.org<BR><B>Subject:</B> Re: [Wtr-general] Lists
question<BR></FONT><BR></DIV>
<DIV></DIV>On 7/11/06, <B class=gmail_sendername>Attebery, Bill</B> <<A
href="mailto:Bill.Attebery@twtelecom.com">Bill.Attebery@twtelecom.com</A>>
wrote:
<DIV><SPAN class=gmail_quote></SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV>
<P><FONT face=Arial size=2>Has anyone written code to handle
<UL>/<OL> and <LI> tags -- as a collection with
iterators?</FONT> <BR><FONT face=Arial size=2>I have the following HTML -- and
I'd like to be able to handle the LIs as a collection and iterate through them
(and access the link within) based on the text -- has anyone done this?
If not I presume I'll have to extend watir and essentially clone the
Spans, Divs or Ps classes and methods? </FONT></P>
<P><FONT face=Arial size=2>Any
suggestions?</FONT><BR></P></DIV></DIV></BLOCKQUOTE>
<DIV>I recommend extending Watir.<BR><BR>I've been steadily reducing the amount
of code it takes to support a new tag in Watir. This shouldn't be very hard. It
should take about 13 lines of code to add support for each each of these in 1.5
-- if you include "end" as a line of code.<BR><BR>I've recently been reading up
about meta programming and suspect that i could rework Watir so that adding
support for tags like these would only take three or four lines of code.
<BR><BR>Bret<BR></DIV><BR></DIV></BODY></HTML>
<table><tr><td bgcolor=#ffffff><font color=#000000>The content contained in this electronic message is not intended to<br>
constitute formation of a contract binding TWTC. TWTC will be<br>
contractually bound only upon execution, by an authorized officer, of<br>
a contract including agreed terms and conditions or by express<br>
application of its tariffs.<br>
<br>
This message is intended only for the use of the individual or entity<br>
to which it is addressed. If the reader of this message is not the<br>
intended recipient, or the employee or agent responsible for<br>
delivering the message to the intended recipient, you are hereby<br>
notified that any dissemination, distribution or copying of this<br>
message is strictly prohibited. If you have received this<br>
communication in error, please notify us immediately by replying to<br>
the sender of this E-Mail or by telephone.<br>
</font></td></tr></table>