1

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="NumberOfAdultRecords">
                            <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

Community
  • 1
  • 1
Julian Coates
  • 6,129
  • 3
  • 16
  • 5
  • 1
    Not an anwer, but wanted to share that I've moved from selenium to sahi: http://sahi.co.in/w/ I don't think i'll ever go back. Runs in IE, records most actions and doesn't fall over like selenium does with AJAX. see comparison here: http://blog.sahi.co.in/2010/04/sahi-vs-selenium.html – Moin Zaman Sep 09 '10 at 06:14

3 Answers3

0

select NumberOfAdultRecords 1

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

I m sure it will work.

user3487861
  • 340
  • 2
  • 2
0

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.......

Satish
  • 11
  • 4
0

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

dmitko
  • 2,607
  • 2
  • 21
  • 15