Navigating across multiple pages on a site

3 views
Skip to first unread message

Matthew Toll

unread,
Aug 29, 2011, 1:44:39 PM8/29/11
to tellurium-users
Hi,

I am new to Tellurium and have walked through some of the examples
provided. Now I am trying to write an example that can show
navigation across a web site. I am using www.yahoo.com as a test site
and I want to script a test routine that can navigate from the home
page to another page, go back to the home page, and then navigate to
another link on the home page.

My problem is:

The first navigation from the home page works fine. The call to
return to the home page (goBack) works fine. However, upon coming
back to the home page, the application says that it can't find my UI
module.

The error reported from the stack trace:

com.thoughtworks.selenium.SeleniumException: ERROR: Cannot locate UI
module div1



Here is my definition for the two pages (both are separate Groovy
classes)

package module
import org.telluriumsource.dsl.DslContext

/**
* Ui Modules for Tellurium Down page at
*
* http://www.yahoo.com
*/

class YahooHomePage extends DslContext {

public void defineUi() {

// Define UI for left menu of Yahoo Site

// this worked... using an ID on the li tag


ui.Div(uid: "div1", clocator: [tag: "div", id: "u_2588582-sb",
class: "sb"]) {
UrlLink(uid: "autos", clocator: [text: "Autos"])
UrlLink(uid: "dating", clocator: [text: "Dating"])
UrlLink(uid: "jobs", clocator: [text: "Jobs"])
}
} // end defineUi

public void navigateAutos(){
click "div1.autos"
waitForPageToLoad 50000
}

public void navigateDating() {
click "div1.dating"
waitForPageToLoad 50000
}

public void navigateJobs() {
click "div1.jobs"
waitForPageToLoad 50000
}

}



package module
import org.telluriumsource.dsl.DslContext

/**
* Ui Modules for Tellurium Down page at
*
* http://www.yahoo.com
*/

class AutosPage extends DslContext {

public void defineUi() {


ui.Div(uid: "div2", clocator: [tag: "div", id:
"yui_3_1_1_8_131463586969810"]) {
}
} // end defineUi


public void returnToParentPage() {
goBack()
}
}


Here is my test


package test;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import module.YahooHomePage;
import module.AutosPage;
import org.telluriumsource.util.Helper;
import org.telluriumsource.test.java.TelluriumJUnitTestCase;


import static org.junit.Assert.*;

/**
* Tests Downloads Page on Yahoo
*
*/
public class YahooHomePageJunitTests extends TelluriumJUnitTestCase {
private static YahooHomePage homePage;
private static AutosPage autoPage;

@BeforeClass
public static void initUi() {
homePage = new YahooHomePage();
homePage.defineUi();
autoPage = new AutosPage();
autoPage.defineUi();
connectSeleniumServer();
useCache(true);
useCssSelector(true);
}

@Before
public void connect(){
connectUrl("http://www.yahoo.com");
}

@Test
public void testNavigation(){
homePage.navigateAutos();
System.out.println("Navigated to Autos");
autoPage.returnToParentPage();
System.out.println("Back on home page");
homePage.navigateAutos();
System.out.println("Navigated to Autos");
}


@AfterClass
public static void showUsage(){
int size = getCacheSize();
int maxSize = getCacheMaxSize();
System.out.println("Cache Size: " + size + ", Cache Max Size:
" + maxSize);
System.out.println("Cache Usage: " + getCacheUsage());
}
}

I would like to know why Tellurium can't seem to locate the UI module
on the home page after the initial call.


Thanks for your help,


Matthew Toll

Jian Fang

unread,
Aug 29, 2011, 3:09:15 PM8/29/11
to telluri...@googlegroups.com
Probably due to some Selenium server side cache issue. You could try
to call diagnose(uid) or validate(ui module) command
to force UI module locating to get around this problem, for example.

//homePage.diagnose("div1.autos");
homePage.validate("div1");
homePage.navigateAutos();

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.
>
>

Reply all
Reply to author
Forward
0 new messages