SelectedItemText and Text value is null for combobox.

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
deepak1920
Posts: 19
Joined: Sat Feb 13, 2016 5:04 pm

SelectedItemText and Text value is null for combobox.

Post by deepak1920 » Tue Aug 02, 2016 7:29 am

Hi,

In windows metro style app, I have one combobox. This combobox is created after overriding the default template of combobox. Now it is like - Grid -> Rectangle -> Combobox.

The implementation is same as of answer shown for button on following link:

https://social.msdn.microsoft.com/Forum ... withcsharp

Now when I select the combobox using ranorex spy, it shows selectedindex value = -1 and selecteditemtext value is blank.

Do we have some way to get the selected value using ranorex? Actually I want to make sure that particular item got selected or not.


Thanks!
Attachments
combobox.png
combobox.png (49.38 KiB) Viewed 826 times
Last edited by deepak1920 on Tue Aug 02, 2016 7:42 am, edited 1 time in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3933
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: SelectedItemText and Text value is null for combobox.

Post by odklizec » Tue Aug 02, 2016 7:34 am

Hi,

Please upload a Ranorex snapshot of the problematic element. Without snapshot, it's next to impossible to suggest something reliable. Also, always mention your actual Ranorex version. Thank you.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

deepak1920
Posts: 19
Joined: Sat Feb 13, 2016 5:04 pm

Re: SelectedItemText and Text value is null for combobox.

Post by deepak1920 » Tue Aug 02, 2016 7:43 am

Hi,

I have uploaded the spy snapshot for the control. And I am using version #5.4.5.19886


Option value 'No' was selected in combobox while taking this snapshot.



Thanks!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3933
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: SelectedItemText and Text value is null for combobox.

Post by odklizec » Tue Aug 02, 2016 7:50 am

Hi, what you have uploaded is "screenshot" not "snapshot". Screenshot is unfortunately not helpful at all. Please learn how to create a Ranorex snapshot >here<.

Also, please take the snapshot with instant tracking (Ctrl+Win shortcut) while the combo box is opened and at least one item is selected.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

deepak1920
Posts: 19
Joined: Sat Feb 13, 2016 5:04 pm

Re: SelectedItemText and Text value is null for combobox.

Post by deepak1920 » Tue Aug 02, 2016 8:03 am

Hi,

I got the snapshot using (Ctrl+Win) shortcut.

In snapshot on the right side bottom, it won't show the combobox visually. Once I click save snapshot, it forces the default app to come into foreground and takes the screenshot from there.


Please let me know if you need more information on the same.


Thanks!
Attachments
combobox_snapshot.rxsnp
(39.54 KiB) Downloaded 38 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3933
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: SelectedItemText and Text value is null for combobox.

Post by odklizec » Tue Aug 02, 2016 12:06 pm

Hi,

Unfortunately, the snapshot shows "invalid" next to combobox listitems, so it seems the snapshot has been saved with no longer valid data. I'm not sure how your application really works and what you mean by "it forces default app to come into foreground". Are there more apps/windows running at the same time - the one with opened combobox and the other one with main interface? Please kill all apps/windows and make sure there is opened only the one with combobox (if possible).

Also, please go to Spy settings and examine the state of Use Hidden Screenshot Capturing option in Advanced tab. By default, it should be enabled. Try to disable it. If it's already disabled, enable it ;) And finally, please uncheck the option "Let snapshot contain complete ancestor subtree".

Then try to take the snapshot again (using Ctrl+Left Win), with opened combo and selected item yes or no. Before you save the snapshot, examine the state of Selected attribute for selected item (yes or no). If Selected attribute for selected item contains a value (I guess 'true'), you have to use this attribute instead of selectedindex. It should be relaitve easy to loop through all combo items and find the one with Selected attribute 'true'. Eventually, you can create a corresponding xpath, which returns only 'selected' item, for example like this:
/winapp[@packagename='Monotype.PrinterExtension']/container/combobox[@automationid='PageBlackTextComboBox']/listitem[@[email protected]]
But of course, it depends on correctly set 'Selected' attribute. If not set (by your app), you are out of luck. My guess why the selectedindex contains -1 is that it's not correctly set by your app either?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration