Page 1 of 1

Azure and tokens

Posted: Fri Oct 12, 2018 11:09 am
by seurrep
I'm trying to test an Azure based application. Part of that involves logging in. Getting Ranorex to do that is fairly simple and isn't an issue.

What is an issue however is what I need to do after that point: I'm logging in so I can directly test the underlying API that we've produced rather than go through the web interface. This presumably would require the access token for any such call to be accepted.

The access token is included in the source of the page after logging in but it's not clear if Ranorex can see that or if it can be used to retrieve the access token.

What would be the best solution here?

Re: Azure and tokens

Posted: Fri Oct 12, 2018 4:02 pm
by seurrep
I'm trying to get the HTML from the document after I'm logged in so I can extract the access token from one of the script tags. Unfortunately there seems to be issues with doing that.

Using the following seems to only get a truncated copy of the HTML:

Code: Select all

        	WebDocument myDom = "/dom";
        	string html = myDom.GetHtml();

It doesn't even seem to reach the end of the <head> tag, much less the rest of the document (at least where Ranorex's own watch window is concerned).

What am I doing wrong here?

Re: Azure and tokens

Posted: Mon Oct 15, 2018 12:54 pm
by RobinHood42
Hi,

Please ensure that you're using the correct WebDocument. Just tried the "GetHtml()" and it returned the complete source of the website -> www.ranorex.com
WebDocument  = "/dom[@caption~'.*Test Automation.*']";
        	var source = rx.GetHtml().ToString();
        	Console.WriteLine(source );
Cheers,
Robin

Re: Azure and tokens

Posted: Mon Oct 15, 2018 1:10 pm
by seurrep
It doesn't seem to include the same scripts. Presumably the difference is down to 'view source' showing the page when it's loaded whereas GetHtml() gets the contents of the page as it is at that point,

The primary issue for me here though is how to get the contents of a cookie that contains the access token. Does anybody have any idea how to do that?

Re: Azure and tokens

Posted: Tue Oct 16, 2018 9:09 am
by RobinHood42
Hi,

I'm afraid that there's not much Ranorex can help you with. You'll need to create your own C# code to fetch the necessary data, e.g.: https://stackoverflow.com/questions/849 ... et-website

Cheers,
Robin

Re: Azure and tokens

Posted: Thu Oct 18, 2018 12:10 pm
by seurrep
Is it possible to use Ranorex in conjunction with the EditThisCookie add on for Chrome (or any other similar add on) ?

This shows the information I need but all Ranorex currently seems to see is the window and not the controls within it. All I currently get within recordings are IDs for the window that change with each recording.

If this can be done then I can at least log in via the browser, grab what I need from the cookies then proceed normally for the rest of the testing. Failing that is there a way of getting cookies from the browser when that browser has been opened from a recording? (I'm referring of course to the open browser action available to me rather than anything done from within a code library)

Re: Azure and tokens

Posted: Fri Oct 19, 2018 8:13 am
by RobinHood42
Hi,

Yes, you could use Ranorex to read values from the "EditThisCookie" extension. Please ensure to enable the "Global Accessibility" to be able to track elements within the extension: chrome://accessibility/

RxRefs: open-chrome-browser-with-global-accessi ... t9232.html

Cheers,
Robin