Using Ranorex with C# and NUnit as a library

Class library usage, coding and language questions.
ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Using Ranorex with C# and NUnit as a library

Post by ngrishakin » Thu Sep 15, 2016 10:59 pm

I would really appreciate any help!!!!

We have application written in dynamic CRM and it uses Silverlight components.
So Selenium was not an option. Our regression is written in C# using NUnit framework. So I want to use Ranorex the same way as a library for my C# project. (No object repository)
Unfortunately not much documentation is available for this. I used to use it this way for WPF applications but now its Web.

I need to instantiate my Browser. In API documentation I found WebDocument class and tried to use it this way:
WebDocument Browser = new WebDocument();
Browser.Navigate("https://host.com/catalysttest/");
Browser.WaitForDocumentLoaded();

And it gives me compilation error: “'WebDocument.WebDocument()' is inaccessible due to its protection level”. This is pretty much like a Selenium does it.
I need to use WaitForDocumentLoaded function because CRM just in generally slow. I could not find a way how do I choose the browser other than default one.

I found a different way how to start my browser and pass in URL:
Host.Local.OpenBrowser("https://host.com/catalysttest/", "chrome.exe");
But now how do I use WaitForDocumentLoaded(). My tests are failing due to timeout.
Please let me know what would be the best approach to solve my problem.

Thanks a lot for all help!!!

User avatar
RobinHood42
Posts: 238
Joined: Fri Jan 09, 2015 3:24 pm

Re: Using Ranorex with C# and NUnit as a library

Post by RobinHood42 » Fri Sep 16, 2016 12:37 pm

Hi ngrishakin,

You basically just need a webdocument object: :D
WebDocument webDoc = "https://host.com/catalysttest/";
        	webDoc.WaitForDocumentLoaded();
Hope this helps,
Robin

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Using Ranorex with C# and NUnit as a library

Post by ngrishakin » Fri Sep 16, 2016 4:21 pm

I found another solution that seem to work:

System.Diagnostics.Process.Start("chrome.exe", "https://cata-test.t.host.com/cata-test/");
webDocument = "/dom[@domain='cata-test.t.host.com']";
webDocument.WaitForDocumentLoaded();

Does it look appropriate?
Thanks for all help!!!

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Using Ranorex with C# and NUnit as a library

Post by ngrishakin » Fri Sep 16, 2016 5:49 pm

RobinHood42 wrote:Hi ngrishakin,

You basically just need a webdocument object: :D
WebDocument webDoc = "https://host.com/catalysttest/";
        	webDoc.WaitForDocumentLoaded();
Hope this helps,
Robin
Robin, WebDocument webDoc = " .... " it expects RxPath not a URL

Ranorex.RxPathException : Parsing RxPath 'https://cat-test.t.host.com/cata/' failed.

Thanks,
Nik

User avatar
RobinHood42
Posts: 238
Joined: Fri Jan 09, 2015 3:24 pm

Re: Using Ranorex with C# and NUnit as a library

Post by RobinHood42 » Mon Sep 19, 2016 12:40 pm

Hi,

Of course, somehow missed to past the correct definition.
webDocument = "/dom[@domain='cata-test.t.host.com']";
should be correct.

Cheers,
Robin

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Using Ranorex with C# and NUnit as a library

Post by ngrishakin » Mon Sep 19, 2016 3:57 pm

RobinHood42 wrote:Hi,

Of course, somehow missed to past the correct definition.
webDocument = "/dom[@domain='cata-test.t.host.com']";
should be correct.

Cheers,
Robin
Thank you RobinHood42! It did work.