Not able to select an item from dropdown in web

Ask general questions here.
kiran.pol
Posts: 12
Joined: Tue Oct 06, 2009 7:40 am

Not able to select an item from dropdown in web

Post by kiran.pol » Wed Jun 02, 2010 2:53 pm

Hi

i have tried this code to select a value from dropdown but it is not working for me

WebDocument webdoc = "/dom[@caption='pagecaption']";
SelectTag cngcntry = webdoc.FindSingle(".//select[@id='idvalue']");
cngcntry.Click();
Delay.Seconds(2);
ListItem item = "/container[@caption='selectbox']/listitem[@innertext='itemtext']";
item.Click();

i get the error "Ranorex.ElementNotFoundException: No element found for path '/container[@caption='selectbox']/listitem[@innertext='textvalue']' within 5000ms. at Ranorex.Core.Element.FindSingle(RxPath path, Duration timeout) at Ranorex.Core.Element.op_Implicit(String path) at Ranorex.ListItem.op_Implicit(String path) at sdsfg.Program.Main(String[] args)

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Not able to select an item from dropdown in web

Post by Ciege » Wed Jun 02, 2010 3:47 pm

Are you setting a value for "itemText"?

Your code should be written such that itemText is used as a variable like so:

Code: Select all

ListItem item = "/container[@caption='selectbox']/listitem[@innertext='" + itemtext + "']";
And you need to set itemtext to a valid list item.

Also make sure that "selectbox" is the proper object name of your container.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

kiran.pol
Posts: 12
Joined: Tue Oct 06, 2009 7:40 am

Re: Not able to select an item from dropdown in web

Post by kiran.pol » Thu Jun 03, 2010 10:21 am

Hi

it is working fine with the below code ...

ListItem item = "/container[@caption='selectbox']/listitem[@accessiblename='" + itemtext + "']";

not sure why it is not working with innertext .....

Thanks
Kiran Pol

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Not able to select an item from dropdown in web

Post by Support Team » Fri Jun 04, 2010 9:10 am

kiran.pol wrote:not sure why it is not working with innertext .....
I guess because the element does not have an attribute with that name. You can only use those attribute that are listed for that element in Ranorex Spy when you track it.

Please, have a look at the Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... apter.html

Regards,
Alex
Ranorex Support Team