How to get the running ProxyServer from BrowserMobFixtureService

119 views
Skip to first unread message

tiberi...@ebsromania.ro

unread,
Apr 25, 2014, 4:36:33 AM4/25/14
to thucydid...@googlegroups.com
Hi,

How do I get ProxyServer running with WebDriver when is instantiated at start.

In pom:
<thucydides.version>0.9.239</thucydides.version>
        <dependency>
            <groupId>net.thucydides</groupId>
            <artifactId>thucydides-core</artifactId>
            <version>${thucydides.version}</version>
        </dependency>
        <dependency>
            <groupId>net.thucydides</groupId>
            <artifactId>thucydides-junit</artifactId>
            <version>${thucydides.version}</version>
        </dependency>
        <dependency>
            <groupId>net.thucydides</groupId>
            <artifactId>thucydides-browsermob-plugin</artifactId>
            <version>${thucydides.version}</version>
        </dependency>

I have tried with:
        ClasspathFixtureProviderService classpathFixtureProviderService = new ClasspathFixtureProviderService();
        List<FixtureService> fixtureServices = classpathFixtureProviderService.getFixtureServices();
        for(FixtureService fixtureService: fixtureServices){
            if(fixtureService instanceof BrowserMobFixtureService ) {
                BrowserMobFixtureService mob = (BrowserMobFixtureService) fixtureService;
                ProxyServer proxy = mob.getProxyServer();
                System.out.println(proxy == null);
            }
        }

But I get a null proxy. I need the proxy which is started with the webdriver 

INFO 04/25 08:06:15 o.b.p.j.h.HttpServer - Version Jetty/5.1.x
INFO 04/25 08:06:15 o.b.p.j.u.Container  - Started HttpContext[/,/]
INFO 04/25 08:06:15 o.b.p.j.h.SocketLis~ - Started SocketListener on 0.0.0.0:5555
INFO 04/25 08:06:15 o.b.p.j.u.Container  - Started org.browsermob.proxy.jetty.jetty.Server@75227d3
INFO 04/25 08:06:23 o.b.p.j.u.Credential - Checking Resource aliases
INFO 04/25 08:06:24 o.b.p.j.h.SocketLis~ - Started SocketListener on 0.0.0.0:62043

With the ProxyServer I want to get the Har file.
It is possible to have a method in Pages Configuration which to get the running ProxyServer?

Andrey Tolpeev

unread,
Apr 25, 2014, 11:13:30 AM4/25/14
to thucydid...@googlegroups.com
Hi, 

You should get the container with FixtureProviderService class from the Guice.

It will be look like this:

FixtureProviderService fixtureProviderService = Injectors.getInjector().getInstance(FixtureProviderService.class);

When iterate through fixtureProviderService.getFixtureServices() and get the BrowserMobFixtureService instance as you wrote before.

I hope this will help.

tiberi...@ebsromania.ro

unread,
May 19, 2014, 7:07:30 AM5/19/14
to thucydid...@googlegroups.com
Works thanks!
Reply all
Reply to author
Forward
0 new messages