Getting XPath locators working

12 views
Skip to first unread message

dratewka

unread,
Jan 18, 2011, 5:51:10 AM1/18/11
to tellurium-users
Hello everybody,

recently I've been trying to get tellurium to work with the project
I'm working on, however
it has been a bumpy road so far.
I've set up the environment using

mvn archetype:create -DgroupId=your_group_id -
DartifactId=your_artifact_id \
-DarchetypeArtifactId=tellurium-junit-archetype \
-DarchetypeGroupId=org.telluriumsource -DarchetypeVersion=0.7.0 \
-DarchetypeRepository=http://maven.kungfuters.org/content/repositories/
releases


and made a simple web page to play around with xpath locators.
The problem is, that they don't seem to work. At all.

Here is a simple example - the web page :

<html>
<head></head>
<body>
<a href="http://www.foo.com">Foo</a>
</body>
</html>


Ui module :

public class FooModule extends DslContext{

public void defineUi() {
ui.UrlLink(uid: "TheLink", locator : "//a");
}
}

Test :
public class FooTestCase extends TelluriumJUnitTestCase{

private static FooModule foo;

@BeforeClass
public static void initUi() {
foo = new FooModule();
foo.defineUi();
connectSeleniumServer();
useTelluriumEngine(true);
useCssSelector(true)

useTrace(true);
}

@Before
public void connectToLocal() {
connectUrl("file:///C:/Temp/html/index.html")
}

@Test
public void execFlow1(){
foo.click "TheLink"
pause 10000
}

}

Now, if I change the ui module to :
ui.UrlLink(uid: "TheLink", clocator : [tag :"a"])
then everything works fine. However running it with the locator
described above I get:

com.thoughtworks.selenium.SeleniumException: ERROR: Command execution
failure. Please search the Tellurium User Group at
http://groups.google.com/group/tellurium-users for error details from
the log window. The error message is: Syntax error, unrecognized
expression:
at
com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:
97)
at
com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:
91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite
$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:
229)
at
org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:
52)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
129)
at
org.telluriumsource.component.connector.CustomSelenium.getBundleResponse(CustomSelenium.groovy:
257)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:
88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at
groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:
149)
at groovy.lang.MetaObjectProtocol$invokeMethod.call(Unknown Source)
at
org.telluriumsource.component.dispatch.Dispatcher.methodMissing(Dispatcher.groovy:
56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:
88)
at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:
813)
at
groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:
1107)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1060)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:
39)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:
40)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
117)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
129)
at
org.telluriumsource.component.bundle.BundleProcessor.flush(BundleProcessor.groovy:
372)
at org.telluriumsource.component.bundle.BundleProcessor
$flush.call(Unknown Source)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:
40)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
117)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
121)
at
org.telluriumsource.framework.TelluriumFramework.pause(TelluriumFramework.groovy:
371)
at
org.telluriumsource.test.java.BaseTelluriumJavaTestCase.pause(BaseTelluriumJavaTestCase.java:
156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:
88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:
1326)
at
org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.callStatic(StaticMetaClassSite.java:
47)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:
48)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:
167)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:
175)
at test.FooTestCase.execFlow1(FooTestCase.groovy:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:
20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
76)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:
65)




According to tellurium manual such a locator using xpath should be
valid,
so I don't know what's going on.

I'm running the test using Firefox 3.6.10 on a Windows 7 box.


Regards,
dratewka

Jian Fang

unread,
Jan 18, 2011, 7:23:49 AM1/18/11
to telluri...@googlegroups.com
The real problem is caused by the following two lines:
       useTelluriumEngine(true);
       useCssSelector(true)

First, Tellurium engine does not use xpath. Second, you cannot use CSS selector because
you use xpath. Please simply replace the above two lines with the following line

useCssSelector(false)

BTW, seems you use a groovy class to extend the JUnit Java class. You better use a Java class.

Thanks,

Jian


--
You received this message because you are subscribed to the Google Groups "tellurium-users" group.
To post to this group, send email to telluri...@googlegroups.com.
To unsubscribe from this group, send email to tellurium-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tellurium-users?hl=en.


Szewczyk Dratewka

unread,
Jan 18, 2011, 7:49:05 AM1/18/11
to telluri...@googlegroups.com
Thanks, setting the values to false gets the test working. I didn't know that using 
tellurium engine and css selectors had implications on using xpath. This makes me think
that maybe I don't have to use xpath at all. Till now I've been trying to use it to solve a case
in which there is a bunch of links like so:

