Jason,
As you said, you may not able to do one traverse to get back all the
information you need because of UI templates. Another reason
is that Tellurium relies on the tree walking to generate the runtime
locator. As a result, you better to use two rounds of traverse. The first
traverse will generate all valid UIDs you need to use including the UI
templates. Then, the second round just does tree walking to the
specific UID and then do some work you want. Look at the dump()
implementation here,
public void dump(String uid){
WorkflowContext context =
WorkflowContext.getContextByEnvironment(this.exploreJQuerySelector,
this.exploreSelectorCache)
def obj = walkToWithException(context, uid)
if(obj != null){
context.setNewUid(uid)
obj.traverse(context)
ArrayList list = context.getUidList()
println("\nDump locator information for " + uid)
println("-------------------------------------------------------")
list.each {String key->
String loc = getLocator(key)
context =
WorkflowContext.getContextByEnvironment(this.exploreJQuerySelector,
this.exploreSelectorCache)
walkToWithException(context, key)
if(this.exploreJQuerySelector){
loc = this.postProcessSelector(context, loc)
}
println("${key}: ${loc}")
}
println("-------------------------------------------------------\n")
}
}
Since Tellurium has already implemented the first round of traverse to get
back all UIDs you need, i.e, the code snippet,
context.setNewUid(uid)
obj.traverse(context)
ArrayList list = context.getUidList()
Then, you method should be like as follows and you do not even need to add
your own tryToWalk() method
public void debug(String uid){
WorkflowContext context =
WorkflowContext.getContextByEnvironment(this.exploreJQuerySelector,
this.exploreSelectorCache)
def obj = walkToWithException(context, uid)
if(obj != null){
context.setNewUid(uid)
obj.traverse(context)
ArrayList list = context.getUidList()
list.each {String key->
context =
WorkflowContext.getContextByEnvironment(this.exploreJQuerySelector,
this.exploreSelectorCache)
walkToWithException(context, key).printDebugInfo()
}
}
}
Here I assume you have a printDebugInfo() method in each UI object to print
out all the debug info you need.
Hope this could be helpful.
Thanks,
Jian
On Mon, Jun 22, 2009 at 1:28 PM, Jason <[email protected]> wrote:
>
> Hey, thanks Jian.
>
> What I've been doing is something like this, which doesn't work for
> "special" list element UiObjects (those with 'all' as their uid)
>
> private String getFullyQualifiedUid(UiObject obj) {
> if ( obj.getParent() != null) {
> return
> getFullyQualifiedUid(obj.getParent())+"."+obj.getUid();
> } else {
> return obj.getUid();
> }
>
> }
>
> Then for all container objects, I iterate over each component within,
> and do:
>
> private void tryToWalk(UiObject obj) {
> // stuff removed for brevity ...
>
> if ( obj instanceof Container) {
> obj.components.each {child ->
>
> // print out some debug info
> printInfoForObject(child.getValue())
>
> descendent = obj.walkTo(ctx,
> UiID.convertToUiID(child.getValue
> ().uid));
> fqUid =
> getFullyQualifiedUid(child.getValue());
>
> if ( descendent ) {
> println("${fqUid}.walkTo: PASS:
> (from ${obj.uid})");
> tryToWalk(descendent);
> }
> // ...
> }
> }
> }
>
> So the question is...what do I do when a component within a container
> has a uid of 'all' -- I tried appending an index to the uid and
> passing it in, like 'UiID.convertToUiID(parentObj.uid+"[${idx}]") but
> that doesn't seem to produce a valid UiID.
>
> thanks!
> Jason
>
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---