5

How can we automate developer tools particularly the networks section using Selenium?

I need the preview section data of a service call to be logged while using automation.

  • Is it possible?
  • If so, how do I achieve this?

enter image description here enter image description here

3 Answers 3

5

Selenium 4 alpha version introduces an Interface for Chrome DevTools API. I'm unable to find anything official (still in alpha) but here are some example uses:

http://executeautomation.com/blog/selenium-4-understanding-and-working-with-chromium-dev-tools/

https://testersdigest.blogspot.com/2019/10/selenium-4-chrome-devtools-api.html

3

No, not with Selenium. Selenium only works on the website part of the browser, not the browser user interface itself.

In your case you want to retrieve the output from a HTTP call, which can be done with Selenium, although I would want to test the user behavior with Selenium. While using API testing tools like Postman for validating return values from HTTP calls.

I think you miss some foundational understanding of how websites do HTTP calls. I suggest you do some research into how websites work, how the access HTTP API's and how the return values are handled.

Automating Chrome Dev Tools:

I think you can access most of its features through the devtools protocol: https://chromedevtools.github.io/devtools-protocol/

Maybe you can ask a new question, about what you want to achieve, maybe we know alternatives that do not use the Chrome developer tools.

If you really want to interact with the developer tools automated have a look at Sikuli or maybe Winium and AutoIt.

4
  • i would like to get data from the preview section of a call under networks tab
    – Vaishnavi
    Commented Apr 14, 2020 at 9:36
  • The text in the name column on the left are http urls, you can do a driver.get to fetch them. Or use a tool like postman to execute the http calls the website normaly does postman.com Commented Apr 14, 2020 at 10:04
  • Selenium couldn't do that, but Selenium 4 alpha includes the devtools-protocol access.
    – Mate Mrše
    Commented Apr 14, 2020 at 10:25
  • If you are looking for a way to retrieve the response data of an HTTP call, as Niels recommended, the Postman is a good tool to go with. HTTP calls usually return some type of XML or JSON. With the Sandbox API from Postman, you can parse such response data and retrieve the data fields that you need (and might do some validation on it).
    – Mh_tm92
    Commented Apr 15, 2020 at 8:03
1

This need is (finally!) starting to be addressed - Devtools & Puppeteer

See Powerful Automation with the Chrome DevTools Protocol. This shows using Javascript and the Chrome DevTools Protocol today with Puppeteer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.