Page 1 of 1

Visual Studio Integration Example

Posted: Mon Sep 24, 2018 9:23 pm
by RobertComstock
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.

Re: Visual Studio Integration Example

Posted: Tue Sep 25, 2018 11:11 am
by dpFourOFour
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
Hope that helps,
DP

Re: Visual Studio Integration Example

Posted: Tue Sep 25, 2018 3:37 pm
by RobertComstock
Thanks, DP. I will give it a try.

Re: Visual Studio Integration Example

Posted: Tue Sep 25, 2018 9:30 pm
by RobertComstock
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;
}

Re: Visual Studio Integration Example

Posted: Wed Sep 26, 2018 8:55 am
by dpFourOFour
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

Re: Visual Studio Integration Example

Posted: Wed Sep 26, 2018 1:20 pm
by RobertComstock
Yes, I am on Windows 10. When I run the recorded test it does find the elements.

Re: Visual Studio Integration Example

Posted: Wed Sep 26, 2018 7:33 pm
by RobertComstock
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?

Re: Visual Studio Integration Example

Posted: Fri Oct 05, 2018 1:19 pm
by bloodenjoy
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.