Azure and tokens

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
seurrep
Posts: 17
Joined: Tue Aug 07, 2018 10:19 am

Azure and tokens

Post by seurrep » Fri Oct 12, 2018 11:09 am

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?

seurrep
Posts: 17
Joined: Tue Aug 07, 2018 10:19 am

Re: Azure and tokens

Post by seurrep » Fri Oct 12, 2018 4:02 pm

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?

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

Re: Azure and tokens

Post by RobinHood42 » Mon Oct 15, 2018 12:54 pm

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

seurrep
Posts: 17
Joined: Tue Aug 07, 2018 10:19 am

Re: Azure and tokens

Post by seurrep » Mon Oct 15, 2018 1:10 pm

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?

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

Re: Azure and tokens

Post by RobinHood42 » Tue Oct 16, 2018 9:09 am

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

seurrep
Posts: 17
Joined: Tue Aug 07, 2018 10:19 am

Re: Azure and tokens

Post by seurrep » Thu Oct 18, 2018 12:10 pm

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)

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

Re: Azure and tokens

Post by RobinHood42 » Fri Oct 19, 2018 8:13 am

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