Here is a sample Tellurium test code to give you some ideas on what the
Tellurium test code looks like.

1) UI Module

-------------------------------------------------------------------------------------------------------------------------------------------

package org.telluriumsource.module

import org.telluriumsource.dsl.DslContext

public class GoogleSearchModule extends DslContext {

  public void defineUi() {
      ui.Image(uid: "Logo", clocator: [tag: "img", src: "*.gif", alt:
"Google"])

    ui.Container(uid: "Google", clocator: [tag: "table"]) {
      InputBox(uid: "Input", clocator: [tag: "input", title: "Google
Search", name: "q"])
      SubmitButton(uid: "Search", clocator: [tag: "input", type: "submit",
value: "Google Search", name: "btnG"])
      SubmitButton(uid: "ImFeelingLucky", clocator: [tag: "input", type:
"submit", value: "I'm Feeling Lucky", name: "btnI"])
    }
  }

  public void doGoogleSearch(String input) {
    keyType "Google.Input", input
    pause 500
    click "Google.Search"
    waitForPageToLoad 30000
  }

  public void doKeyType(def input) {
    clearText "Google.Input"
    keyType "Google.Input", input
    pause 500
  }

  public void doType(def input) {
    clearText "Google.Input"
    type "Google.Input", input
    pause 500
  }

  public void doImFeelingLucky(String input) {
    type "Google.Input", input
    pause 500
    click "Google.ImFeelingLucky"
    waitForPageToLoad 30000
  }

  //Test jQuery selector for attributes
  public String getLogoAlt(){
    return getImageAlt("Logo")
  }

  boolean isInputDisabled() {
    return isDisabled("Google.Input")
  }

  public void doTypeRepeated(String input){
    customUiCall "Google.Input", typeRepeated, input
    pause 500
    click "Google.Search"
    waitForPageToLoad 30000
  }
}

------------------------------------------------------------------------------------------------------------------------------

2) Test Case

-----------------------------------------------------------------------------------------------------------------------------
package org.telluriumsource.ft;

import org.telluriumsource.test.java.TelluriumJUnitTestCase;
import org.junit.*;
import static org.junit.Assert.*;
import org.telluriumsource.module.GoogleSearchModule;
import org.telluriumsource.entity.CachePolicy;

import java.util.ArrayList;
import java.util.List;

public class GoogleSearchJUnitTestCase extends TelluriumJUnitTestCase {
    private static GoogleSearchModule gsm;
    private static String te_ns = "http://telluriumsource.org/ns";;

    @BeforeClass
    public static void initUi() {
        gsm = new GoogleSearchModule();
        gsm.defineUi();
        connectSeleniumServer();
        useCssSelector(true);
        useTelluriumApi(true);
        useTrace(true);
        useCache(true);
    }

    @Before
    public void connectToGoogle() {

        connectUrl("http://www.google.com/intl/en/";);
    }

    @Test
    public void testJsonfyUiModule(){
        String json = gsm.toString("Google");
        System.out.println(json);
    }

    @Test
    public void testGoogleSearch() {
        gsm.doGoogleSearch("tellurium . ( Groovy ) Test");
    }

    @Test
    public void testGoogleSearchFeelingLucky() {
        gsm.doImFeelingLucky("tellurium automated Testing");
    }

    @Test
    public void testLogo(){
        gsm.validate("Logo");
        gsm.diagnose("Logo");
        String alt = gsm.getLogoAlt();
        assertNotNull(alt);
    }

    @Test
    public void testClosestMatch(){
        useClosestMatch(true);
        String alt = gsm.getLogoAlt();
        assertNotNull(alt);
        useClosestMatch(false);
    }

    @Test
    public void testIsDisabled(){
        useCssSelector(true);
        boolean result = gsm.isInputDisabled();
        assertFalse(result);
        useCssSelector(false);
        result = gsm.isInputDisabled();
        assertFalse(result);
    }

    @Test
    public void testUseCache(){
        useCache(true);
        boolean result = gsm.getCacheState();
        assertTrue(result);

        useCache(false);
        result = gsm.getCacheState();
        assertFalse(result);
    }

    @Test
    public void testKeyType(){
        //Test case for Issue 290: key type event is not working in IE
        gsm.doGoogleSearch("[email protected]");
    }

    @Test
    public void testTypeRepeated(){
        gsm.doTypeRepeated("tellurium jQuery");
    }

    @Test
    public void testDifferentTypeInput(){
        gsm.doType(null);
        gsm.doType("telluriumsource.org");
        gsm.doType(2515);
        gsm.doType(12.15);
        gsm.doType(true);
        gsm.doType(gsm);
    }

    @Test
    public void testDifferentKeyTypeInput(){
        gsm.doKeyType(null);
        gsm.doKeyType("telluriumsource.org");
        gsm.doKeyType(2515);
        gsm.doKeyType(12.15);
        gsm.doKeyType(true);
        gsm.doKeyType(gsm);
    }


    @Test
    public void testRegisterNamespace(){
        registerNamespace("te", te_ns);
        String ns = getNamespace("te");
        assertNotNull(ns);
        assertEquals(te_ns, ns);
        ns = getNamespace("x");
        assertNotNull(ns);
        assertEquals("http://www.w3.org/1999/xhtml";, ns);
        ns = getNamespace("mathml");
        assertNotNull(ns);
        assertEquals("http://www.w3.org/1998/Math/MathML";, ns);
    }

