Sorry, I was wrong, "index" parameter is correct. Seems "selectedIndex" is
only used in jQuery.

http://marcgrabanski.com/articles/jquery-select-list-values

Then, the problem is really wired.

I just added the getSelectedIndex() to the Engine project. Only for proof
purpose, if you run the following snapshot selenium server with Tellurium
APIs and cache enabled,

http://maven.kungfuters.org/content/repositories/snapshots/org/seleniumhq/selenium/server/selenium-server/1.0.1-te5-SNAPSHOT/selenium-server-1.0.1-te5-20100903.202424-2.jar

is the problem still there?

Thanks,

Jian

On Fri, Sep 3, 2010 at 3:50 PM, Jian Fang <[email protected]> wrote:

> Hi Jade,
>
> If you are not using Tellurium Engine, you don't need to use cache. Since
> the getSelectedIndex is not
> implemented in Tellurium APIs, Tellurium Engine simply delegates the call
> to Selenium core. To prove this,
> set
>
> useTelluriumApi(false);
>
> to see if the problem is still there.
>
> If it is still there, it must be the Selenium API problem. I suspect the
> "index" parameter in the method getSelectedIndex()
> should be "selectedIndex".
>
> Will try some tests later.
>
> Thanks,
>
> Jian
>
>
> On Fri, Sep 3, 2010 at 3:23 PM, Jade <[email protected]> wrote:
>
>> Hi Jian,
>>
>> getSelectedValue works fine as does getSelectOptions and
>> getSelectValues.
>>
>> These are my test options:
>>
>> useTelluriumEngine(false);
>>                useTelluriumApi(true);
>>                useCache false
>>                useCssSelector(true);
>>                useTrace(true);
>>
>> I set useCache to false since the html changes with ajax but it
>> doesn't seem to fix those problems.
>>
>> The following method works since I changed to using getSelectedValue
>> instead of getSelectedIndex but it would be nice to have both options.
>>
>> /**
>>         * Test the option specified by the indx for the selection.
>>         *
>>         * @param uid
>>         * @param module
>>         * @param indx
>>         * @param shouldFail -- true if the indx should not be able to be
>> selected
>>         */
>>         public static void selectClickableOption(final String listUid,
>> final
>> String selectorId,
>>        final DslContext module, final int indx, boolean shouldFail) {
>>
>>                 log.info "selectClickableOption ${selectorId}"
>>                 // With Ajax, the module has to be clicked on so the uid
>> is found.
>>                module.click listUid
>>
>>                int len = module.getSelectOptions(selectorId).size()
>>
>>                log.info("selector size (" + selectorId + "): " + len);
>>
>>
>>                if (indx > len) {
>>                        fail("${indx} > selector size, ${selectorId}, size:
>> ${len}")
>>                }
>>
>>                 if (indx < 1) {
>>                        fail("indx: ${indx} must be at least 1 or greater,
>> ${selectorId},
>> size: ${len}")
>>                }
>>
>>                boolean successful = false;
>>                int maxTries = 5;
>>                int tries = 0;
>>                // Due to ajax timing issues, try more than once to perform
>> this
>> action.
>>                while (!successful && tries < maxTries) {
>>                        try {
>>                                // workaround due to tellurium bug with
>> indx problem returning 48
>> when index set to 1
>>                                // see
>> http://groups.google.com/group/tellurium-users/browse_thread/thread/994b889df6140bc1/5529f3dd9607fbec#5529f3dd9607fbec
>>                                 // With Ajax, the module has to be clicked
>> on so the uid is found.
>>                                module.click listUid
>>
>>  module.pause(VireoTestConfig.getPauseTime());
>>
>>                                String[] values =
>> module.getSelectValues(selectorId)
>>                                for (value in values)
>>                                        log.info "value: ${value}"
>>
>>                                // With Ajax, the module has to be clicked
>> on so the uid is found.
>>                                module.click listUid
>>
>>  module.pause(VireoTestConfig.getPauseTime());
>>
>>                                String[] options =
>> module.getSelectOptions(selectorId)
>>                                for (option in options)
>>                                        log.info "option: ${option}"
>>
>>                                // without this, times out and field is no
>> longer selectable
>>                                module.click listUid
>>
>>  module.pause(VireoTestConfig.getPauseTime());
>>                                 String origValue =
>> module.getSelectedValue(selectorId)
>>
>>                                 module.click listUid
>>
>>  module.pause(VireoTestConfig.getPauseTime());
>>                                 int origIndx =
>> module.getSelectedIndex(selectorId);
>>                                 log.info "origIndx: ${origIndx}"
>>                                // bug?
>>                                // module.selectByIndex(selectorId, indx);
>>
>>                                // int selected =
>> module.getSelectedIndex(selectorId);
>>                                 module.click listUid
>>                                module.selectByValue selectorId,
>> values[indx]
>>                                module.click listUid
>>                                String selectedValue =
>> module.getSelectedValue(selectorId)
>>
>>                                //              if (shouldFail) {
>>                                //
>>  assertEquals("selectOption: selecting ${indx} for $
>> {selectorId} should have failed", origIndx, selected);
>>                                //              } else {
>>                                //
>>  assertEquals("selectOption: selecting ${indx} for $
>> {selectorId} should have succeeded", indx, selected);
>>                                 //              }
>>                                successful = true
>>                                 if (shouldFail) {
>>                                        assertEquals("selectOption:
>> selecting ${indx} for ${selectorId}
>> should have failed", origValue, selectedValue);
>>                                 } else {
>>                                        assertEquals("selectOption:
>> selecting ${indx} for ${selectorId}
>> should have succeeded", values[indx], selectedValue);
>>                                }
>>                        } catch (Exception e) {
>>                                log.error("ajax timing error: " +
>> e.getMessage())
>>                                tries++
>>                        } catch (Throwable t) {
>>                                log.error("ajax timing error: " +
>> t.getMessage())
>>                                tries++
>>                        }
>>                }
>>        }
>>
>> Jade
>>
>> On Sep 3, 1:24 pm, Jian Fang <[email protected]> wrote:
>> > The Selenium call stack is as follows:
>> >
>> > Selenium.prototype.getSelectedIndex = function(selectLocator) {
>> >     /** Gets option index (option number, starting at 0) for selected
>> option
>> > in the specified select element.
>> >    *
>> >    * @param selectLocator an <a href="#locators">element locator</a>
>> > identifying a drop-down menu
>> >    * @return string the selected option index in the specified select
>> > drop-down
>> >    */
>> >     return this.findSelectedOptionProperty(selectLocator, "index");
>> >
>> > }
>> >
>> > Selenium.prototype.findSelectedOptionProperty = function(locator,
>> property)
>> > {
>> >     var selectedOptions = this.findSelectedOptionProperties(locator,
>> > property);
>> >     if (selectedOptions.length > 1) {
>> >         Assert.fail("More than one selected option!");
>> >     }
>> >     return selectedOptions[0];
>> >
>> > }
>> >
>> > Selenium.prototype.findSelectedOptionProperties = function(locator,
>> > property) {
>> >    var element = this.browserbot.findElement(locator);
>> >    if (!("options" in element)) {
>> >         throw new SeleniumError("Specified element is not a Select (has
>> no
>> > options)");
>> >     }
>> >
>> >     var selectedOptions = [];
>> >
>> >     for (var i = 0; i < element.options.length; i++) {
>> >         if (element.options[i].selected)
>> >         {
>> >             var propVal = element.options[i][property];
>> >             selectedOptions.push(propVal);
>> >         }
>> >     }
>> >     if (selectedOptions.length == 0) Assert.fail("No option selected");
>> >     return selectedOptions;
>> >
>> > }
>> >
>> > The getSelectedValue implementation is similar:
>> >
>> > Selenium.prototype.getSelectedValue = function(selectLocator) {
>> >     /** Gets option value (value attribute) for selected option in the
>> > specified select element.
>> >    *
>> >    * @param selectLocator an <a href="#locators">element locator</a>
>> > identifying a drop-down menu
>> >    * @return string the selected option value in the specified select
>> > drop-down
>> >    */
>> >     return this.findSelectedOptionProperty(selectLocator, "value");
>> >
>> > }
>> >
>> > What is the value your get back for getSelectedValue()?
>> >
>> > If getSelectedValue() returns a correct value, then it is the
>> > getSelectedIndex() implementation problem.
>> > If both return wrong values, then, it is probably the runtime locator
>> > problem. Are you using CSS selector?
>> >
>> > Thanks,
>> >
>> > Jian
>> >
>> > On Fri, Sep 3, 2010 at 11:10 AM, Jade <[email protected]> wrote:
>> > > Hi Jian,
>> >
>> > > The HTMLSource is very long. Here's the part that matches this
>> > > selector in one module: Selector(uid: "degreeSelector", clocator: [id:
>> > > "aspect_vireo_admin_View_field_degree"])
>> >
>> > > and the List in the other module:  List(uid: "degree", clocator: [tag:
>> > > "ol", id: "aspect_vireo_admin_View_field_degree"], separator: "li") {
>> > >                                Container(uid: "{all}", clocator: [:])
>> > >                        }
>> >
>> > > <div class="ds-form-content">
>> > > <div class="editableWrap"><ol alt="fakefield_20" title=""
>> > > id="aspect_vireo_admin_View_field_degree" class="fakeField fakeSelect
>> > > ds-select-field degree editable"><li class="hidden" id="">none</li><li
>> > > class="selected" id="Test Degree4">Test Degree4</li><li class="hidden"
>> > > id="Test Degree3">Test Degree3</li><li class="hidden" id="Test
>> > > Degree2">Test Degree2</li><li class="hidden" id="Business">Business</
>> > > li><li class="hidden" id="Computer Science">Computer Science</li><li
>> > > class="hidden" id="Test Degree1">Test Degree1</li></ol></div>
>> > > </div>
>> >
>> > > Jade
>> >
>> > > On Sep 3, 9:50 am, Jian Fang <[email protected]> wrote:
>> > > > Hi Jade,
>> >
>> > > > the getHTMLSource command only works for Tellurium new Engine. You
>> can
>> > > make
>> > > > that call with the new engine as follows:
>> >
>> > > >                click "DegreeInformationForm.degree"
>> >
>> > > >                useTelluriumEngine(true)
>> > > >                                log.info "htmlSource: " +
>> > > > getHTMLSource("DegreeInformationClickedForm.degreeSelector")
>> > > >                useTelluriumEngine(false)
>> >
>> > > >  TestingUtils.selectClickableOption("DegreeInformationForm.degree",
>> > > > "DegreeInformationClickedForm.degreeSelector", this, indxToTest,
>> > > > shouldFail)
>> >
>> > > > Hope this helps.
>> >
>> > > > Thanks,
>> >
>> > > > Jian
>> >
>> > > > On Fri, Sep 3, 2010 at 9:57 AM, Jade <[email protected]> wrote:
>> > > > > Hi Jian,
>> >
>> > > > > I'm getting an exception when requesting the HTML source: ERROR:
>> > > > > Cannot find UI module DegreeInformationClickedForm.degreeSelector
>> from
>> > > > > cache
>> >
>> > > > > Here are my lines of code (I first clicked on the list):
>> >
>> > > > >                click "DegreeInformationForm.degree"
>> > > > >                                log.info "htmlSource: " +
>> > > > > getHTMLSource("DegreeInformationClickedForm.degreeSelector")
>> >
>> > > > >
>>  TestingUtils.selectClickableOption("DegreeInformationForm.degree",
>> > > > > "DegreeInformationClickedForm.degreeSelector", this, indxToTest,
>> > > > > shouldFail)
>> >
>> > > > > My module def:
>> >
>> > > > > public void defineModule() {
>> > > > >                ui.Form(uid: "DegreeInformationForm", clocator:
>> [tag:
>> > > > > "form",
>> > > > > method: "post", action: "${postAction}", class:
>> "ds-interactive-div
>> > > > > view-form", id: "aspect_vireo_admin_View_div_view-form"]) {
>> > > > >                        InputBox(uid: "committee_member_2",
>> clocator:
>> > > [tag:
>> > > > > "input", id:
>> > > > > "aspect_vireo_admin_View_field_committee-member-2", type: "text"],
>> > > > > respond: ["click"])
>> > > > >                        InputBox(uid: "committee_member_1",
>> clocator:
>> > > [tag:
>> > > > > "input", id:
>> > > > > "aspect_vireo_admin_View_field_committee-member-1", type: "text"],
>> > > > > respond: ["click"])
>> >
>> > > > >                        List(uid: "degree", clocator: [tag: "ol",
>> id:
>> > > > > "aspect_vireo_admin_View_field_degree"], separator: "li") {
>> > > > >                                Container(uid: "{all}", clocator:
>> [:])
>> > > > >                        }
>> > > > >                        InputBox(uid: "school", clocator: [tag:
>> "input",
>> > > id:
>> > > > > "aspect_vireo_admin_View_field_school", type: "text"], respond:
>> > > > > ["click"])
>> > > > >                        InputBox(uid: "committee_email", clocator:
>> [tag:
>> > > > > "input", id:
>> > > > > "aspect_vireo_admin_View_field_committee-email", type: "text"],
>> > > > > respond: ["click"])
>> > > > >                        InputBox(uid: "department", clocator: [tag:
>> > > "input",
>> > > > > id:
>> > > > > "aspect_vireo_admin_View_field_department", type: "text"],
>> respond:
>> > > > > ["click"])
>> >
>> > > > >                        List(uid: "college", clocator: [tag: "ol",
>> id:
>> > > > > "aspect_vireo_admin_View_field_college"], separator: "li",
>> respond:
>> > > > > ["click"]) {
>> > > > >                                Container(uid: "{all}", clocator:
>> [:])
>> > > > >                        }
>> > > > >                        InputBox(uid: "committee_member_3",
>> clocator:
>> > > [tag:
>> > > > > "input", id:
>> > > > > "aspect_vireo_admin_View_field_committee-member-3", type: "text"],
>> > > > > respond: ["click"])
>> > > > >                        InputBox(uid: "discipline", clocator: [tag:
>> > > "input",
>> > > > > id:
>> > > > > "aspect_vireo_admin_View_field_discipline", type: "text"],
>> respond:
>> > > > > ["click"])
>> > > > >                        InputBox(uid: "semester", clocator: [tag:
>> > > "input",
>> > > > > id:
>> > > > > "aspect_vireo_admin_View_field_semester", type: "text"], respond:
>> > > > > ["click"])
>> >
>> > > > >                        List(uid: "degreeLevel", clocator: [tag:
>> "ol",
>> > > id:
>> > > > > "aspect_vireo_admin_View_field_degreeLevel"], separator: "li",
>> > > > > respond: ["click"]) {
>> > > > >                                Container(uid: "{all}", clocator:
>> [:])
>> > > > >                        }
>> > > > >                }
>> >
>> > > > >                //Since ajax changes the html when a list is
>> clicked,
>> > > this
>> > > > > module is
>> > > > > required to represent clickable lists once they've been clicked.
>> > > > >                //  For more information, see:
>> >
>> > > > >
>> http://groups.google.com/group/tellurium-users/browse_thread/thread/9.
>> > > ..
>> > > > >                //
>> > > > >                ui.Form(uid: "DegreeInformationClickedForm",
>> clocator:
>> > > [tag:
>> > > > > "form",
>> > > > > method: "post", action: "${postAction}", class:
>> "ds-interactive-div
>> > > > > view-form", id: "aspect_vireo_admin_View_div_view-form"]) {
>> >
>> > > > >                        Selector(uid: "degreeSelector", clocator:
>> [id:
>> > > > > "aspect_vireo_admin_View_field_degree"])
>> > > > >                        Selector(uid: "collegeSelector", clocator:
>> [id:
>> > > > > "aspect_vireo_admin_View_field_college"])
>> > > > >                        Selector(uid: "degreeLevelSelector",
>> clocator:
>> > > [id:
>> > > > > "aspect_vireo_admin_View_field_degreeLevel"])
>> > > > >                }
>> >
>> > > > > ERROR: Cannot find UI module
>> > > > > DegreeInformationClickedForm.degreeSelector from cache
>> >
>> > >
>> com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:
>> > > > > 97)
>> >
>> > >
>> com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:
>> > > > > 91)
>> > > > >
>> sun.reflect.GeneratedMethodAccessor80.invoke(Unknown
>> > > > > Source)
>> >
>> > >
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
>> > > > > 43)
>> > > > >                java.lang.reflect.Method.invoke(Method.java:616)
>> > > > >
>>  org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite
>> > > > >
>> $PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:
>> > > > > 229)
>> >
>> > >
>> org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:
>> > > > > 52)
>> >
>> > >
>> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
>> > > > > 129)
>> >
>> > >
>> org.telluriumsource.component.connector.CustomSelenium.getBundleResponse(CustomSelenium.groovy:
>> > > > > 257)
>> > > > >
>> sun.reflect.GeneratedMethodAccessor79.invoke(Unknown
>> > > > > Source)
>> >
>> > >
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
>> > > > > 43)
>> > > > >                java.lang.reflect.Method.invoke(Method.java:616)
>> >
>> > > > >
>>  org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:
>> > > > > 88)
>> >
>> > >  groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
>> >
>> > > > >  groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
>> >
>> > > > >  groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
>> >
>> > ...
>> >
>> > read more ยป
>>
>> --
>> 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