<div class='menu'>
    <a href="http://www.foo.com"><span>Foo</span></a>
    <a href="http://www.bar.com"><span>Bar</span></a>
</div>

and I want to get the foo link. Now if there was no <span> inside, I could
just use
 ui.UrlLink(uid: "TheLink",  clocator : [tag :"a", text : "Foo"])

but the <span> makes it more difficult. Obviously I can use xpath to do this, but
is there a better alternative?

Thanks,
dratewka

p.s. I know that java would be better, but this is just a sandbox project.

Rohit Vats

unread,
Jan 18, 2011, 8:08:01 AM1/18/11
to telluri...@googlegroups.com
You can download the Trump IDE plugin for firefox. That will automatically generate the UI modules for your elements as you click on them.

Szewczyk Dratewka

unread,
Jan 18, 2011, 8:13:09 AM1/18/11
to telluri...@googlegroups.com
Actually that was the first thing I tried, however the result was :
  • [error] Error generating UI module and commands: message: this.tagObjectArray[i] is null, name: TypeError, filename: chrome://source/content/uicreator/uimodule-alg.js, linenumber: 234. JavaScript Error Stack: {anonymous}()@chrome://source/content/uicreator/uimodule-alg.js:442 {anonymous}(null)@chrome://source/content/workspace.js:764 {anonymous}()@chrome://source/content/workspace.js:520 {anonymous}()@chrome://source/content/recorder.js:556 {anonymous}([object BeforeUnloadEvent])@chrome://source/content/recorder.js:111 
That's why I'm trying to figure out how to do this "by hand".

Rohit Vats

unread,
Jan 18, 2011, 8:38:20 AM1/18/11
to telluri...@googlegroups.com
In Trump, you first need to click on the elements on your page so that the "record stack" has some elements, and then click the "generate" button. 


Szewczyk Dratewka

unread,
Jan 18, 2011, 8:55:48 AM1/18/11
to telluri...@googlegroups.com
Ok, some clicking around before clicking the actual button help to generate this :

ui.Container(uid: "Link", clocator: [tag: "a"]){
TextBox(uid: "Bar", clocator: [tag: "span", text: "Bar", direct: "true"])
}

open "file:///C:/Temp/html/index.html"
click "Link.Bar"
waitForPageToLoad 30000

but when trying to run such a test results in:


groovy.lang.MissingMethodException: No signature of method: org.telluriumsource.ui.object.UiObject.click() is applicable for argument types: (org.telluriumsource.dsl.BaseDslContext$_click_closure4) values: [org.telluriumsource.dsl.BaseDslContext$_click_closure4@26e7127]
Possible solutions: wait(), wait(long), split(groovy.lang.Closure), sleep(long), print(java.io.PrintWriter), print(java.lang.Object)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:107)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:192)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:208)
at org.telluriumsource.ui.object.UiObject.methodMissing(UiObject.groovy:170)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:813)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1107)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1060)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:90)
at org.telluriumsource.dsl.BaseDslContext.click(BaseDslContext.groovy:166)
at org.telluriumsource.dsl.BaseDslContext$click.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at module.FooModule.execFlow1(Foo.groovy:39)
at FooTestCase.testCase(FooTestCase.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)


So what I understand from this is that you cannot click a 'container'. 

Rohit Vats

unread,
Jan 18, 2011, 9:28:01 AM1/18/11
to telluri...@googlegroups.com
Based on the HTML snippet you provided, I used trump 0.8.0 rc1 to generate the following module:

ui.Container(uid: "Menu", clocator: [tag: "div", class: "menu"]){

                                                                Span(uid: "Foo", clocator: [tag: "span", text: "Foo"])

                                                                Span(uid: "Bar", clocator: [tag: "span", text: "Bar"])

                                                }


Can you try this? click "Menu.Foo"



Jian Fang

unread,
Jan 18, 2011, 9:40:35 AM1/18/11
to telluri...@googlegroups.com
Tellurium recommends not to use XPath and it does UI module to runtime locator mapping
automatically, which is CSS selector by default. Tellurium new Engine uses a group locating
algorithm to locate the whole UI module in one attempt.

For you case, you could define the UI module as follows if you really need the Foo and Bar texts.

