0

Can please anyone guide me how i could Press F12 and than navigate to source tab in Developer tool in Chrome.

I was able to do it till pressing F12, but i am not able to Navigate to source, since the focus is not moved to developer tool so that with Tab click we could navigate to source tab.

Code for Pressing F12-

robot = new Robot();
            robot.keyPress(KeyEvent.VK_F12);
            robot.keyRelease(KeyEvent.VK_F12);

Could anyone please suggest me some solution or work around.

4
  • 5
    What is your final goal?
    – Alexey R.
    Apr 11, 2018 at 12:39
  • 1
    No how; Selenium is an API for communicating with browsers through the webdriver protocol, and that's it. The DevTools is a desktop's app component, in no way exposed for interaction through webdriver. And what you've done with the Robot framework is to simulate physical interaction with the desktop app; your only option is to continue in that direction, but not to call it - or try to get it done with - Selenium. Apr 12, 2018 at 8:25
  • actually my goal is to, open an application URL that i want to automate, and open developer tool, navigate to source tab and set broke point and reload the url. This is the complete flow that i want to automate. Could you suggest how i can achieve?
    – suman
    Apr 12, 2018 at 8:53
  • See stackoverflow.com/a/48636877/631619 Jul 21, 2018 at 11:38

1 Answer 1

1

If your objective is to get the html source code, you can do that using

driver.getPageSource()

You generally can't access stuff like that, the way you are trying to, because selenium is sandboxed your browser. You can access chrome dev tools using the dev tools API or a testing framework like puppeteer which has access to dev tools API.

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.