unable to find selected text in a drop down

Ask general questions here.
rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

unable to find selected text in a drop down

Post by rsudhak » Fri Apr 26, 2019 3:57 pm

Hi ,

For our desktop applications . I have a drop down. I want to check the selected item in the drop down, unable to do so .

I need to checkthe selected item for Combobox CableTypeComboBox

Attached the snapshot of the control.... using uipreffered and wpf both.

thanks
rajee
Attachments
wpf.rxsnp
(788.88 KiB) Downloaded 14 times
wew.rxsnp
(61.2 KiB) Downloaded 13 times

McTurtle
Posts: 255
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: unable to find selected text in a drop down

Post by McTurtle » Mon Apr 29, 2019 7:10 am

Hi rsudhak,

I've downloaded this demo: Telefik WPF
I searched for RadDropDownButton to find the control that you are using and I created a few steps of navigation 2 levels deep into the menu. Truly, the composition of this control is "strange" for someone who is used to standard WPF controls :) Don't use UIA for this control, please use WpfImprovedOnly. I was able to create a simple test by tracking the elements with Ranorex Spy, adding them to the repository manually and then creating the mouse-move/click actions. Have you already tried that?

You also did not really explain what you mean by "unable to do so". Please be more specific. What did you try and what failed?

Regards,
McTurtle

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: unable to find selected text in a drop down

Post by rsudhak » Mon Apr 29, 2019 10:10 am

Thanks for the reply .Can I use wpfimproved just for the particular dropdown list in the code?

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

Re: unable to find selected text in a drop down

Post by odklizec » Mon Apr 29, 2019 11:36 am

Hi,

You can learn here how to switch between wpfimproved and wpfonly using code:
viewtopic.php?f=16&t=10871&p=43882
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

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: unable to find selected text in a drop down

Post by rsudhak » Mon Apr 29, 2019 1:14 pm

Currently, my scenario is to switch to wpfimprovedonly, and check the caption of the element which is a text, then switch back to ui , while doing so I am getting an error wherein path cant be generated:

string actualStep1 = EditProperties.selected_InstallMethod();
if ((actualStep1.Trim()).Equals(InstallationMethod_Step1.Trim()))
Report.Success("For cable Id:" +Cable_ID + "Install Method Step1 matches");
else
Report.Failure("For cable Id:" +Cable_ID + ", Actual:"+EditProperties.selected_InstallMethodStep1() + " where as Expected:" + InstallationMethod_Step1);

public static string selected_InstallMethod() {
string step1 = CablesHelper.selected_installMethodStep1();
Ranorex.Plugin.WpfConfiguration.WpfApplicationTrees = Ranorex.Plugin.WpfTreeSelection.UiaPreferred;
Configuration.Current.SaveToUserSettings();
return step1;
}

public static string selected_installMethodStep1() {
Ranorex.Plugin.WpfConfiguration.WpfApplicationTrees = Ranorex.Plugin.WpfTreeSelection.WpfImprovedOnly;
Configuration.Current.SaveToUserSettings();
string step1 = Utilities.getAttributeCaption(ProDesign.CableSettingsDialog.List_InstallationMethodsStep1Info);
return step1;
}

public static string getAttributeCaption(RepoItemInfo element) {
string path = element.AbsolutePath.ToString();
try{
return Ranorex.Core.Element.FromPath(path).GetAttributeValueText("Caption");
}
catch(Exception e) {
Report.Info(e.StackTrace.ToString());
Report.Info(e.InnerException.ToString());
return Ranorex.Core.Element.FromPath(path).GetAttributeValueText("Caption");
}
}

I get the below error:

Object reference not set to an instance of an object.
Show/Hide Stacktrace
at ProdesignAutomatedTesting.ProDesign_Files.UI_Elements_Engine.Utilities.getAttributeCaption(RepoItemInfo element) in c:\git\designsuiteautomatedtesting\ProdesignAutomatedTesting\ProdesignAutomatedTesting\ProDesign Files\UI Elements Engine\Utilities.cs:line 241at ProdesignAutomatedTesting.ProDesign_Files.UI_Elements_Engine.CablesHelper.selected_installMethodStep1() in c:\git\designsuiteautomatedtesting\ProdesignAutomatedTesting\ProdesignAutomatedTesting\ProDesign Files\UI Elements Engine\CablesHelper.cs:line 476at ProdesignAutomatedTesting.ProDesign_Files.ProDesign_Dialog_Events.EditProperties.selected_InstallMethodStep1() in c:\git\designsuiteautomatedtesting\ProdesignAutomatedTesting\ProdesignAutomatedTesting\ProDesign Files\ProDesign Dialog Events\EditProperties.cs:line 587at ProdesignAutomatedTesting.ProDesign_Files.ProDesign_General_Functions.CoreCables.Ranorex.Core.Testing.ITestModule.Run() in c:\git\designsuiteautomatedtesting\ProdesignAutomatedTesting\ProdesignAutomatedTesting\ProDesign Files\ProDesign General Functions\CoreCables.cs:line 267at Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext, Int32 iteration, Int32 iterationCount, Boolean skipIteration)

Am I doing something wrong?

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: unable to find selected text in a drop down

