etaoin icon indicating copy to clipboard operation
etaoin copied to clipboard

How to get status code.

Open alehatsman opened this issue 7 years ago • 7 comments

How to get status code after i executed go function?

alehatsman avatar Jan 22 '18 15:01 alehatsman

@Atsman briefly, it requires some tweaks described there: https://stackoverflow.com/questions/6509628/how-to-get-http-response-code-using-selenium-webdriver-with-java

Currently, you may set your own LogType preferences passing some particular capabilities value. The issue you've created is to process log-type key.

igrishaev avatar Jan 22 '18 15:01 igrishaev

I can confirm that I've been able to retrieve http response status from chrome perf logs using the solution in the stackoverflow link posted, but it took ages of poking around, passing the right flags into chromedriver, then retrieving and parsing the logs themselves.

marceloramires avatar Dec 03 '18 07:12 marceloramires

It's a pleasure using this library!

https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-responseReceivedExtraInfo

Since now we got this api (though marked as experimental), maybe we can add the related data to the etaoin.dev/get-requests result? Maybe enable this behavior via some experimental option?

lotuc avatar Nov 21 '22 12:11 lotuc

Thanks for the comment @lotuc!

I'll re-open this issue so we don't forget about it.

lread avatar Nov 21 '22 15:11 lread

So, @lotuc this isn't part of the w3c spec, and is experimental, so we probably won't include it in the etaoin API.

But... if you can provide me with a working code example, it might be nice to include it in the user guide of something browser-custom folks can do.

lread avatar Dec 02 '22 22:12 lread

OK, here is my dirty patch gist. I just copy the whole etaoin.dev. The changed part is Line 70 - Line 75 & Line 90 - Line 94.

Sample:

(def d (etaoin.api/chrome {:dev {}}))
(etaoin.api/go d "https://www.bing.com")
(def requests (etaoin.dev-patch/get-requests d)) ;; replace the etaoin.dev
(-> (first requests) :response :status-code)     ;; the :status-code is only added compare to original etaoin.dev/get-requests
;; we get the status code here

lotuc avatar Dec 04 '22 13:12 lotuc

Thanks @lotuc!

I kinda sorta forgot we have a dedicated namespace to support chrome dev tools.

Once this moves out of the experimental state your gist will be a nice headstart on incorporating this.

lread avatar Dec 04 '22 18:12 lread