Controlling Chrome Devtools with Selenium Webdriver

后端 未结 1 1538
谎友^
谎友^ 2021-01-05 14:57

I am looking to access/use Chrome\'s devtools panel with Selenium Webdriver.

Specifically, I want to use the \"WASP\" chrome plugin, which is accessed through devtoo

相关标签:
1条回答
  • 2021-01-05 15:41

    In Selenium 4 alpha, there is a way to interact with DevTools API using the java-client. What you are looking for specifically is the "Profiler" domain (https://chromedevtools.github.io/devtools-protocol/tot/Profiler)

    Recently, I contributed the "Network" and "Performance" domains for a better user facing API in selenium java - https://github.com/SeleniumHQ/selenium/pull/7212

    I believe that "Profiler" will also be implemented soon. Of course, there is a generic API for all domains in Java client that was merged a while ago, you can use it like this:

         driver.getDevTools().createSession();
    
        driver.getDevTools().send(new Command("Profiler.enable", ImmutableMap.of()));
        driver.getDevTools().send(new Command("Profiler.start", ImmutableMap.of()));
    
        //register to profiler events
        driver.getDevTools().addListener(new Event("Profiler.consoleProfileStarted", ConsoleProfileStarted.class), new Consumer<Object>() {
            @Override
            public void accept(Object o) {
                //do something
            }
        });
    

    Until the Profiler domain will added to Selenium java client, you will have to supply your Mapper.

    0 讨论(0)
提交回复
热议问题