Visual Studio Integration Example

Ask general questions here.
RobertComstock
Posts: 5
Joined: Fri Jul 13, 2018 2:25 pm

Visual Studio Integration Example

Post by RobertComstock » Mon Sep 24, 2018 9:23 pm

The VS Integration Example references Ranorex 8. https://www.ranorex.com/help/latest/int ... tegration/

Does the example still work for 8.2? I am using C# and I have followed the steps and the calculator opens but it never clicks the buttons.
I have double checked the .NET Framework and dll's being referenced.

dpFourOFour
Certified Professional
Certified Professional
Posts: 38
Joined: Mon Dec 12, 2016 9:24 am

Re: Visual Studio Integration Example

Post by dpFourOFour » Tue Sep 25, 2018 11:11 am

Hi RobertComstock,

You are right, the sample as it is listed on the page is not working properly. Perhaps something went wrong with parsing the code in the html page.
Anyway, I have created a sample in VS as a reference
RanorexVSIntegration.zip
(190.48 KiB) Downloaded 8 times
Hope that helps,
DP
Please always include the following information to your posts
  • Ranorex Version
  • OS Version

RobertComstock
Posts: 5
Joined: Fri Jul 13, 2018 2:25 pm

Re: Visual Studio Integration Example

Post by RobertComstock » Tue Sep 25, 2018 3:37 pm

Thanks, DP. I will give it a try.

RobertComstock
Posts: 5
Joined: Fri Jul 13, 2018 2:25 pm

Re: Visual Studio Integration Example

Post by RobertComstock » Tue Sep 25, 2018 9:30 pm

DP,

Tried the solution you sent and it is still not working. Gives an error on WindowsApp calculator = Host.Local.FindSingle<WindowsApp>("winapp[@processname='" + processName + "']"); saying that it can't find that process.

I then built a quick Ranorex Studio test and followed what it was doing. Based on my findings I modified the run method and now I get this exception "No element found for path '/winapp[@packagename='Microsoft.WindowsCalculator']/?/?/button[@automationid='num8Button']'."

private static int run()
{
int error = 0;
//Start calculator and wait for UI to be loaded
try
{
Host.Local.RunApplication("C:\\Windows\\System32\\calc.exe","", "C:\\Windows\\System32", false);
Thread.Sleep(2000);

Button button =
Host.Local.FindSingle<Button>(
"/winapp[@packagename='Microsoft.WindowsCalculator']/?/?/button[@automationid='num8Button']");
button.Click();

}
catch (RanorexException e)
{
Console.WriteLine(e.ToString());
error = -1;
}
return error;
}

dpFourOFour
Certified Professional
Certified Professional
Posts: 38
Joined: Mon Dec 12, 2016 9:24 am

Re: Visual Studio Integration Example

Post by dpFourOFour » Wed Sep 26, 2018 8:55 am

Well, that's odd...

I have built and tested this project on a Win10 machine. Which OS are you running?
What happens when you run the recorded test on your machine? Is it finding the elements or do you also get an error?

Best,
DP
Please always include the following information to your posts
  • Ranorex Version
  • OS Version

RobertComstock
Posts: 5
Joined: Fri Jul 13, 2018 2:25 pm

Re: Visual Studio Integration Example

Post by RobertComstock » Wed Sep 26, 2018 1:20 pm

Yes, I am on Windows 10. When I run the recorded test it does find the elements.

RobertComstock
Posts: 5
Joined: Fri Jul 13, 2018 2:25 pm

Re: Visual Studio Integration Example

Post by RobertComstock » Wed Sep 26, 2018 7:33 pm

So an interesting development. I have had Ranorex 6.1.1 installed on my machine for some time and Ranorex Spy was working. After upgrading to 8.2 Ranorex Spy would no longer capture elements (tracking or Ctrl + Left Windows). I decided to restore defaults in the settings and then Ranorex Spy started working. I also ran the project you sent me and that started working as well. Is there something in 6.1.1 settings that do not transfer over to 8.2 correctly and would cause this type of behavior?

bloodenjoy
Posts: 1
Joined: Fri Oct 05, 2018 1:17 pm

Re: Visual Studio Integration Example

Post by bloodenjoy » Fri Oct 05, 2018 1:19 pm

RobertComstock wrote:
Mon Sep 24, 2018 9:23 pm
The VS Integration Example references Ranorex 8. https://www.ranorex.com/help/latest/int ... tegration/

Does the example still work for 8.2? I am using C# and I have followed the steps and the calculator opens but it never clicks the buttons.
I have double checked the .NET Framework and dll's being referenced.
Thanks for the link.