BrowserMob proxy is overriding disabled Cookies in Chrome

738 views
Skip to first unread message

Isaac Howard

unread,
Feb 7, 2013, 4:04:54 PM2/7/13
to browserm...@googlegroups.com
Selenium-Server 2.28.0
BrowserMob Proxy 2.0Beta7 

There should be no cookies in the requests for this file right? I've disabled Cookies in Chrome.

But everytime I run it the har file shows that BrowserMob is sending cookies to the server.
Or did I miss a setting where you have to disable cookies in Browsermob proxy?


public static void doChrome(){
        ProxyServer chromeProxyServer = new ProxyServer(4456);
        Proxy chromeProxy = null;
        RemoteWebDriver chromeWebDriver;

        try {
            chromeProxyServer.start();
        } catch (Exception e) {
            System.out.println("Proxy Server Failed...");
        }

        chromeProxyServer.setCaptureContent(true);
        chromeProxyServer.setCaptureHeaders(true);

        try {
            chromeProxy = chromeProxyServer.seleniumProxy();
        } catch (Exception e){
            System.out.println("BLAH...");
        }

        chromeProxyServer.newHar("chrome");

        /*Chrome*/
        DesiredCapabilities dcChrome = DesiredCapabilities.chrome();
        dcChrome.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        dcChrome.setCapability(CapabilityType.PLATFORM, "MAC");
        //This should disable cookies with the Chrome Browser
        Map<String, Integer> prefs = new Hashtable<String, Integer>();
        prefs.put("profile.managed_default_content_settings.cookies", 2);
        dcChrome.setCapability("chrome.prefs", prefs);
        dcChrome.setCapability(CapabilityType.PROXY, chromeProxy);
        chromeWebDriver = new RemoteWebDriver(getURL("http://localhost:4444/wd/hub"), dcChrome);

        chromeWebDriver.get("http://www.google.com/");

        //chromeProxyServer.waitForNetworkTrafficToStop(500, 2000);

        Har chromeHar = chromeProxyServer.getHar();

        String chromeFilePath = "/Users/irh/projects/HARfiles/chrome.har";
        try {
            FileOutputStream chromeFOS = new FileOutputStream(chromeFilePath);
            chromeHar.writeTo(chromeFOS);
        } catch (Exception e) {
            System.out.println("Writing the har file failed...");
        }

        try {
            chromeProxyServer.stop();
        } catch (Exception e) {
            System.out.println("I refuse to stop...");
        }
        chromeWebDriver.quit();
    }

William Chang

unread,
Feb 7, 2013, 5:03:11 PM2/7/13
to browserm...@googlegroups.com
https://github.com/webmetrics/browsermob-proxy/issues/43

Revert source code and do a custom build.

--
 
---
You received this message because you are subscribed to the Google Groups "BrowserMob Proxy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to browsermob-pro...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Isaac Howard

unread,
Feb 7, 2013, 5:24:18 PM2/7/13
to browserm...@googlegroups.com
What I meant was that I disabled cookies in Chrome, but Browsermob is ignoring the Disabled cookies from Chrome.

I quit the browser between every test and only hit the page a single time. So I don't think it's an issue of saving the cookies...
But I'll do a custom build, and report back.

Thanks,
ISaac

William Chang

unread,
Feb 7, 2013, 5:42:52 PM2/7/13
to browserm...@googlegroups.com
I was running into the same issue even though I had a clean profile browser spawning for each test. I believe reverting the code will solve your issue.

Isaac Howard

unread,
Feb 8, 2013, 1:46:53 PM2/8/13
to browserm...@googlegroups.com
Alright so I did this

Then attempted to do 
imac07:browsermob-proxy irh$ git revert 9608c8f
error: Commit 9608c8f6256e2d9f9a924f83f657a5eab59e06bf is a merge but no -m option was given.
fatal: revert failed

I can't find any reference to a parent number that I would need to revert that commmit. Or am I missing something with reverting a merge?

I also tried Beta4, but alas I need the newer SSL stuff.

Patrick Lightbody

unread,
Feb 12, 2013, 12:52:06 AM2/12/13
to browserm...@googlegroups.com
I should just fix this. The issue is: I'm not entirely sure what the problem is :)

Can someone write a failing test case?

Isaac Howard

unread,
Feb 12, 2013, 4:50:59 PM2/12/13
to browserm...@googlegroups.com
A failing Selenium test?
Or a Unit Level Test for BrowserMob Proxy?

Patrick Lightbody

