Letractively / aost

Automatically exported from code.google.com/p/aost
Other
1 stars 0 forks source link

Option object upgrade in 0.8.0 #435

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

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.

Original issue reported on code.google.com by John.Jian.Fang@gmail.com on 9 Jun 2010 at 6:54

GoogleCodeExporter commented 8 years ago

Original comment by John.Jian.Fang@gmail.com on 9 Jun 2010 at 6:55

GoogleCodeExporter commented 8 years ago
Issue 434 has been merged into this issue.

Original comment by John.Jian.Fang@gmail.com on 9 Jun 2010 at 7:58

GoogleCodeExporter commented 8 years ago

Original comment by John.Jian.Fang@gmail.com on 24 Jun 2010 at 7:28