ui.Container(uid: "menu", clocator: [tag: "div", class: "menu"]){
   Container(uid: "FooLink", clocator: [tag: "a"]{
      TextBox(uid: "Foo", clocator: [tag: "span", text:"Foo"])

   ....Same for the Bar
}

Have you tried Tellurium IDE or Trump to automatically generate
the UI module for you?

Thanks,

Jian

Szewczyk Dratewka

unread,
Jan 18, 2011, 10:00:14 AM1/18/11
to telluri...@googlegroups.com
First of all, thank you for the quick responses.

I tried both tellurium IDE which generated: 
ui.Container(uid: "Link", clocator: [tag: "a"]){
TextBox(uid: "Bar", clocator: [tag: "span", text: "Bar", direct: "true"])
}
click "Link.Bar"
  
this doesn't work  ...

then trump 0.8.0 rc1

Container(uid: "Menu", clocator: [tag: "div", class: "menu"]){
Span(uid: "Foo", clocator: [tag: "span", text: "Foo"])
Span(uid: "Bar", clocator: [tag: "span", text: "Bar"])
click "Menu.Foo"

this one works!!! :-)

Originally i thought that using trump wouldn't be any different from using the ide, but
obviously I was wrong.

Thanks,
dratewka

Jian Fang

unread,
Jan 18, 2011, 10:05:06 AM1/18/11
to telluri...@googlegroups.com
For the first one, you should call

click "Link"

because the bar is not a link.

For the second one, it may be related to the way JavaScript event propagation.

Vivek, can you provide some input here.

Thanks,

Jian

Jian Fang

unread,
Jan 18, 2011, 10:11:59 AM1/18/11
to telluri...@googlegroups.com
BTW, are you using Telluirum IDE 0.8.0 RC1 or RC2? RC2 is better.

Tellurium IDE is designed to record user actions and then generate UI module and test script, thus, some elements
has to be auto selected by an algorithm. For trump, you can select whatever you need. Trump 0.8.0 RC1 uses a different
UI module generation algorithm.

Thanks,

Jian

Szewczyk Dratewka

unread,
Jan 18, 2011, 10:12:03 AM1/18/11
to telluri...@googlegroups.com
When I call

click "Link"

I get 

groovy.lang.MissingMethodException: No signature of method: org.telluriumsource.ui.object.UiObject.click() is applicable for argument types: (org.telluriumsource.dsl.BaseDslContext$_click_closure4) values: [org.telluriumsource.dsl.BaseDslContext$_click_closure4@6f978b94]
Possible solutions: wait(), wait(long), is(java.lang.Object), split(groovy.lang.Closure), print(java.lang.Object), each(groovy.lang.Closure)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:107)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:192)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:208)
at org.telluriumsource.ui.object.UiObject.methodMissing(UiObject.groovy:170)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:813)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1107)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1060)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:90)
at org.telluriumsource.dsl.BaseDslContext.click(BaseDslContext.groovy:166)
at org.telluriumsource.dsl.BaseDslContext$click.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
at module.FooModule.execFlow1(Foo.groovy:39)
at FooTestCase.testCase(FooTestCase.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


I've actually spent quite some time trying different versions of "what to click", however
I just can't get the tellurium IDE generated modules working when there are <span>'s nested i <a>'s.

Szewczyk Dratewka

unread,
Jan 18, 2011, 10:15:46 AM1/18/11
to telluri...@googlegroups.com
Yep, I'm using the newest I could find Tellurium 0.8.0 RC2

Jian Fang

unread,
Jan 18, 2011, 10:18:19 AM1/18/11
to telluri...@googlegroups.com
That is because in 0.7.0, you need to add a respond attribute

respond: ["click"]

to the link container. In 0.8.0, it should work fine.

Thanks,

Jian

Szewczyk Dratewka

unread,
Jan 18, 2011, 10:26:47 AM1/18/11
to telluri...@googlegroups.com
If I do something like this :

ui.Container(uid: "Link", clocator: [tag: "a"],respond : ['click']){
TextBox(uid: "Bar", clocator: [tag: "span", text: "Bar", direct: "true"])
}


then I get :
com.thoughtworks.selenium.SeleniumException: ERROR: Command execution failure. Please search the Tellurium User Group at http://groups.google.com/group/tellurium-users for error details from the log window.  The error message is: JSON.parse
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)



But do you mean, that tellurium IDE generates code for tellurium 0.8 ?

Szewczyk Dratewka

unread,
Jan 18, 2011, 10:28:43 AM1/18/11
to telluri...@googlegroups.com
Just noticed that I wrote 
respond : ['click']

instead of 

respond : ["click"]

