Letractively / aost

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

select command does not pass in correct select option in Tellurium IDE 0.8.0 #452

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
# [info] Run command select('Standaloneoptions.Searchform2.Subsidiary.Id_sort', 
'Apperance')
# [info] Executing command select failed: message: split[1] is undefined, name: 
TypeError, filename: chrome://trump/content/engine/tellurium-cmd.js, 
linenumber: 303. JavaScript Error Stack: 
{anonymous}("Standaloneoptions.Searchform2.Subsidiary.Id_sort","Apperance")@chro
me://trump/content/engine/tellurium-cmd.js:322 
{anonymous}("select","Standaloneoptions.Searchform2.Subsidiary.Id_sort","Apperan
ce")@chrome://trump/content/engine/tellurium-cmd.js:141 
{anonymous}()@chrome://trump/content/editor.js:549 oncommand([object 
XULCommandEvent])@chrome://trump/content/trump-ide.xul:1 

TelluriumCommand.prototype.select = function(uid, optionLocator){
    var optionSelector = this.getOptionSelector(optionLocator);
    this.execCommand("select", uid, optionSelector);
};

TelluriumCommand.prototype.getOptionSelector = function(optionLocator){
    var split = optionLocator.split("=");
    var sel = "";
    split[0] = split[0].trim();
    split[1] = split[1].trim();
    if(split[0] == "label" || split[0] == "text"){
        sel = this.cssBuilder.buildText(split[1]);
    }else if(split[0] == "value"){
        sel = this.cssBuilder.buildAttribute(split[0], split[1]);
    }else if(split[0] == "index"){
        var inx = parseInt(split[1]) - 1;
        sel = ":eq(" + inx + ")"
    }else if(split[0] == "id"){
        sel = this.cssBuilder.buildId(split[1]);
    }else{
        logger.error("Invalid Selector optionLocator " + optionLocator);
        return null;
    }

    return sel;
};

Original issue reported on code.google.com by John.Jian.Fang@gmail.com on 26 Jul 2010 at 9:03

GoogleCodeExporter commented 8 years ago

Original comment by John.Jian.Fang@gmail.com on 26 Jul 2010 at 9:03

GoogleCodeExporter commented 8 years ago
The selector object should include methods such as selectByValue, 
selectByIndex, selectByLabel, and so on.

var UiSelector = UiObject.extend({
    init: function(){
        this._super();
        this.uiType = 'Selector';
        this.tag = "select";
    },

    select: function(context, optionSelector){
        var element = context.domRef;
        var $sel = teJQuery(element);
        //first, remove all selected element
        $sel.find("option").removeAttr("selected");
        //construct the select option
        var opt = "option" + optionSelector;
        //select the appropriate option
        $sel.find(opt).attr("selected", "selected");
        if (teJQuery.browser.msie) {
            element.fireEvent("onchange");
        } else {
            var evObj = document.createEvent('HTMLEvents');
            evObj.initEvent('change', true, true);
            element.dispatchEvent(evObj);
        }
    }
});

Original comment by John.Jian.Fang@gmail.com on 26 Jul 2010 at 9:06

GoogleCodeExporter commented 8 years ago
use label and regular expression

Original comment by John.Jian.Fang@gmail.com on 8 Aug 2010 at 12:49