cancel
Showing results for 
Search instead for 
Did you mean: 

How to grab the message in browser console (Chrome Developer Tools)

Highlighted
Contributor

How to grab the message in browser console (Chrome Developer Tools)

Hi,

 

I am wondering how can we write a Script in Javascript to grab the message in Browser Console.

So e.g. when trying to login to a webpage and login fails, the console will return some error message like this 

 

console.jpg

 

I would like to grab that line and put it in my txt log file. 

Is there any method to do that? 

 

Thank You. 

5 REPLIES 5
Community Hero

Re: How to grab the message in browser console (Chrome Developer Tools)

Hi,

 

You are speaking about API testing. You need another tool to work with rest-services (like a SoapUI) or create your own script using one of the javascript rest-clients (like restful.js or something else). 

Community Hero

Re: How to grab the message in browser console (Chrome Developer Tools)

You could possibly do something with the Chrome API's?

 

It provides a bunch of them. https://developer.chrome.com/extensions/api_index

 

eg - https://developer.chrome.com/extensions/devtools_network

 

Looks like it should get you into the area of Network messages such as those in your example.

 

I've used Selenium & Python to extract Performance metrics from browser pages before. But I've never tried using the Chrome API from TestComplete. I suspect it could be done, but having never actually used it, I couldn't say for sure.

Contributor

Re: How to grab the message in browser console (Chrome Developer Tools)

Thanks all.  Smiley Happy

 

Just wondering if we can use TestComplete to automate restful API testing ? 

Community Hero

Re: How to grab the message in browser console (Chrome Developer Tools)

You can.

 

You can integrate with SoapUI.

 

Or you can write something yourself to do it directly.

 

Direct approach discussed here: https://community.smartbear.com/t5/TestComplete-Functional-Web/TestComplete-support-for-automating-R...

 

And another discussion about this, which seemed to end up with SoapUI integration, here: https://community.smartbear.com/t5/TestComplete-General-Discussions/Automate-REST-api-using-TC/td-p/...

 

Personally, I have a whole bunch of script extensions hooked into the TFS API to allow to update TFS directly from scripts. I used the XMLHTTP object and wrote it myself. As long as you have access to decent docs for the API you want to use, and some way of parsing the response (I used a JSON Parser), it's not terribly difficult.

Frequent Contributor

Re: How to grab the message in browser console (Chrome Developer Tools)

Try using Postman.

https://www.getpostman.com/