Hi Mike,
I amended the html slightly as there were a couple of small
problems.
The anchor elements weren't being closed correctly and I substituted the
double-quotes
around the javascript declarations with single-quotes. (I don't think the
javscript works
proper if you have double-quotes inside double-quotes. )
However this doesn't fix your problem completely, it just allows you to call
the javascript
correctly I think.
I replaced the javascript function with a simple alert box that prints out
what node you clicked.
The bad part is that the only way i could locate the objects and click on
one of the buttons
was to introduce and id attribute into the <a> anchor tag.
Would it be feasible for you to do for all the links?
---------------------------------------
<html>
<head>
<title>Hello</title>
<script type="text/javascript">
function print(tree, nodeVal) {
alert('Clicked node' +nodeVal)
}
</script>
</head>
<body>
<table>
<tr>
<td class="false" height="20"><a id ="Home1"
href='javascript:print("my_tree#MA", "n=0000")'> <img height="8" width="8"
src="images/plus.gif" border="0" alt="Expand Root Node"></a>Original Home
Node</td>
</tr>
<tr>
<td class="selected" align="left" height="20"><a id
="Start2" href='javascript:print("my_tree#MA", "n=0001")'> <img height="8"
width="8" src="images/plus.gif" border="0" alt="Expand Node"></a> Original
Start Node</td>
</tr>
<tr>
<td class="selected" align="left" height="20">
<a id ="Home" href="javascript:print('my_tree#MA',
'n=0000')">
<img height="8" width="8"
src="images/plus.gif" border="0" alt="Expand Root Node">Home Node</a>
</td>
</tr>
<tr>
<td class="selected" align="left" height="20">
<a id ="Start" href="javascript:print('my_tree#MA',
'n=0001')" value="Start Node">
<img height="8" width="8"
src="images/plus.gif" border="0" alt="Expand Node">Start Node</a>
</td>
</tr>
</table>
</body>
</html>
-------------------------------------------
Have a go of this.
ie = Watir::IE.start("<url pointing to below html>")
home = ie.link(:id, /Home1/)
home.click
I think this clicks the first Home link.
HTH,
Mark.
-----Original Message-----
From: Mike Wilson [mailto:[EMAIL PROTECTED]
Sent: 17 October 2005 15:10
To: [email protected]
Subject: [Wtr-general] JavaScript Tree difficulties
Given a JavaScript tree which looks a bit like
- Home Node
+ Start Node
clicking on the little plus sign next to "Start Node" renders
- Home Node
- Start Node
+ Node 1
+ Node 2
+ Node 3
+ Node 4
and again, clicking each of those will expand to more nodes.
The html to create the first 2 nodes of this tree looks a bit like:
<table>
<tr>
<td>..</td>
</tr>
<tr>
<td class="false" height="20"><a
href="javascript:treeAction("my_tree#MA", "n=0000")
<img height="8" width="8" src="images/plus.gif" border="0" alt="Expand
Root Node"></a>Home Node</td>
</tr>
<tr>
<td class="selected" align="left" height="20"><a
href="javascript:treeAction("my_tree#MA", "n=0001")
<img height="8" width="8" src="images/plus.gif" border="0" alt="Expand
Node"></a>Start Node</td>
</tr>
</table>
So, as you click them, the html changes to display the child nodes.
Now, if I have the following code:
ie.link(:url, /treeAction/).click
ie.link(:url, /treeAction/).click
That will work for the "Home Node", but it never sees the "Start
Node". I want to be able to expand all nodes in the tree. How can I
do this?
Incidentally, I saw the reference to JavaScript trees in the FAQ, but
it didn't seem to help my situation.
Does Watir possibly do a .uniq on the link array, and so it only sees the
first?
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general