Tellurium Tutorial Series: The UID

10 views
Skip to first unread message

John.Ji...@gmail.com

unread,
Oct 7, 2008, 11:36:15 PM10/7/08
to tellurium-users
One of the big advantage for Tellurium is that you can use UIDs to
refer objects instead of writing the XPath directly everywhere. Take
the Google Book List page UI module in our Tellurium core test samples
as an example, the UI modules is defined as,

ui.Container(uid: "GoogleBooksList", clocator: [tag: "table",
id: "hp_table"], group: "true"){
TextBox(uid: "category", clocator: [tag: "div", class:
"sub_cat_title"])
List(uid: "subcategory", clocator: [tag: "div",
class:"sub_cat_section"], separator: "p"){
UrlLink(uid: "all", locator: "/a")
}
}

As we said, the "ui." is actually a parser. Since we defined a set of
nested objects, the parser will store an object tree in the registry.
The object tree looks like


GoogleBooksList ------- "category"
|
|--- ------- "subcategory" ------ "1"

| ......
| ------
"n"


Any node in the tree can be reached by walking from the root to that
node. For example, "GoogleBookList.category" will walk you from
"GoogleBooksList" to the object "category".
For list, you may have variable number of elements and they are all
referred by their indexes. For example,
"GoogleBooksList.subcategory[1]" will walk from "GoogleBooksList" ->
"subcategory" -> "1".

For table, you have two dimensions of indexes. For example,
"downloadpage.downloadResult[2][5]".

If you have only one nested UI defined as above, you can omit the root
"GoogleBooksList". That is to say, "GoogleBooksList.subcategory[1]"
can be shorten as "subcategory[1]". But if you have multiple nested
objects defined, such as

ui.Container(uid: "menu", clocator: [tag: "table", id: "mt",
trailer: "/tbody/tr/th"], group: "true"){
UrlLink(uid: "project_home", clocator: [text: "%%Home"])
UrlLink(uid: "downloads", clocator: [text: "Downloads"])
UrlLink(uid: "wiki", clocator: [text: "Wiki"])
UrlLink(uid: "issues", clocator: [text: "Issues"])
UrlLink(uid: "source", clocator: [text: "Source"])
}

ui.Form(uid: "search", clocator: [:], group: "true"){
InputBox(uid: "searchbox", clocator: [name: "q"])
SubmitButton(uid: "search_project_button", clocator:
[value: "Search Projects"])
SubmitButton(uid: "search_web_button", clocator: [value:
"Search the Web"])
}

In such a case, there are two nested object trees built in the object
registry and you cannot omit the root ui "menu" or "search". You must
use full UIDs such as "menu.source" or "search.search_web_button".
Reply all
Reply to author
Forward
0 new messages