I checked the code, the two children of the Option object do not need to be
the same as long as they
have the same uid. The implementation of the option object is pretty simple
as follows,

    public UiObject walkTo(WorkflowContext context, UiID uiid){

        //get the reference locator and store it
        String refenernceLocator = context.getReferenceLocator()

        //the option should always use the same Uid as its direct children
        //i.e., it just passes through and forward to its children.
        //as a result, we should not do the following
        //String child = uiid.pop()

        //Try to find all its children with the same uiid
        java.util.List<UiObject> children = getComponents(this.uid)
        if(children != null && children.size() > 0){
            Accessor accessor = new Accessor()
            for(UiObject child : children){

                UiID uiidclone = uiid.clone()

                //keep walking until get the last UiOjbect
                UiObject lastOne = child.walkTo(context, uiidclone)

                //get the whole xpath to the last UiObject
                String guess = context.getReferenceLocator()
                if(!guess.startsWith("//")){
                    guess =  "/" + guess
                }
                //check the current DOM to see if this xpath does exist
                int count =
accessor.getXpathCount(WorkflowContext.getDefaultContext(), guess)
                //found the xpath for the given UIID
                if(count == 1){
                     return lastOne
                }else{
                    //cannot find, or there are errors, try the next one
                    //need to reset the reference locator
                    context.setReferenceLocator(refenernceLocator)
                }
            }
        }else{
            println i18nBundle.getMessage("Container.NoUIObjectForOption",
{[this.uid , this.uid]})
            return null
        }
        println i18nBundle.getMessage("Container.CannotFindXPath",
{this.uid})
        return null
    }

That is to see, the Tellurium core will check each child to see if there is
a match in the DOM at runtime.
Since the Option object was created long time ago with XPath as the locator.
It may not work for CSS
selector. We need to update this.

Be aware, the new Tellurium does not support the Option object yet. You have
to use Tellurium Core to
generate the runtime xpath for your test.

Thanks,

Jian

On Wed, Jun 9, 2010 at 9:42 AM, Jian Fang <[email protected]> wrote:

> Hi Jonathan,
>
> The option object is used when you have two possible html presentations of
> the same UI at
> runtime.  For example, on tellurium issue page, we have the "List" or
> "Grid" link. The
> Container object might have to be the same, I cannot remember clearly and
> need to
> double check.
>
> In the meanwhile, you can use validate("validationErrors") or
> diagnose("validationErrors")
> to see if you can find some hints.
>
> Thanks,
>
> Jian
>
>
> On Wed, Jun 9, 2010 at 6:45 AM, Jonathan Share <[email protected]>wrote:
>
>> Hi,
>>
>> I have some generic error checking code that looks out for validation
>> errors on various forms, however the markup is slightly different on
>> one of the forms. This situation sounds very much like a use case for
>> the Option ui object and so I have defined the following;
>>
>>    ui.Option(uid: "validationErrors") {
>>            Container(uid: "validationErrors", clocator: [tag: "div",
>> 'class': "validation-error-box"]) {
>>                List(uid: "errors", clocator: [tag: "ul"]) {
>>                    TextBox(uid: "{all}", clocator: [tag: "li"])
>>                }
>>            }
>>            Container(uid: "validationErrors", clocator: [tag: "div",
>> 'class': "validationErrors"]) {
>>                List(uid: "errors", clocator: [tag: "ul"]) {
>>                    TextBox(uid: "{all}", clocator: [tag: "li"])
>>                }
>>            }
>>    }
>>
>> However when I call isElementPresent("validationErrors") I get an
>> exception.
>>
>>    org.telluriumsource.exception.UiObjectNotFoundException: Cannot
>> find UI Object validationErrors
>>
>> Is this a bug or have I misunderstood the usage of the Option object?
>>
>> Regards,
>>
>> Jonathan
>>
>> --
>> 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