Here is my test code
UI Module
----------------------------------------------------------------------------
package org.telluriumsource.module
import org.telluriumsource.dsl.DslContext
class JListModule extends DslContext {
public void defineUi(){
ui.Form(uid: "selectedSailings", clocator: [name:
"selectedSailingsForm"]) {
List(uid: "outgoingSailings", locator: "/div[1]") {
Container(uid: "all", clocator: [tag: "div", 'class': "option"]) {
List(uid: "fares", clocator: [tag: "ul"]) {
Container(uid: "all", clocator: [tag: "li"]) {
RadioButton(uid: "radio", clocator: [:], respond: ["click"])
TextBox(uid: "label", clocator: [tag: "label"])
}
}
TextBox(uid: "departureTime", locator: "/div/dl/dd/em[1]")
}
}
}
ui.Form(uid: "Sailings", clocator: [name: "selectedSailingsForm"]){
List(uid: "Fares", clocator: [tag: "ul", class: "fares"], separator:
"li"){
Container(uid: "all"){
RadioButton(uid: "radio", clocator: [:], respond: ["click"])
TextBox(uid: "label", clocator: [tag: "label"])
}
}
}
}
}
--------------------------------------------------------------------------------------------------
Test Case
-------------------------------------------------------------------------------------------------
package org.telluriumsource.ft;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.telluriumsource.module.JListModule;
import org.telluriumsource.test.java.TelluriumMockJUnitTestCase;
public class JListTestJUnitCase extends TelluriumMockJUnitTestCase {
private static JListModule jlm;
@BeforeClass
public static void initUi() {
registerHtmlBody("JList");
jlm = new JListModule();
jlm.defineUi();
// useCssSelector(true);
// useTelluriumApi(true);
useTrace(true);
// useCache(true);
// useMacroCmd(true);
useEngineLog(true);
}
@Before
public void connectToLocal() {
connect("JList");
}
@Test //This works fine if the following two commands are used:
useCache(true); useTelluriumApi(true);
public void testGetListSize(){
int size =
jlm.getListSize("selectedSailings.outgoingSailings[1].fares");
System.out.println("List Size " + size);
}
@Test
public void testGetNewListSize(){
int size = jlm.getListSize("Sailings.Fares");
System.out.println("List Size " + size);
}
@AfterClass
public static void tearDown(){
showTrace();
}
}
On Mon, Feb 1, 2010 at 11:05 AM, Jian Fang <[email protected]> wrote:
> Hi,
>
> Your UI module definition might be problematic. I used the following one
> and can get back the list size 2 correctly
>
> ui.Form(uid: "Sailings", clocator: [name: "selectedSailingsForm"]){
> List(uid: "Fares", clocator: [tag: "ul", class: "fares"], separator:
> "li"){
> Container(uid: "all"){
>
> RadioButton(uid: "radio", clocator: [:], respond: ["click"])
> TextBox(uid: "label", clocator: [tag: "label"])
> }
> }
> }
>
> You should use the logical container to include the list elements.
>
> Also, please don't use hard coded xpath there, otherwise, your test is not
> robust to changes. Also, most 0.7.0 new
> features require the clocator.
>
> Interesting thing is I can get back the correct List size even with your UI
> module with new Tellurium API. I will
> post all my test code soon.
>
> Thanks,
>
> Jian
>
>
> On Mon, Feb 1, 2010 at 10:49 AM, Jian Fang <[email protected]>wrote:
>
>> You are right, the new core added a WorkflowContext variable to all
>> Accessor methods
>> so that we can pass in meta data to the tiers under it. That is why it
>> cannot find the method with
>> the old snapshot.
>>
>> Thanks,
>>
>> Jian
>>
>>
>> On Mon, Feb 1, 2010 at 10:35 AM, Jonathan Share <[email protected]>wrote:
>>
>>> Thanks, I'm also having problems with getXpathCount, but that may be
>>> because I'm using an old snapshot in order to work around the list
>>> problem.
>>>
>>> "groovy.lang.MissingMethodException: No signature of method:
>>> org.telluriumsource.access.Accessor.getXpathCount() is applicable for
>>> argument types: (java.lang.String) values:
>>>
>>> [//descendant-or-self::tab...@id="supplierEditor"]/tbody/tr[child::td]/td[1]]"
>>>
>>> 2010/2/1 Jian Fang <[email protected]>:
>>> > Thanks for reporting the problem. I will create a test case and see
>>> what
>>> > happens.
>>> >
>>> > Thanks,
>>> >
>>> > Jian
>>> >
>>> > On Mon, Feb 1, 2010 at 7:20 AM, Jonathan Share <[email protected]>
>>> wrote:
>>> >>
>>> >> Hi,
>>> >>
>>> >> I seem to be having a little problem with getListSize. When I call
>>> >> that method tellurium crashes on me with the following exception;
>>> >>
>>> >> com.thoughtworks.selenium.SeleniumException: ERROR: Element
>>> >>
>>> >>
>>> //descendant-or-self::fo...@name="selectedSailingsForm"]/div[1]/d...@class="option"][1]/descendant-or-self::ul/li[3]
>>> >> not found
>>> >>
>>> >> The interesting thing to note here is that there are only two li
>>> >> elements in the list. Is this a bug that has crept into tellurium or
>>> >> am I doing something really stupid in my test?
>>> >>
>>> >> Thanks in advance
>>> >>
>>> >> Jonathan
>>> >>
>>> >> // MODEL
>>> >> ui.Form(uid: "selectedSailings", clocator: [name:
>>> "selectedSailingsForm"])
>>> >> {
>>> >> List(uid: "outgoingSailings", locator: "/div[1]") {
>>> >> Container(uid: "all", clocator: [tag: "div", 'class':
>>> >> "option"]) {
>>> >> List(uid: "fares", clocator: [tag: "ul"]) {
>>> >> Container(uid: "all", clocator: [tag: "li"]) {
>>> >> RadioButton(uid: "radio", clocator: [:],
>>> >> respond: ["click"])
>>> >> TextBox(uid: "label", clocator: [tag:
>>> "label"])
>>> >> }
>>> >> }
>>> >> TextBox(uid: "departureTime", locator:
>>> >> "/div/dl/dd/em[1]")
>>> >> }
>>> >> }
>>> >> }
>>> >>
>>> >> // TEST LINE THAT FAILS
>>> >> def numPricesForSailing =
>>> >> getListSize("selectedSailings.outgoingSailings[1].fares")
>>> >>
>>> >> // HTML (edited a little)
>>> >> <form action="..." id="airDetailsForm" method="POST"
>>> >> name="selectedSailingsForm">
>>> >> <div class="segment clearfix">
>>> >> <div class="option">
>>> >> <ul class="fares">
>>> >> <li>
>>> >> <input id="..." name="..." type="radio" value="..." checked
>>> >> onclick="enableDisable(1,2)"> <label for="..."><strong><span
>>> >> id="...">3,000</span>KR</strong>economy</label>
>>> >> </li>
>>> >> <li>
>>> >> <input id="..." name="..." type="radio" value="..."
>>> >> onclick="enableDisable(1,1)"> <label for="..."><strong><span
>>> >> id="...">4,000</span>KR</strong> Flexible</label>
>>> >> </li>
>>> >> </ul>
>>> >> </div>
>>> >> </div>
>>> >> </form>
>>> >>
>>> >> --
>>> >> 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]<tellurium-users%[email protected]>
>>> .
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/group/tellurium-users?hl=en.
>>> >>
>>> >
>>> > --
>>> > 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]<tellurium-users%[email protected]>
>>> .
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/tellurium-users?hl=en.
>>> >
>>>
>>> --
>>> 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]<tellurium-users%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/tellurium-users?hl=en.
>>>
>>>
>>
>
--
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.