but still the effect is the same

Jonathan Share

unread,
Jan 18, 2011, 10:34:18 AM1/18/11
to telluri...@googlegroups.com
On Jan 18, 2011, at 1:49 PM, Szewczyk Dratewka wrote:

Thanks, setting the values to false gets the test working. I didn't know that using 
tellurium engine and css selectors had implications on using xpath. This makes me think
that maybe I don't have to use xpath at all. Till now I've been trying to use it to solve a case
in which there is a bunch of links like so:

<div class='menu'>
    <a href="http://www.foo.com"><span>Foo</span></a>
    <a href="http://www.bar.com"><span>Bar</span></a>
</div>

and I want to get the foo link. Now if there was no <span> inside, I could
just use
 ui.UrlLink(uid: "TheLink",  clocator : [tag :"a", text : "Foo"])

but the <span> makes it more difficult. Obviously I can use xpath to do this, but
is there a better alternative?


Did you actually try this definition? The check for text tests against the textContent of an element. The textContent of your <a> element is still "Foo" even though there is also a <span> in the dom.

If this a reduced example and the actual dom has whitespace between the elements then you might need to use the definition;

ui.UrlLink(uid: "TheLink",  clocator : [tag :"a", text : "*Foo"])

in order to match the link that contains the text Foo.

Another alternative solution (if the order of the links i guaranteed) would be;

ui.Container(id:'menu', clocator:[tag:'div', 'class': 'menu') {
  UrlLink(id:'foo', clocator: [position: '1'])
}

click 'menu.foo'

Which will then click on the first link in the containing element. 

Regards,

Jonathan

Jonathan Share

unread,
Jan 18, 2011, 10:42:45 AM1/18/11
to telluri...@googlegroups.com
A third option, and possibly the best as it doesn't tie you to the localisation of the site under test, would be to match against the href attribute of the link of possible

ui.UrlLink(uid: "TheLink",  clocator : [tag :"a", href : "*foo.com"])

Szewczyk Dratewka

unread,
Jan 18, 2011, 11:02:47 AM1/18/11
to telluri...@googlegroups.com
Now that you've mentioned it - you're right the text value should actually be Foo despite the span element inside.
And 

ui.UrlLink(uid: "TheLink",  clocator : [tag :"a", text: "Foo"]) 

does work. But yes, this is just a toy example - and I have to admit I didn't test the above solution with it.
I tried this solution with the real html I'm working on - didn't work - probably because the * prefix was missing. Thank you for the tip.

But I guess still one question remains : why doesn't the code generated be tellurium IDE work? Is it because 
it is generated for tellurium 0.8.0?

Regards,
dratewka





--

Jonathan Share

unread,
Jan 18, 2011, 11:37:35 AM1/18/11
to telluri...@googlegroups.com
The last example

ui.Container(uid: "Link", clocator: [tag: "a"],respond : ['click']){
  TextBox(uid: "Bar", clocator: [tag: "span", text: "Bar", direct: "true"])
}

click "Link"

won't work because the definition of your "Link" will match both links in your document not just the one that contains the span with text "Bar".

If you modify it to include the group attribute as the following

ui.Container(uid: "Link", clocator: [tag: "a"],respond : ['click'], group: 'true'){
  TextBox(uid: "Bar", clocator: [tag: "span", text: "Bar", direct: "true"])
}

Then it should work, however this to me is very ugly code (very typical of tools that autogenerate code) especially if you want to model both links. To me it would make more sense to model your example as

ui.Container(uid:'menu', clocator: [tag:'div', class:'menu']) {
  UrlLink(uid:'foo', clocator: [text: 'Foo'])
  UrlLink(uid:'bar', clocator: [text: 'Bar'])
}

which is a lot simpler and easier to read than the autogenerated code.

Regards,

Jonathan

Jian Fang

unread,
Jan 18, 2011, 5:32:54 PM1/18/11
to telluri...@googlegroups.com
As Jonathan said, your link matches two and thus, it does not work.  However, if you use Tellurium new Engine in 0.8.0,
it should be fine since all the elements in the UI module are located together.


Yes, Tellurium IDE 0.8.0 is for Tellurium 0.8.0.

Thanks,

Jian

Szewczyk Dratewka

unread,
Jan 19, 2011, 5:29:49 AM1/19/11
to telluri...@googlegroups.com
Ok, now I understand.

Thanks for clearing things up,
dratewka
Reply all
Reply to author
Forward
0 new messages