开发者

Selenium IDE - unable to select value in list possibly due to 'onchange' event

I'm having trouble running the following command to select a value in a drop down list using selenium IDE.


Command = Select Target = NumberOfAdultRecords Value = label=4


When i run the test above in sequence with the other commands in the test case, the value 4 is not selected in the drop down. If i select only that one command line and use the 'Find' feature it highlights the element and if i double click the command while the test is paused or stopped it successfully selects the 4th value.

I've sourced other explanations and found this Selenium onChange not working and i believe that i'm experiencing the same issue with the OnChange event.

Could some please help me write a test command to select the 4th value within the following code:

<div style="background-color: rgb(255, 204, 0); width: 66px; height: 35px; float: left;"><select onchange="javascript:updateCostsAdult(this.value);" id="NumberOfAdultRecords" name="NumberOfAdultRe开发者_StackOverflow社区cords">
                            <option selected="" value="0">0</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                      </select></div>

I would really appreciate any help

Cheers

Jules


You may try to use JavaScript to select the value:

http://wiki.openqa.org/display/SEL/eval

selenium.browserbot.getCurrentWindow().getElementById('you_select_id_here').selectedIndex=4


select NumberOfAdultRecords 1

Try the above and Let me know is it working or not.

I m sure it will work.


Other way I achieved this is by using below method for all my onchange dropdownselection boxes. Pass id and selection and it works

public void onchangedropdownselection(String object, String value) {
        driver.findElement(By.id(object)).sendKeys(value);
        driver.findElement(By.id(object)).sendKeys(Keys.UP);
        driver.findElement(By.id(object)).sendKeys(Keys.DOWN);
    }

By doing up and down we are initialzing the script onchange.......

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