How to get button Response/Request URLs in QTP? - request

How do I get Response/Request URLs (which are shown in F12 Developer tools - Network Tab) using QTP 11? Based on these URLs, I need to perform certain action in my application. Is there any alternate solution to get those URLs?
Scenario: Open IE browser and navigate to a URL, Press F12, Go to 'Network' tab. Click on 'Start Capturing' button. Now click on any button or link on the page, you will get a set of URLs in the Developer Tool (F12).

Firstly, do you need all of the URL requests generated from a button and/or link click? Remember that what you get from the "Network" tab in the developer tools also include URL's for fetching e.g. Javascript and CSS in addition to, for instance a GET request to an external API.
I'll try an provide you with an alternative approach. If what you are really requiring is the URL associated with each interactive element, then you should be able to get that by using the GetROProperty method like so:
strURL = Browser("YourBrowser").Page("MainPage").WebButton("aButton").GetROProperty("href")
A more generic script for fetching e.g. all the "href" properties for all the links on a page may be found in the following post: (HP QuickTest) How do I get HTTP status using QuickTest?.
Hope this helps.
UPDATE: With regards to your question regarding fetching of the URL's from the IE developer tools; As far as I know there is no way to fetch them from this view by using QTP.

Related

Gatling - Click or follow a link on browser

Is there any way that I can make Gatling to follow a link after page load, On click this link redirects to a new page which gives login page ?
Gatling doesn't automate web browsers.
You have to parse the network traffic in order to find where the link comes from.
Such parsing really depends on how your application works.
If HTML content is generated server side, there's an example based on css selectors in the tutorial.
If it's generated in Javascript, you probably have to parse some JSON payload, eg with a JMESPath check.

SSRS 2016 Toolbar Back Button

I am trying to figure out in SSRS 2016 why the back button goes missing and how to get it back. I am adding the report into an iFrame of another application - I do not have access to that application's code, I just get to put in a URL.
If I put in a URL like this:
http://sqlservername/Reports/report/Cityworks%20Reports/Parks/ParksReport?rs:embed=true
I get the back button, however the report does not scroll horizontally very well.
If I put the URL in like this, the report scrolls horizontally very well however the back button goes missing:
http://sqlservername/ReportServer/Pages/ReportViewer.aspx?Cityworks+Reports%2fParks%2fParksReport&rs:Command=Render
I have tried to see what other options are available and am stumped at the moment. Has anyone come across this and know a solution?
Try add to the wanted URL the follow parameter
&rc:showbackbutton=true
One URL is for the Report manager, and the other for Browsing. The URL with YourServer\ReportServer is the browser landing page; there's therefore no "need" for the back button as it's purely a browsing page. If you go to http://YourServerName/ReportServer you'll see you have a page that very much looks like one you get with IIS with folder browsing enabled. Normally you only land on these pages when you receive a report by email, which contains a link to the report; or you are an end user.
The other URL YourServer\Reports is the report manager. It makes more sense here to have a back button, as you are navigating a management portal. As a result you could have come from other pages other than the folder browser page.

Security with "web_accessible_resources"

MDN docs state:
To enable a web page to contain an <img> element whose src attribute points to this image,
you could specify "web_accessible_resources" like this:
"web_accessible_resources": ["images/my-image.png"]
The file will then be available using a URL like:
moz-extension://<extension-UUID>/images/my-image.png"
<extension-UUID> is not your extension's ID.
It is randomly generated for every browser instance.
This prevents websites from fingerprinting a browser by examining
the extensions it has installed.
So, I would think that these resources cannot be read by any web page outside the extension, since they would need to know the random UUID.
However, the same MDN docs also state:
Note that if you make a page web-accessible, then any website may then link or redirect
to that page. The page should then treat any input (POST data, for examples)
as if it came from an untrusted source, just as a normal web page should.
I don't understand how "any website may then link or redirect to that page". Wouldn't it need to know the random UUID? How else could a webpage access this resource?
The point of Web Accessible Resources is to be able to include them in a web context.
While you can communicate the random UUID to the webpage so that it can use the file, it doesn't have to be included by the website code itself. Here's a hypothetical scenario:
You're writing an extension that adds a button to evil.com site's UI. That button is supposed to have an image on it.
You bundle the image with your extension, but to add it as src or CSS property to the webpage you need to be able to reference it from a web context.
So, you make it web-accessible, and then inject your UI element with a content script.
Perfectly plausible scenario.
Note that a random third-party site villains-united.com can't just scrape the URL to know if your extension is installed, since the URL is per-browser unique. This is the intent behind WebExtensions's UUID over Chrome's extension-id model.
However, let's continue our hypothetical scenario, from a security perspective.
The operators of evil.com are unhappy with your extra UI. They add a script to their code that looks for added buttons.
That script can see the DOM properties of the button, including the address of the image. Now evil.com's code can see your UUID.
Being the good guy, your extension's source code is available somewhere, including the page that launches nuclear missiles if called (why you would have that and why it would be web-accessible is another matter, perhaps to provide the functionality to good-guys-last-resort.org).
evil.com's script now can reconstruct the URL of this trigger page and XHR it, plunging the planet into nuclear apocalypse. Oops. You probably should've checked the origin of that request.
Basically, if a web-accessible resource is used in a page, the UUID likely leaks to that page's context via DOM. That may not be a page you control.

How do I get my button to redirect to a web page within the app?

So far, I have it so that when a user presses a button, a browser opens and redirects the user to my desired url. However, I want this to happen within the app instead of a web tab. How can I do this?
Use the BrowserComponent, just add it to the center of a border layout form and set the URL for that component. Check out the list of main components in Codename One within the developer guide.
Define a xml layout containing a widget called webview. Then in your activity you implement a listener to your button which invokes that xml with the desired page to load inside your webview. Google to find some code and return here with your code problems, if you find some. If this will be the case, open new questions provinding detailed info about your matters then we can help more. Best.
EDIT: Excuse me, just now, re-reading your question I think I really understand it, and the solution is very simple, just a line of code (to instruct your app to open a webpage inside your webview, and not the regular browser, outside your app). Try this:
wv = (WebView) findViewById(R.id.myWebView);
wv.setWebViewClient(new WebViewClient()); // needed to open url inside our webview, otherwise it will open at the default browser
wv.loadUrl(url);

mailto: links gobbled in a route

I'm using the jquery linkify plugin on a relatively simple Backbone view. Links to web pages outside this app work properly and using browser view source, I see the mailto links are properly generated. But clicking a mailto link appends /mailto:q#example.com to the current URL (e.g., http://example-acme.staging.myservername.com/mailto:q#example.com).
If I copy the generated HTML using Inspector and paste it into the source of arbitrary pages (not in this app), the mailto links function as expected, opening a new message window from my mail client. Problem is the same in Chrome and Firefox.
Have you seen and fixed this issue?
Just for closure: I added an event handler in the handler use window.location.assign(mailto) and that gets the job done. Not necessarily 'correct' but practical. #Brad, thanks for chiming in!

Resources