Question

I have a select_list that gets populated in runtime. I need to select a value based on the item index.

Eg.

self.myselectlist1.option(indexval).select

If the indexval I pass is 3, it should select the third item.

The above code errors out. Is there an alternate way?

Was it helpful?

Solution

Assuming that myselectlist1 is the name of a select list defined in an accessor, you want:

self.myselectlist1_element.options[0].click

Explanation:

  1. myselectlist1_element is used to get the select list element.
  2. options returns an array of option elements for the select list.
  3. [0] returns the first item of the options array
  4. click clicks the option to select it. There is no select defined for options (ie you will get a deprecation warning).

OTHER TIPS

You have 3 issues:

  1. The method you're looking for is "options" not "option"
  2. Use brackets instead of parenthesis.
  3. use click instead of select.

myselectlist1.options[indexval].click

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top