lightbody / browsermob-proxy

A free utility to help web developers watch and manipulate network traffic from their AJAX applications.
http://bmp.lightbody.net
Apache License 2.0
2.17k stars 659 forks source link

Firefox driver throwing exception with BrowserMobProxyServer #289

Closed ayanmodak closed 8 years ago

ayanmodak commented 9 years ago

I have tried the below code as per latest BrowserMobProxy

import java.io.File; import java.io.IOException;

import net.lightbody.bmp.BrowserMobProxy; import net.lightbody.bmp.BrowserMobProxyServer; import net.lightbody.bmp.client.ClientUtil; import net.lightbody.bmp.core.har.Har;

import org.openqa.selenium.Proxy; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities;

public class SampleTestSuite2 {

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

    // start the proxy
    BrowserMobProxy server = new BrowserMobProxyServer();
    server.start(0);

    int port = server.getPort();
    System.out.println(port);

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

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

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

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

    // open yahoo.com
    driver.get("https://in.yahoo.com");

    // get the HAR data
    Har har = server.getHar();

    // Write the HAR Data in a File
    File harFile = new File("D:\\psstg1.har");
    har.writeTo(harFile);

    // Stop the BrowserMob Proxy Server
    server.stop();

    // Close the browser
    driver.quit();
}

}

But it is not working. It is launching the browser but not doing anything after.

In debug mode I have found that it is going to the following finally block of RemoteWebDriver class } finally { Thread.currentThread().setName(currentName); // line number 601 }

and then it is going to Thread.dispatchUncaughtException(Throwable).

So the browser launch was unsuccessful.

I have used following dependencies:

net.lightbody.bmp browsermob-core-littleproxy 2.1.0-beta-2 test
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.46.0</version>
    </dependency>

OS: Windows 7 64 bit

Please let me know if I am doing anything wrong.

jekh commented 9 years ago

What version of Firefox are you using? Firefox 39 (the latest) isn't supported by Selenium yet. Try Firefox 38.

selenUser commented 9 years ago

it's not official yet, but selenium 2.46 + FF 39 working well for me

2015-07-29 10:38 GMT+03:00 Jason Hoetger notifications@github.com:

What version of Firefox are you using? Firefox 39 (the latest) isn't supported by Selenium yet. Try Firefox 38.

— Reply to this email directly or view it on GitHub https://github.com/lightbody/browsermob-proxy/issues/289#issuecomment-125870700 .

ayanmodak commented 9 years ago

Yes other functional tests are running properly with selenium 2.46 + FF 39.

I have tried another approach. Instead of adding the Jar by maven dependency as above, I added the 'browsermob-dist-2.1.0-beta-2.jar' in the build path of the project. This time its working fine and hitting the URL properly. But server.getHar(); returning null value.

jekh commented 9 years ago

@ayanmodak - are you still having issues with this? The BrowserTest test class passes for me using the latest Selenium and FF.

jekh commented 8 years ago

I haven't seen an update to this issue, so I'll go ahead and close it. Please feel free to reopen if it occurs again.