Checking the contents of a pdf that is opened in new browser tab

Ask general questions here.
AviatorFly
Posts: 15
Joined: Fri Sep 06, 2019 2:21 pm

Checking the contents of a pdf that is opened in new browser tab

Post by AviatorFly » Tue Jan 05, 2021 10:20 pm

Hi all,

I have an application what when I click on a generate button, it creates a pdf report on a new browser tab in Firefox.
The new tab has an url like blob:https://somesite.com/c5ef7f11-904d-4cba ... 50ce73bff0 where c5ef7f11-904d-4cba-aca1-2650ce73bff0 is a random guid.

Can anyone offer some tips on how to do this?

I suppose first step is getting Ranorex to move to the new open tab somehow.

Thanks

User avatar
Stub
Posts: 443
Joined: Fri Jul 15, 2016 1:35 pm

Re: Checking the contents of a pdf that is opened in new browser tab

Post by Stub » Wed Jan 06, 2021 8:53 am

Could you use a regular expression in your RxPath which recognises the format of the GUID but not the actual value of it?

IngaQ
Posts: 1
Joined: Tue Jan 05, 2021 10:58 am

Re: Checking the contents of a pdf that is opened in new browser tab

Post by IngaQ » Wed Jan 06, 2021 12:14 pm

To expand on Stub's idea:

You want a repository element (usually a rooted folder) that points to the new browser tab. The base element for a web page is a "/dom" element. The identifying attribute can for example be the domain ("/dom[@domain='www.ranorex.com']") or the page URL ("/dom[@pageurl>'https://www.ranorex.com/forum']) or a combination of multiple attributes.

For your specific case you could use a RanoreXPath with a pageUrl matching a regular expression.
If your GUID always follows the pattern from your example, you could use this one:

Code: Select all

^https://somesite\.com/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}
and use it like this in you RanoreXPath:

Code: Select all

/dom[@pageurl~'^https://somesite.com/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}'
Alternatively you could check if the new tab has a distinct caption, e. g. if the new tab has a title starting with "PDF Report", you could use something like "/dom[@domain='somesite.com' and @caption>'PDF Report']".

If your question is instead about clicking on the tab in the browser toolbar (i. e. switch from your old tab to the new tab with the report), you don't need the DOM elements but elements from the browser, specifically the "tabpage" from the "tabpagelist" you want to navigate to. You can identify the correct tabpage by title (should be the same as caption for the dom) or maybe by index if you can guarantee its position.

In my experience the easiest way to get stuff like this right, is to make a recording with the desired workflow - e. g. trigger 'Create report', navigate to the new tab with the report, click some element there - and then check the repository elements created by Ranorex. If the GUID (or something else that changes constantly like a date) shows up somewhere, you can then edit those elements specifically to use a different attribute or to use a regular expression etc.

AviatorFly
Posts: 15
Joined: Fri Sep 06, 2019 2:21 pm

Re: Checking the contents of a pdf that is opened in new browser tab

Post by AviatorFly » Thu Jan 07, 2021 9:09 pm

With the spy tool, it looks like Ranorex will only identity the entire pdf shown in the new tab of firefox. I was hoping I would see the red frame around individual items in the pdf file. Is there a way to do that?

Also I was not able to figure out how to get Ranorex to get to the tab with the pdf file. Anyone has examples on how to do that?

Thanks