OWASP ZAP - Extract URL after browser is launched using Selenium Python - selenium

I'm launching a website using Selenium Python! On loading the Chrome browser, ZAP proxy is getting attached to it and capturing URL. I have 2 things to that needs to be clarified here:
How to capture URL/requests when user parses through different links? ZAP is capturing it in GUI. Is there any API that gives me the full URL List?
How to use Selenium (Python) to capture URL? It captures only current URL and when I go to other link, it doesn't print the new page URL.

The short answer is yes - Zap has an amazing API, and you can find the documentation here. For a longer explanation, I will need some details as I don't fully understand your question.
1 - are you looking to get all the request that were proxy through Zap? You can use the following: /JSON/core/view/sites/?zapapiformat=JSON&formMethod=GET.
2 - Not sure - seems like a selenium question, correct?

Related

Is it possible in Jmeter to get overall response time with including rendering of page in browser

I have a requirement from client that The overall response time (end to end time including rendering of page in browser) should be 3 secs for all the requests.Its an API with frontend.
As i know jmeter handles server side response time, even if i add embedded resource it just downloads java script ,images etc but doesn't act as a browser. Is there any way where i can get The overall response time (end to end time including rendering of page in browser) .
Could some please help me out with this.Thanks..
You can use JMeter Plugin WebDriver Sampler with associated -Driver Config Elements to achieve overall response time.
Following Links could be useful
Web Driver Tutorial
Web Driver Sampler
You cannot, as per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So the only way of getting client-side metrics like rendering time you need to use a real browser, for example kick off one using WebDriver Sampler. Metrics can be obtained from Navigation Timing API via WebDriver.executeScript() function

Google AppEngine API Explorer redirects and lists no URLs

I'm having an unending issue trying to use the AppEngine API explorer with the stupidly simple helloworld example.
When trying to navigate to the url to explore the API my Chrome browser redirects to HTTPS from the default HTTP and no API's are listed. I have gone through every possible fix I can find (Like this, and all of these) and none are working reliably.
What's the most infuriating is I have gotten the API listed TWICE but now no longer displays with any of the methods below.
The setup I had when it worked the first time:
Chrome launched with "C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe" --unsafely-treat-insecure-origin-as-secure=http://localhost:8080 (As per the tutorial)
The url being: (http://)apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api&root=http://localhost:8080/_ah/api#p/
The second time it worked was using also using the above URL but lasted only a second before being redirected to HTTPS and not listing anything.
Some specifics:
Windows 10 OS.
Every time the page loads I get the "The API you are exploring is hosted over HTTP, which can cause problems. Learn how to use Explorer with a local HTTP API." message, even the times the API displayed correctly.
Every time I now load any of the API Explorer URLs I get redirected to HTTPS, and nothing is listed. Also the URL is escaped (%3A instead of ':'). Not sure if it's important but the first time it worked the URL was HTTP and NOT escaped.
I have tried the shield in the search bar and enabling Load unsafe scripts ( from here).
Tried launching Chrome as usual and with the flags --unsafely-treat-insecure-origin-as-secure=http://localhost:8080 and/or --allow-running-insecure-content (from this answer).
Tried http://localhost:8080/_ah/api/explorer
Tried http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/
http://localhost:8080/_ah/admin works correctly and shows the Admin console every time.
Since the API's being listed once I haven't touched the project code, but restarted the server, Chrome, and tried different URLs on more occasions than I care to count.
I also tried accessing the API URL directly as explained in this answer but cannot find the correct URL to access the helloworld /sayHi endpoint. Maybe someone can help me work out what I need to prefix it with as all of the variations I try give me a 404.
Any help would be a very very appreciated.

Capture JSON response through Selenium

I'm testing a webpage using Selenium (either IDE or webdriver). The webpage has a "search" function, basically just a GET call with params. The javascript also output to console the JSON returned from the search call, i.e. something like console.log(data). And I'm able to inspect the response data in Firefox console.
My question is: is there anyway I can capture this data from Firefox console in Selenium (so that I can further inspect and doing asserts)? Writing a direct GET request (eg, from Python) does not work since the search url is protected through a login page.
Thanks.
AFAIK Selenium doesnt provide any in built API/method to play with console.
You can redirect console output file and read from file.
Link: How to redirect Firefox console output to file.
It was possible at one point using Firebug. Not sure if it still works.

Set request header and User Agent in Geb

When using Geb, is it possible to set custom request headers and user agent when using the Browser API (and not the Direct Download API)?
While this is possible with the FirefoxDriver (see here), I am looking for a way of doing this with the WebKitDriver.
A possible solution is via a proxy.
BrowserMob has a standalone mode with REST api, or embedded in your test programmatically: https://github.com/webmetrics/browsermob-proxy . Useful when there are a lot of custom headers you want to test.
If you already have Apache, you can create another VirtualHost on a different port having that particular request header, and point your browser to that port before the test. Given that your header doesn't change between tests.
This might not be the direct solution to your question: modify request headers directly in Browser API, but it achieves the end result.

how does pastie or any other site remember browser info

I am trying to make a simple experimental app. I'd like for it to behave like pastie.
On pasite you can paste code and it will remember your browser.
So if you paste the url (that pastie provides) in the same browser then you'll be able to edit the page. Everyone else will not see the edit link. Basically there is no registration or logging in.
How is this done?
Using HTTP cookies.