Hello,
You can use a XPath expression to get to the element you want.
This worked for me, using the HTML piece of code you provided:
--
require "rubygems"
require "watir"
@ie = Watir::IE.new
@ie.goto "file://c:/test.html"
@text = @ie.element_by_xpath("//span[contains(.,'Test
1')]/following::td[1]")
puts @text.innerText
---
Regards,
FK
On Mon, May 3, 2010 at 5:12 PM, watirRookie <[email protected]> wrote:
> hi,
> I want to get to the cell value (Pass, Fail, Blocked) based on the
> <span> values (Test 1, Test 2, Test 3) inside the divs.
> I can not use id's like div(:id, "node1") because the id's are dynamic
> and change often. The only way is to use the text inside the <span> to
> identify a particular <div> and then calling table on that div to get
> to the cell value.
>
> I can identify a particular <div> based on <span> text value but then
> can not call table on that. Can someone please help!
>
> <div class="Node" id="node1">
> <span style="font-weight:bold;">Test 1</span>
> <table>
> <tr><td>Pass</td></tr>
> </table>
> </div>
> <div class="Node" id="node2">
> <span style="font-weight:bold;">Test 2 </span>
> <table>
> <tr><td>Fail</td></tr>
> </table>
> </div>
> <div class="Node" id="node3">
> <span style="font-weight:bold;">Test 3 </span>
> <table>
> <tr><td>Blocked</td></tr>
> </table>
> </div>
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> You received this message because you are subscribed to
> http://groups.google.com/group/watir-general
> To post: [email protected]
> To unsubscribe:
> [email protected]<watir-general%[email protected]>
>
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
You received this message because you are subscribed to
http://groups.google.com/group/watir-general
To post: [email protected]
To unsubscribe: [email protected]