unread,
Feb 13, 2013, 1:38:26 AM2/13/13
to browserm...@googlegroups.com
Either is good with me. I was thinking a JUnit test that drives Selenium + automates the proxy (similar to the existing MailingListTestCase that is in the source now) would be the way to go.

Isaac Howard

unread,
Feb 14, 2013, 11:00:01 AM2/14/13
to browserm...@googlegroups.com
Alright, so I've been trying to hack up a test for you that fails.

But I'm running into this issue.
In order to run Selenium from browsermob-proxy is need to add:
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>2.29.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.29.0</version>
            <scope>test</scope>
        </dependency>

Which when by itself throws a: java.lang.NoClassDefFoundError: org/apache/http/entity/ContentType on instantiation of chrome (aka WebDriver webDriver = new ChromeDriver(dcChrome);)

Googling that results in adding this dependency for Selenium as of 2.28.0
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.2.3</version>
            <scope>test</scope>
        </dependency>

But that conflicts with your org.apache.httpcomponents.httpclient dependency, so I removed the scope of test.

But now it throws me this...
java: /Users/irh/projects/browsermobNEW/src/main/java/org/browsermob/proxy/http/BrowserMobHttpRequest.java:76: reference to StringEntity is ambiguous, both method StringEntity(java.lang.String,java.lang.String) in org.apache.http.entity.StringEntity and method StringEntity(java.lang.String,java.nio.charset.Charset) in org.apache.http.entity.StringEntity match

I readily admit to not knowing how to deal with that one now. Any advice?

Just for reference here is my test case:
<TEST>
package org.browsermob.proxy;

import org.browsermob.core.har.Har;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.FileOutputStream;

/**
 * User: irh
 * Date: 2/13/13
 */
public class CookieIssuesTest {

    private ProxyServer proxyServer = new ProxyServer(8081);

    @org.junit.Test
    public void testCookie() {
        Proxy proxy = null;

        try {
            proxyServer.start();
            proxyServer.setCaptureContent(true);
            proxyServer.setCaptureHeaders(true);

            proxy = proxyServer.seleniumProxy();
        } catch (Exception e) {
            System.out.println("Crap");
        }

        DesiredCapabilities dcChrome = DesiredCapabilities.chrome();
        dcChrome.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        //dcChrome.setCapability(CapabilityType.PROXY, proxy);
        WebDriver webDriver = new ChromeDriver(dcChrome);

        proxyServer.newHar("HAR");

        webDriver.get("www.google.com");

        //TODO check the cookies coming from client to proxy
        //TODo check the cookies coming from proxy to server

        writeHarFile("har");

        try {
            System.out.println("Stopping Port " + proxyServer.getPort());
            proxyServer.stop();
        } catch (Exception e) {
            System.out.println("The proxy server didn't stop.");
        }

        webDriver.quit();
    }

    public void writeHarFile(String fileName) {
        Har har = proxyServer.getHar();

        //proxyServer.waitForNetworkTrafficToStop(500, 20000);

        String strFilePath = "/Users/irh/projects/browsermobNEW/target/HARfiles/har.har";
        try {
            FileOutputStream fos = new FileOutputStream(strFilePath);
            har.writeTo(fos);
        } catch (Exception e) {
            System.out.println("Writing the har file failed...");
        }
    }
}
</TEST>

Patrick Lightbody

unread,
Feb 15, 2013, 8:56:43 AM2/15/13
to browserm...@googlegroups.com
I'll figure out the dependency issues. The key thing is creating the Selenium test that demonstrates the cookie issue. I can take it from there.

webtester

unread,
Apr 14, 2013, 1:09:53 PM4/14/13
to browserm...@googlegroups.com
Any update on this ?

Patrick Lightbody

unread,
Apr 14, 2013, 1:11:51 PM4/14/13
to browserm...@googlegroups.com

Not yet but am working on it today


Sent from Mailbox for iPhone

Patrick Lightbody

unread,
Apr 21, 2013, 3:20:44 PM4/21/13
to browserm...@googlegroups.com
I think this is fixed now. I just did a bunch of Cookie-related work and have some tests in place now. Can you confirm?

عماد الشامخ

unread,
Jun 6, 2013, 8:54:55 PM6/6/13
to browserm...@googlegroups.com
نصب واحتيال احذرو ????

عماد الشامخ

unread,
Jun 6, 2013, 8:55:27 PM6/6/13
to browserm...@googlegroups.com
نصب واحتيال احذرو ????
Reply all
Reply to author
Forward
0 new messages