SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

WebDriver-driven Firefox with browsermob-proxy cannot be closed within selenium-server 2.30.0 version #5415

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 5415

Repro Steps:
1. Start FirefoxDriver with browsermob-proxy 
2. Then, navigate to taobao.com
3. Try to quit driver in  teardown method (Tried both in TestNG and junit)

Actual Result: 
The firefoxdriver instance  should be closed automcaticallly. But instead of that,
the firefox doesnot quit as expected. 

Fore more information: 
1. I also tried to quit FirefoxDriver instance without proxy configured like above.
And the firefoxdriver instance closed smoothly. 
2. Then, I tried to debug this issue. The debug info turns out that after running @Test
method, the firefoxdriver instance is still alive. And it's level is FINE. But after
entering the teardown method, the firefoxdriver instance becomes to be a NULL object.

Selenium version: 2.30.0
OS: Window XP
Browser: Firefox
Browser version: 19.0.2

Pls help to locate whether this is a selenium issue?

Attached is my codes:

======Maven configuration====

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>2.30.0</version>
        </dependency>

        <dependency>
            <groupId>biz.neustar</groupId>
            <artifactId>browsermob-proxy</artifactId>
            <version>2.0-beta-6</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
        </dependency>

=====Test code ======
public class testCaptureNetworkTrafficWithFirefox {
    public static WebDriver driver;

    // @Test
    public void testCaptureNetworkTrafficWithFirefox() throws Exception {
        // start the proxy
        ProxyServer server = new ProxyServer(4444);
        server.start();

        // 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
        System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
        WebDriver driver = new FirefoxDriver(capabilities);

        // create a new HAR with label
        server.newHar("test");

        driver.get("http://www.taobao.com");

        // get the HAR data
        Har har = server.getHar();
        System.out.println("1============" + har.getLog().getEntries().size());
        System.out.println("1=========END!!");

        server.newHar("test2");
        driver.get("http://www.tmall.com");

        Har har2 = server.getHar();
        System.out.println("2============" + har2.getLog().getEntries().size());
        System.out.println("2=========END!!");

        server.cleanup();
        server.stop();

        Assert.assertNotNull(driver);
    }

    @AfterMethod
    public void tearDown() throws Exception {
        System.out.println("AfterMethod");
        Assert.assertNotNull(driver);
        driver.quit();
    }
}

Reported by Tyingrong on 2013-03-28 05:48:37

lukeis commented 8 years ago
I forgot above that IE8 and Chrome works fine in this senario.

Reported by Tyingrong on 2013-03-28 06:43:18

lukeis commented 8 years ago
It's quite suspicious that IE and Chrome work, they should not!

Because you use a local 'driver' variable in the test method, and your static 'driver'
field is never assigned.

Reported by barancev on 2013-03-29 19:29:18

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:17:02