Using Selenium IDE to select dropdown by position

89 views
Skip to first unread message

DanS

unread,
Jan 29, 2010, 8:42:31 AM1/29/10
to Selenium Users
How can I pick a value in a dropdown menu by its position instaed of
it's label. I have an area where I will not have static labels in the
drop down, so I have to pick by position in the list versus what the
label is.

Thanks for any help.

Jerald paul

unread,
Jan 29, 2010, 8:51:15 AM1/29/10
to seleniu...@googlegroups.com
Hi
Try this code,

while (true)
    {
        if (!selenium.isElementPresent("xpath=//select[@name='XPATH_TO_SELECT_ELEMENT']/optgroup[2]/option[" + i + "]"))
        {
        break;
        }
        selenium.select("xpath=//select[@name='XPATH_TO_SELECT_ELEMENT']", "index=" + (i - 1) + "");

        i++;

    }

Thanks and Kind Regards
jerald





--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


DanS

unread,
Jan 29, 2010, 8:54:07 AM1/29/10
to Selenium Users
Thanks Jerald.

I was an idiot and didn't read this before posting.

http://release.seleniumhq.org/selenium-core/0.8.0/reference.html

On Jan 29, 8:51 am, Jerald paul <pauljer...@gmail.com> wrote:
> Hi
> Try this code,
>
> while (true)
>     {
>         if
> (!selenium.isElementPresent("xpath=//select[@name='XPATH_TO_SELECT_ELEMENT']/optgroup[2]/option["
> + i + "]"))
>         {
>         break;
>         }
>         selenium.select("xpath=//select[@name='XPATH_TO_SELECT_ELEMENT']",
> "index=" + (i - 1) + "");
>
>         i++;
>
>     }
>
> Thanks and Kind Regards
> jerald
>

> On 29 January 2010 19:12, DanS <thehappyd...@gmail.com> wrote:
>
> > How can I pick a value in a dropdown menu by its position instaed of
> > it's label. I have an area where I will not have static labels in the
> > drop down, so I have to pick by position in the list versus what the
> > label is.
>
> > Thanks for any help.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Selenium Users" group.
> > To post to this group, send email to seleniu...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > selenium-user...@googlegroups.com<selenium-users%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages