Page 1 of 1

Select an "OptionTag" on SelectTag

Posted: Tue Nov 09, 2010 5:44 pm
by sundarpn
I have a web page dialog and in there is a Select Drop down called "Encounter Type". I want to select a specific encounter type. (note that some options might be hidden and a scroll bar might appear).

I have attached the snapshot of the "Encounter Selector" Dialog
EncounterSelector.rxsnp
Screen shot of application showing this drop-down.
SelectTag.JPG
My Repository.
Repo.JPG
.

Code: I want to select the encounter type of "other"
...
...
Repo.WebDocumentEncounter_Selector.SelectTagSelEncounterType
.RMouseClick(message: "Mouse clicked 'Encounter Type' dropdown", delay: 250); //Mouse click to open the dropdown.

OptionTag tag = Repo.WebDocumentEncounter_Selector.SelectTagSelEncounterType.FindSingle("./option[@innertext='Other']");
m_Logger.ReportInfo("----------> " + tag.Visible.ToString());
tag.EnsureVisible(); // I am using ensure visible with the hope that it will scroll the list if the option is not in the visible area.
m_Logger.ReportInfo("----------> After Ensure Visible " + tag.Visible.ToString());

//Issue #1
tag.PerformClick(); //Weird issue. This select the option "CDA" eventhough tag show inner text of "Other"??

//Other options I tried...:
//tag["selected"] = "selected"; //Again selected "CDA". Weird?

Issue #2
//tag.Selected = true; // this selected "Other" however the "OK" button on the dialog is not getting enabled. i.e. App is not seeing the selection.

So:
1. I need to know why Issue #1 is selecting "CDA" when 'tag' option object is for "Other"? This is a bug.
2. What options do I have for issue #2.

Re: Select an "OptionTag" on SelectTag

Posted: Tue Nov 09, 2010 6:55 pm
by Ciege
Have a look at this thread that should help you out with your questions:
http://www.ranorex.com/forum/html-select-box-t1714.html

Re: Select an "OptionTag" on SelectTag

Posted: Tue Nov 09, 2010 8:11 pm
by sundarpn
yes, we actually tried that approach of dropping the select box down and then finding the "Listitem". That works fine except in the case when the list item is not visible. If the item is not visible, it throws an element not found exception.

Screen shot:
SelectDropDownScrollbar.JPG

So I added the scroll bar and did a simple while loop like this...

//...Select drop down is already open via click

Code: Select all

ListItem item = null;
System.DateTime start = System.DateTime.Now;

while (!Repo.ContainerSelectbox.Self.TryFindSingle("./listitem[@text='" + encounterType + "' and @visible='true']", 3000, out item))
{
        if( (System.DateTime.Now - start).TotalSeconds > m_WaitCheckTimeoutSecs)
               throw new EEHREnsureVisibleFailureException("Encounter Selector ->Encounter Type: " + encounterType + " failed to become visible.");

        Repo.ContainerSelectbox.btnLine_down.Click();
        m_Logger.ReportInfo("Clicked Line Down");

}

  //item.Select(); //dind't work. have to use mouse click

item.RMouseClick(message: "Mouse clicked '" + encounterType + "' on 'Encounter Type' dropdown", delay: 250);

m_Logger.ReportStep("Selected '" + encounterType + "' on 'Encounter Type' dropdown");

NOTE: the screen shot above is from my actual run when scroll down btn was pressed like 5 times and you can see the item "other" is indeed visible... But ranorex still did not find it and threw my exception with this message "Encounter Selector ->Encounter Type: Other failed to become visible."

Re: Select an "OptionTag" on SelectTag

Posted: Tue Nov 09, 2010 8:28 pm
by Ciege
Try increasing your findsingle timeout from 3000 to 30000. You could be timing out before Ranorex gets a chance to actually search for and find the item.

Re: Select an "OptionTag" on SelectTag

Posted: Wed Nov 10, 2010 11:42 am
by Support Team
Hi,

Please could you post us a Ranorex snapshot of the container in your use case above?
To track the container of the select-box you have to use Instant Tracking of Spy and then save it as snapshot.
Instant Tracking
Create a Snapshot

Thanks in advance.

Regards,
Peter
Ranorex Team

Re: Select an "OptionTag" on SelectTag

Posted: Wed Nov 10, 2010 4:58 pm
by sundarpn
Hello,

I have captured the snapshot of the container that drops down showing the list items. (using instant tracking)
Container_DropDown.rxsnp
Another Screenshot showing this dropdown.
pic_Encounter_Type_Dropdown.JPG
My post above also has the code snippet and the associated repository we use.

Re: Select an "OptionTag" on SelectTag

Posted: Wed Nov 10, 2010 5:13 pm
by sundarpn
Hello,

For some reason, the snapshot of the Container I attached isn't complete. The size is only 1 KB and is NOT capturing the list items shown. I tried again and the result is the same...

See this screen shot.
screen_shot.JPG

Re: Select an "OptionTag" on SelectTag

Posted: Thu Nov 11, 2010 11:32 am
by Support Team
Hi,

I think this is a "msaa" limitation. Instead of posting us the Ranorex Snapshot, would it be possible to post us a screenshot where you instant track the combo box and we can also see the spy on this screenshot. Are the list items always invisible or only if you have to scroll to one list item inside the combo box. See Ranorex Spy all elements even, when you have to scroll to elements? (some elements should have the state "visible" and some have the "invisible" state)

Thanks in advance.

Regards,
Peter
Ranorex Team

Re: Select an "OptionTag" on SelectTag

Posted: Thu Nov 11, 2010 10:22 pm
by sundarpn
When we run the scripts with our own suiterunner via Teamcity on an agent m/c, for some reason that drop-down shows a scroll-bar within it. (You can see this in the screen shot on second post in this thread dated Tue Nov 09, 2010 2:11 pm)

But the last two screen shot I posted was from my local desktop in which I don't see the scroll bar. I tried reducing the resolution of my desktop down to 800 by 600 and even then the scroll bar wouldn't appear.

Re: Select an "OptionTag" on SelectTag

Posted: Mon Nov 15, 2010 11:20 am
by Support Team
Hi,

Maybe the different skin of you operating system, forces your application to paint the combo box in a different way. Have you tried to use the same setting from the computer with the "combo box scrollable" on your computer. Another possibility could be the Internet Explorer. Maybe on your computer is 8.0 installed and on the other machine 7.0.

Regards,
Peter
Ranorex Team