0

で使っBrowserMob Proxy’sてみますWebDriver。次のコードを使用します。

public static void main(String[] args) throws Exception {

        String strFilePath = "";

        // start the proxy
        ProxyServer server = new ProxyServer(4455);
        server.start();
        //captures the moouse movements and navigations
        server.setCaptureHeaders(true);
        server.setCaptureContent(true);

        // get the Selenium proxy object
        Proxy proxy = server.seleniumProxy();

        // configure it as a desired capability
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.PROXY, proxy);

        // start the browser up
        WebDriver driver = new FirefoxDriver(capabilities);

        // create a new HAR with the label "apple.com"
        server.newHar("assertselenium.com");

        // open yahoo.com
        driver.get("http://assertselenium.com");

        driver.get("http://assertselenium.com/2012/10/30/transformation-from-manual-tester-to-a-selenium-webdriver-automation-specialist/");

        // get the HAR data
        Har har = server.getHar();
        FileOutputStream fos = new FileOutputStream(strFilePath);
        har.writeTo(fos);
        server.stop();
        driver.quit();

    }

そして、次のエラーが発生しました:The proxy server is refusing connections: Firefox is configured to use a proxy server that is refusing connections.

browsermob-proxy.batまた、 with portを実行しようとする4455と、次のエラーが表示されますmain

java.net.BindException: Address already in use: JVM_Bind

BrowserMob Proxy の使用方法を教えてください。

4

3 に答える 3

1

プロキシを記述するコードは正しいようです。BindException の場合、何かが既にポート 4455 を使用していることは明らかです。これを確認できます (Windows マシンでは、メモリから書き込まれます)。

netstat -ano | find "4455"

Linux ではlsof -i:4455、PID を取得して強制終了します。とにかく、接続を拒否するプロキシについては、プロキシを明示的に設定してみてください。運が良ければ、次のようになります

proxy.setHttpProxy("localhost:4455");
proxy.setSslProxy("localhost:4455");

また、最新バージョンの FF および BMP を使用していることを確認してください。

于 2014-03-19T00:47:17.943 に答える
0

java.net.BindException: Address already in use: JVM_Bind このエラーが発生するのは、前述のポートですでに 1 つのサーバーが実行されているためです。最初のインスタンスで起動したサーバーを停止せずに、コードを再度実行することがあります。

于 2015-06-11T10:57:20.483 に答える