Post by rsudhak » Tue Apr 30, 2019 3:30 pm

Sorry to come back to this, currently I have a csv data source, on the first iteration it runs fine, switching to WpfimprovedOnly and then back to uiPreffered, but in the second iteration it simple fails says No element found for path (Path of WPFimprovedOnly) , any idea as it why this is happening?

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

Re: unable to find selected text in a drop down

Post by odklizec » Tue Apr 30, 2019 3:38 pm

Hi,

Are you sure, that Ranorex is set to wpfimprovedonly before the next iteration? Please create the app snapshot (from code), right before the failing step. Then examine if the xpath you are using in repo is still valid and eventually change it.
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

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: unable to find selected text in a drop down

Post by rsudhak » Tue Apr 30, 2019 3:49 pm

Before moving to the next iteration , i do set it back to uipreferred because by default its uipreferred, only for certain drop downs I switch back to wpfimprovedonly, how can I create a app spanshot?

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

Re: unable to find selected text in a drop down

Post by odklizec » Tue Apr 30, 2019 3:57 pm

Hi,

And this is most probably source of your problem! If the xpath in repo is wpfimprovedonly-based, you must again switch to wpfimprovedonly, in case you want to access such element. You can take snapshot with Report.Snapshot method.
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

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: unable to find selected text in a drop down

Post by rsudhak » Wed May 01, 2019 9:15 am

Yes, xpath is wpfimprovedonly , just before accessing this element I switch to wpfimproved , once the action of the element is done I switch back to uipreferred , and this runs fine for the first iteration, but the second one fails, is there a way to check which is the current plugin?

added Report.snapshot, cant see any link on the report, any links for reference please

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: unable to find selected text in a drop down

Post by rsudhak » Wed May 01, 2019 1:01 pm

Any update on this would be of great help, I see random failures finding the WPFImprovedOnly element, before accessing the the element , I do check whether its wpfImprovedonly, its identifies as wpfimprovedonly, but fails to find the element, just sample report attached for reference
Attachments
pluginIssue_ranorexReport.zip
Latest report for info
(1.2 MiB) Downloaded 9 times

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

Re: unable to find selected text in a drop down

Post by odklizec » Thu May 02, 2019 7:08 am

Hi,

There is not much to add I'm afraid. As long as you don't provide another snapshot, created just before accessing the problematic element, there is unfortunately nothing anyone here can do or suggest. Ideally, take the snapshot for each iteration.

Looking at both snapshots you already provided, the xpath in your report does not work in neither of them, so I'm curious, with what settings you recorded such xpath? :)

This is the xpath from your report:
'/form[@title='Cable Settings' or @title~'^Final\ Circuit\ ' or @title~'^Lighting\ Column\ ' and @processname='ProDesign']/?/?/container[@automationid='ComponentSettingsView']/?/?/container[@automationid='PageContentControl']//combobox[@automationid='InstallationMethodGroupComboBox']/button[@automationid='PART_DropDownButton']/text

And this xpath actually works in wpf.rxsnp:
/form[@title='Cable Settings' or @title~'^Final\ Circuit\ ' or @title~'^Lighting\ Column\ ' and @processname='ProDesign']//container[@automationid='ComponentSettingsView']//element[@automationid='PageContentControl']//list[@automationid='InstallationMethodGroupComboBox']//checkbox[@automationid='PART_DropDownButton']//text
Do you see the differences?

And in the other snapshot (wew.rxsnp - the one taken in UIA only mode), it looks even more differently, plus there are no combo box sublements recognized, so it can be found only up to the combobox element...
/form[@title='Cable Settings' or @title~'^Final\ Circuit\ ' or @title~'^Lighting\ Column\ ' and @processname='ProDesign']/element[@automationid='ComponentSettingsView']//element[@automationid='CableTypeViewElement']/combobox[@automationid='InstallationMethodGroupComboBox']
WPF_UIA_cmbobox.png
WPF_UIA_cmbobox.png (90.38 KiB) Viewed 182 times
The WPF mode clearly shows more elements, but I agree some element types are recognized weirdly (e.g. list instead of combobox).

All in all, the xpath from report is most probably not good for neither wpf settings you've used, while generating both snapshots.

BTW, you should definitely update Ranorex to most recent 9.0.1, because 8.3.1 is already outdated and there were many bug fixes and improvements done since then, which may include also some WPF-related things! Debugging such kind of issue with an obsolete version, is just the waste of time and energy ;)
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

rsudhak
Posts: 72
Joined: Fri Jan 04, 2019 1:38 pm

Re: unable to find selected text in a drop down

Post by rsudhak » Fri May 03, 2019 12:51 pm

Thanks for the reply, I have upgraded to the latest version, but the issue persists

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

Re: unable to find selected text in a drop down

Post by odklizec » Fri May 03, 2019 1:05 pm

Hi,

Well, in this case, there is no other option than to create another another set of snapshots, ideally taken in first iteration, where the xpath you are using works and second iteration, where, as you mentioned, it stopped working. And please tell us, what exactly do you want to achieve? And explain why do you mix UIAonly and WPFPreferred modes? Thanks.
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