It's hard because text exist in many tags.
I've done the following.
#Cycles through all the Span Tags
$ie.spans.each {|span|
#Verify Labe is Visible
if span.visible?.to_s == "true"
#Label Matches Expected Label
if text_value == span.text
text_exists_flg = "True"
break
end
end
}
#Iterates through all li tags
if text_exists_flg == "False"
#Cycles through all the P Tags
$ie.lis.each {|li|
#Verify unordered list value is Visible
if li.visible?.to_s == "true"
#unordered list Expected Label
if text_value.gsub(/\r?\n/, " ").strip == li.text.gsub(/\r?
\n/, " ").strip
text_exists_flg = "True"
break
end
end
}
end
if text_exists_flg == "False"
#Cycles through all the P Tags
$ie.ps.each {|p|
#Verify Labe is Visible
if p.visible?.to_s == "true"
#Label Matches Expected Label
if text_value.to_s.gsub(/\r?\n/, " ").strip ==
p.text.to_s.gsub(/\r?\n/, " ").strip
text_exists_flg = "True"
break
end
end
}
end
#Iterates through all the dif tages
if text_exists_flg == "False"
#Cycles through all the P Tags
$ie.divs.each {|div|
#Verify Labe is Visible
if div.visible?.to_s == "true"
#Label Matches Expected Label
if text_value.gsub(/\r?\n/, " ").strip == div.text.gsub(/\r?
\n/, " ").strip
text_exists_flg = "True"
break
end
end
}
end
#Cycle through all Table Cells incase the Text Exists within a table
if text_exists_flg == "False"
$ie.tables.each {|t|
t.each do|row|
row.each do |cell|
if cell.text.include?(text_value.to_s.gsub(/\r?\n/, "
").strip).to_s == "true"
text_exists_flg = "True"
break
end
end
if text_exists_flg == "True"
break
end
end
if text_exists_flg == "True"
break
end
}
end
#Cycle through all Address Tags
if text_exists_flg == "False"
$ie.document.getElementsByTagName('ADDRESS').each{|
address|
#Label Matches Expected Label
if text_value.gsub(/\r?\n/, "").strip == address.innertext.gsub(/
\r?\n/, " ").strip
text_exists_flg = "True"
break
end
}
end
#Cycle through all DD Tags
if text_exists_flg == "False"
$ie.document.getElementsByTagName('DD').each{|dd|
#Label Matches Expected Label
if text_value.gsub(/\r?\n/, "").strip == dd.innertext.gsub(/\r?
\n/, " ").strip
text_exists_flg = "True"
break
end
}
end
#Cycle through all LEGEND Tags
if text_exists_flg == "False"
$ie.document.getElementsByTagName('LEGEND').each{|address|
#Label Matches Expected Label
if text_value.gsub(/\r?\n/, "").strip == address.innertext.gsub(/
\r?\n/, " ").strip
text_exists_flg = "True"
break
end
}
end
On Oct 13, 8:20 am, "bugs apple" <[EMAIL PROTECTED]> wrote:
> Hi, all
>
> As we known, pagecontainstext method could check the text that contained
> current page, including the values in the object
>
> maybe the pagecontainstext method was designed like below,
> if (ie.getDocument.body.innertext =~ /#{text}/) != nil
> puts true
> else
> puts false
> end
>
> but, that is not my expect, I only want to check the pure text, as the label
> displayed on page, which is not belong to any object value or
> dropdown/select list item.
> who can provide some good way to check the text?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---