How to capture all requests made by page in webdriver? Is there any alternative to Browsermob?

后端 未结 3 1013
长情又很酷
长情又很酷 2020-12-04 16:11

I am using Selenium2/WebDriver to test my web applications. All the tests are written in Java and run with Maven.

While opening a page with webdriver I\'d like to ca

3条回答
  •  心在旅途
    2020-12-04 16:32

    I've been working recently on this kind of proxy. Project is pretty fresh, I'm still working on documentation but it may be worth checking. Sources and examples are here

    1. Add dependency to your project
        
           com.moxproxy
           moxproxy.core
           1.0.2
        
    
    1. Start proxy
        MoxProxy proxy = LocalMoxProxy.builder()
                    .withPort(89)
                    .build();
        proxy.startServer();
    
    1. Setup selenium webdriver to use proxy on localhost with port 89 and run test

    2. Collect traffic

        List requestTraffic = proxy.getAllRequestTraffic();
        List responseTraffic = proxy.getAllResponseTraffic();
    

    Beside collecting traffic proxy provides posibility to modify requests and responses - details on github

提交回复
热议问题