    @Test
    public void testCachePolicy(){
        useCssSelector(true);
        useCache(true);
        String policy = getCurrentCachePolicy();
        assertEquals("DiscardOldPolicy", policy);
        useCachePolicy(CachePolicy.DISCARD_LEAST_USED);
        policy = getCurrentCachePolicy();
        assertEquals("DiscardLeastUsedPolicy", policy);
        useCachePolicy(CachePolicy.DISCARD_INVALID);
        policy = getCurrentCachePolicy();
        assertEquals("DiscardInvalidPolicy", policy);
        useCachePolicy(CachePolicy.DISCARD_NEW);
        policy = getCurrentCachePolicy();
        assertEquals("DiscardNewPolicy", policy);
        useCachePolicy(CachePolicy.DISCARD_OLD);
        policy = getCurrentCachePolicy();
        assertEquals("DiscardOldPolicy", policy);
    }

    @Test
    public void testCustomDirectCall(){
        List<String> list  = new ArrayList<String>();
        list.add("//inp...@title='Google Search']");
        gsm.customDirectCall("click", list.toArray());
    }

    @AfterClass
    public static void tearDown(){
        showTrace();
     }
}

Please read more details from Tellurium user guide at

http://code.google.com/p/aost/wiki/UserGuide070Introduction?tm=6

and 0.7.0 update at

http://code.google.com/p/aost/wiki/Tellurium070Update

Thanks,

Jian


On Mon, Feb 1, 2010 at 12:36 PM, Jian Fang <[email protected]> wrote:

> No, you cannot put pauses and waitForPageLoad everywhere. I guess that
> might be the root cause of the problem.
>
> Thanks,
>
> Jian
>
>
> On Mon, Feb 1, 2010 at 12:33 PM, Pascal Gandilhon <
> [email protected]> wrote:
>
>> *Did you put waitForPageLoad or other wait operation there?*
>>
>> Yes I put pauses and waitForPageLoad everywhere ;-))
>>
>> *Or this happened inside the open URL method?*
>>
>> *This happens  in the connectUrl method*
>> *
>> *
>> *regards, Pascal
>> *
>> 2010/2/1 Jian Fang <[email protected]>
>>
>>> BTW, I searched the web and this might be a regular Javascript problem.
>>> For example, this post
>>>
>>>
>>> http://www.coderanch.com/t/122834/HTML-JavaScript/document-body-null-or-not#606782
>>>
>>> indicated that "You are calling it before the window is fully loaded."
>>> and the solution is "If you detect it null, than use a setTimeout and call
>>> it again. Repeat until loaded."
>>>
>>> Did you put waitForPageLoad or other wait operation there? Or this
>>> happened inside the open URL method?
>>>
>>> Thanks,
>>>
>>> Jian
>>>
>>> On Mon, Feb 1, 2010 at 11:43 AM, Pascal Gandilhon <
>>> [email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> thanks for your quick answer. Nothing particular in the logs.....the
>>>> message is a popup alert on ie.... sorry if I wasn't clear about that. I
>>>> joigned a screen capture. I tried with serveral Tellurium version, now I'm
>>>> on the latest Snapshot.
>>>>
>>>> regards,
>>>>
>>>> Pascal
>>>>
>>>>
>>>> 2010/2/1 Jian Fang <[email protected]>
>>>>
>>>> Hi Pascal,
>>>>>
>>>>> Are you using Tellurium 0.7.0 latest snapshot? If you are, please do me
>>>>> a favor. First put a break point before where the problem happened in your
>>>>> test code,
>>>>> then turn on the Engine console logging by adding the following call to
>>>>> your code,
>>>>>
>>>>> useEngineLog(true)
>>>>>
>>>>> or click on the Tellurium logging button on the testing page. More
>>>>> details here:
>>>>>
>>>>> http://code.google.com/p/aost/wiki/Tellurium070Update#Engine_Logging
>>>>>
>>>>> Please also put a breakpoint at the @AfterClass method in the base test
>>>>> class so that you can check the console logging before the browser is
>>>>> killed.
>>>>>
>>>>> You should see some error messages there. If you click on the error
>>>>> message,  you should see some stack trace. Please post all the logging
>>>>> messages and stack trace here.
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> Jian
>>>>>
>>>>> On Mon, Feb 1, 2010 at 5:04 AM, Pascal Gandilhon <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi Jian,
>>>>>>
>>>>>> it seems there is a problem on ie 6 and 7 with some webPages based on
>>>>>> Jquery :
>>>>>>
>>>>>> using single Window mode (i.e. useMultiWindow = false on
>>>>>> TelluriumConfig.groovy) wich is default property, I have this warning :
>>>>>>
>>>>>> 'document.body' is null or not an object
>>>>>>
>>>>>> The only way I found to solve this problem was to use multi windows
>>>>>> mode (useMultiWindow = true on TelluriumConfig.groovy) , wich is not a 
>>>>>> very
>>>>>> big problem for me.
>>>>>> I just passed several hours to find this issue and didn't find any
>>>>>> help on the web about this, so I'm posting this message if it can save 
>>>>>> time
>>>>>> to the next one..... or if someone knows another issue.
>>>>>>
>>>>>> regards,
>>>>>>
>>>>>> Pascal
>>>>>>
>>>>>>
>>>>>>
>>>>>>  --
>>>>>> 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]<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.

Reply via email to