In the interest of keeping it generic, I'd like to not rely on the
text. I did find a solution that seems to work:
Again, the HTML:
<table id="tblLink">
<tr>
<td>Google</td>
<td><a href="http://www.google.com/">Link</a></td>
<tr>
</table>
And the UIModule:
ui.Table(uid: "tblLink", clocator: [tag: "td", id: "tblLink"]) {
TextBox(uid: "{row: all, column: 1}", clocator: [:])
UrlLink(uid: "{row: all, column: 2}", clocator: [tag: "a", text:
"Link"])
}
Still have to leave out useTelluriumEngine(true) for the link to work
correctly, though. About to try it with Tellurium 0.8.0...
Thanks much for your help,
- Josh
On May 19, 2:45 pm, Jian Fang <[email protected]> wrote:
> Have you updated your UI module to include the td with text "Google"? You
> could use a TextBox for it, also
> add the direct attribute as true for the TextBox since there is no other tag
> inside the first TD.
>
> On Thu, May 19, 2011 at 3:35 PM, Josh Allen <[email protected]>wrote:
>
>
>
>
>
>
>
> > Yes, it does identify the link correctly, as the output from
> > diagnose("tblLink[1][2]") shows:
>
> > Diagnosis Result for tblLink[1][2]
>
> > -------------------------------------------------------
>
> > Matching count: 1
>
> > Match Elements:
>
> > --- Element 1 -->
>
> > <a href="http://www.google.com/">Link</a>
>
> > Parents:
>
> > --- Parent 1 ---
>
> > <td><a href="http://www.google.com/">Link</a></td>
>
> > Closest:
>
> > Closest:
>
> > --- closest element 1 ---
>
> > <a href="http://www.google.com/">Link</a>
>
> > HTML Source:
>
> > <head>
> > </head><body><table id="tblLink">
> > <tbody><tr>
> > <td>Google</td>
> > <td><a href="http://www.google.com/">Link</a></td>
> > </tr><tr>
> > </tr></tbody></table>
> > </body>
>
> > -------------------------------------------------------
>
> > So the problem is that when useTelluriumEngine(true) in initUi() is
> > commented out, the test throws an exception when searching for the
> > text box containing "Google", or "tblLink[1][1]", and when
> > useTelluriumEngine does exist, it locates the link but cannot
> > recognize the link's href. The output from the diagnose statements
> > for each element are consistent, whether useTelluriumEngine is used or
> > not.
>
> > - Josh
>
> > On May 19, 2:21 pm, Jian Fang <[email protected]> wrote:
> > > Since you have another td, shouldn't the link be tblLink[1][2]? You need
> > to
> > > change your UI module to reflect that as well.
>
> > > On Thu, May 19, 2011 at 3:13 PM, Josh Allen <[email protected]
> > >wrote:
>
> > > > Haven't tried 0.8.0 yet, I'll see what happens when I use that.
>
> > > > Output from the diagnose call is as follows:
>
> > > > -------------------------------------------------------
>
> > > > Matching count: 0
>
> > > > Parents:
>
> > > > --- Parent 1 ---
>
> > > > <td>Google</td>
>
> > > > HTML Source:
>
> > > > <head>
> > > > </head><body><table id="tblLink">
> > > > <tbody><tr>
> > > > <td>Google</td>
> > > > <td><a href="http://www.google.com/">Link</a></td>
> > > > </tr><tr>
> > > > </tr></tbody></table>
> > > > </body>
>
> > > > -------------------------------------------------------
>
> > > > Looks like the intended target is Parent 1?
>
> > > > - Josh
>
> > > > On May 19, 11:13 am, Jian Fang <[email protected]> wrote:
> > > > > Have you tried Tellurium 0.8.0 snapshot?
>
> > > > > Seems the jquery selector cannot find the UI element, would it
> > include
> > > > > multiple matches?
>
> > > > > Try to run
>
> > > > > diagnose("tblLink[1][1]")
>
> > > > > and post the output.
>
> > > > > Thanks,
>
> > > > > Jian
>
> > > > > On Thu, May 19, 2011 at 12:10 PM, Josh Allen <
> > [email protected]
> > > > >wrote:
>
> > > > > > I'm using Tellurium v0.7.0. Also if this helps, here's related
> > code
> > > > > > that causes the exception when useTelluriumEngine(true) is left
> > out:
>
> > > > > > HTML:
> > > > > > <table id="tblLink">
> > > > > > <tr>
> > > > > > <td>Google</td>
> > > > > > <td><a href="http://www.google.com/">Link</a></td>
> > > > > > <tr>
> > > > > > </table>
>
> > > > > > UIModule:
> > > > > > ui.Table(uid: "tblLink", clocator: [tag: "td", id: "tblLink"]) {
> > > > > > TextBox(uid: "{row: all, column: 1}", clocator: [tag:
> > "td"])
> > > > > > UrlLink(uid: "{row: all, column: 2}", clocator: [tag: "a",
> > text:
> > > > > > "Link"])
> > > > > > }
>
> > > > > > The function that causes the exception:
> > > > > > public void testTextBox() {
> > > > > > def targetTextBox = "tblLink[1][1]"
> > > > > > println getText(targetTextBox)
> > > > > > }
>
> > > > > > ...and finally, the exception:
> > > > > > com.thoughtworks.selenium.SeleniumException: ERROR: Element
> > > > > > uimcal={"rid":"tblLink[1][1]","locator":"jquery=#tblLink > tbody >
> > > > > > tr:has(td):eq(0) > td:eq(0) td"} not found
>
> > > > > > Thanks again,
> > > > > > - Josh
>
> > > > > > On May 19, 10:42 am, Jian Fang <[email protected]> wrote:
> > > > > > > Which version of Tellurium are you using?
>
> > > > > > > useTelluriumEngine(true)
>
> > > > > > > means that you are using the new Tellurium engine. I will try
> > that
> > > > with
> > > > > > the
> > > > > > > test case tonight.
>
> > > > > > > Thanks,
>
> > > > > > > Jian
>
> > > > > > > On Thu, May 19, 2011 at 11:19 AM, Josh Allen <
> > > > [email protected]
> > > > > > >wrote:
>
> > > > > > > > Hi Jian,
>
> > > > > > > > Thanks for your quick response. Your code does indeed work,
> > and I
> > > > may
> > > > > > > > have determined what makes mine fail. Previously, my initUi
> > > > function
> > > > > > > > consisted of the following:
>
> > > > > > > > @BeforeClass
> > > > > > > > public static void initUi() {
> > > > > > > > ulm = new UrlLinkModule();
> > > > > > > > ulm.defineUi();
>
> > > > > > > > connectSeleniumServer();
> > > > > > > > useTelluriumEngine(true);
> > > > > > > > useTrace(true);
> > > > > > > > }
>
> > > > > > > > After trying several things to reconcile our code, I commented
> > out
> > > > > > > > useTelluriumEngine(true), and the scenario I previously
> > described
> > > > > > > > works: the link's href is non-null, and clicking the link
> > works.
> > > > Any
> > > > > > > > ideas why this may be?
>
> > > > > > > > I noticed in the documentation that this function enables the
> > use
> > > > of
> > > > > > > > caching and the tellurium API, so I'm guessing this is
> > something
> > > > that
> > > > > > > > I wouldn't want to comment out. Sure enough, other scenarios
> > now
> > > > do
> > > > > > > > not work: an exception now occurs when I try to identify a
> > textbox
> > > > > > > > within a table.
>
> > > > > > > > Thanks,
> > > > > > > > - Josh
>
> > > > > > > > On May 18, 5:10 pm, Jian Fang <[email protected]>
> > wrote:
> > > > > > > > > Here is the output for the test case:
>
> > > > > > > > > TE: Name: isElementPresent, start: 1305756372015, duration:
> > 62ms
> > > > > > > > > TE: Name: isElementPresent, start: 1305756372015, duration:
> > 62ms
> > > > > > > > > TE: Name: getText, start: 1305756372081, duration: 51ms
> > > > > > > > > TE: Name: getText, start: 1305756372081, duration: 51ms
> > > > > > > > > text: Link
> > > > > > > > > html: <a>Link</a>
>
> > > > > > > > > TE: Name: getAttribute, start: 1305756372153, duration: 52ms
> > > > > > > > > TE: Name: getAttribute, start: 1305756372153, duration: 52ms
> > > > > > > > > href:http://www.google.com/
> > > > > > > > > TE: Name: click, start: 1305756372226, duration: 53ms
> > > > > > > > > TE: Name: click, start: 1305756372226, duration: 53ms
> > > > > > > > > TE: Name: waitForPageToLoad, start: 1305756372284, duration:
> > > > 1822ms
> > > > > > > > > TE: Name: waitForPageToLoad, start: 1305756372284, duration:
> > > > 1822ms
>
> > > > > > > > > On Wed, May 18, 2011 at 6:10 PM, Jian Fang <
> > > > [email protected]
>
> > > > > > > > wrote:
> > > > > > > > > > I tried the same code you used and just replace your url
> > with
> > > > > > Google's
> > > > > > > > but
> > > > > > > > > > cannot reproduce your problem.
>
> > > > > > > > > > Here is the code:
>
> > > > > > > > > > --- UI Module -----
> > > > > > > > > > package org.telluriumsource.module
>
> > > > > > > > > > import org.telluriumsource.dsl.DslContext
>
> > > > > > > > > > class UrlLinkModule extends DslContext {
> > > > > > > > > > public void defineUi() {
>
> > > > > > > > > > ui.Table(uid: "tblLink", clocator: [tag: "td", id:
> > > > > > "tblLink"])
> > > > > > > > {
> > > > > > > > > > UrlLink(uid: "{row: 1, column: 1}", clocator:
> > [tag:
> > > > > > "a",
> > > > > > > > text:
> > > > > > > > > > "Link"])
> > > > > > > > > > }
> > > > > > > > > > }
>
> > > > > > > > > > public void testLink() {
>
> > > > > > > > > > def targetLink = "tblLink[1][1]"
> > > > > > > > > > println "text: " + getText(targetLink)
> > > > > > > > > > println "html: " + toHTML(targetLink)
> > > > > > > > > > println "href: " + getLink(targetLink)
> > > > > > > > > > click targetLink
> > > > > > > > > > waitForPageToLoad 30000
> > > > > > > > > > }
> > > > > > > > > > }
>
> > > > > > > > > > ---- Test Case ----
>
> > > > > > > > > > package org.telluriumsource.ft;
>
> > > > > > > > > > import org.junit.Before;
> > > > > > > > > > import org.junit.BeforeClass;
> > > > > > > > > > import org.junit.Test;
> > > > > > > > > > import org.telluriumsource.module.UrlLinkModule;
> > > > > > > > > > import
> > > > org.telluriumsource.test.java.TelluriumMockJUnitTestCase;
>
> > > > > > > > > > public class UrlLinkTestCase extends
> > TelluriumMockJUnitTestCase
> > > > {
> > > > > > > > > > private static UrlLinkModule ulm;
>
> > > > > > > > > > @BeforeClass
> > > > > > > > > > public static void initUi() {
> > > > > > > > > > registerHtml("UrlLink");
>
> > > > > > > > > > ulm = new UrlLinkModule();
> > > > > > > > > > ulm.defineUi();
> > > > > > > > > > useTrace(true);
> > > > > > > > > > }
>
> > > > > > > > > > @Before
> > > > > > > > > > public void connectToLocal() {
> > > > > > > > > > connect("UrlLink");
> > > > > > > > > > }
>
> > > > > > > > > > @Test
> > > > > > > > > > public void validate(){
> > > > > > > > > > ulm.validate("tblLink");
> > > > > > > > > > }
>
> > > > > > > > > > @Test
> > > > > > > > > > public void testClickUrl(){
> > > > > > > > > > ulm.testLink();
> > > > > > > > > > }
>
> > > > > > > > > > }
>
> > > > > > > > > > You can check our tellurium trunk core project and look at
> > the
> > > > > > above
> > > > > > > > > > example there.
>
> > > > > > > > > > Thanks,
>
> > > > > > > > > > Jian
>
> > > > > > > > > > On
>
> ...
>
> read more »
--
You received this message because you are subscribed to the Google Groups
"tellurium-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tellurium-users?hl=en.