Selenium with browser mob proxy opens a blank screen

208 views
Skip to first unread message

sum582

unread,
Apr 25, 2014, 9:35:08 AM4/25/14
to browserm...@googlegroups.com
Hi,
 i am trying to capture network timing for my selenium tests. I am using selenium web driver selenium-server-2.37.0 and browsermob-proxy-2.0-beta-8. I have included all the dependency jars in my project.

If i  comment out  the line which is setting the  proxy then it works fine. Page opens up.  

Please let me know what could be going wrong here. screenshots is also attached.


 @Test
    public void testJava1Web()  throws Exception{
        try{
              ProxyServer proxyserver = new ProxyServer(4444);
              proxyserver.start();
              Proxy proxy = proxyserver.seleniumProxy();
              proxyserver.newHar("suman");

             FirefoxProfile profileAutoUser = new FirefoxProfile();
             profileAutoUser.setAssumeUntrustedCertificateIssuer(true);
             profileAutoUser.setAcceptUntrustedCertificates(true);
         
              
             DesiredCapabilities capabilities = new DesiredCapabilities();
             capabilities.setCapability(CapabilityType.PROXY, proxy);
             capabilities.setCapability(FirefoxDriver.PROFILE, profileAutoUser);

              WebDriver driver = new FirefoxDriver(capabilities);
              driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

              driver.get("http://xxxxx:7802/em/");
              proxyserver.getHar().writeTo(new File("suman"));
              proxyserver.stop();
              driver.close();
        }catch(Exception e){
            System.out.println(e.getMessage());
            e.printStackTrace();
           
        }
     }


In console

Started JUnit Test Runner (v4)

WARN 04/25 13:20:57 n.l.b.p.h.Simulated~ - Using InetSocketAddress.getHostName() rather than InetSocketAddress.getHostString(). Consider upgrading to Java 7 for faster performance!
INFO 04/25 13:20:57 n.l.b.p.j.h.HttpSer~ - Version Jetty/5.1.x
INFO 04/25 13:20:57 n.l.b.p.j.u.Contain~ - Started HttpContext[/,/]
INFO 04/25 13:20:57 n.l.b.p.j.h.SocketL~ - Started SocketListener on 0.0.0.0:4444
INFO 04/25 13:20:57 n.l.b.p.j.u.Contain~ - Started net.lightbody.bmp.proxy.jetty.jetty.Server@1c247a0
WARN 04/25 13:24:16 n.l.b.p.ProxyServer  - Waited 5 seconds for requests to cease before returning HAR; giving up!
INFO 04/25 13:24:16 n.l.b.p.j.u.Threade~ - Stopping Acceptor ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=4444]
INFO 04/25 13:24:16 n.l.b.p.j.h.SocketL~ - Stopped SocketListener on 0.0.0.0:4444
INFO 04/25 13:24:16 n.l.b.p.j.u.Contain~ - Stopped HttpContext[/,/]
INFO 04/25 13:24:16 n.l.b.p.j.u.Contain~ - Stopped net.lightbody.bmp.proxy.jetty.jetty.Server@1c247a0
Process exited with exit code 1.



screen.png

sum582

unread,
Apr 28, 2014, 9:22:38 AM4/28/14
to browserm...@googlegroups.com
Screen opens up and all navigation work fine when  i use this code

             ProxyServer proxyserver = new ProxyServer(4444);
              proxyserver.start();
              Proxy proxy = proxyserver.seleniumProxy();
              proxy.setHttpProxy("www-proxy.abc.com:80");
              proxyserver.newHar("suman");

but HAR file doesn't have any information which in understandable.

Without  setting HttpProxy, if i see the network tab of my firefox winbdw (opened by selenium) i get <my system name> as  HttpProxy  and 4444 as port. which is not recognized by the network i think.

Question is.. do we need to  setup a new proxy with <my system name>? Is it not possible to override  it with www-proxy.abc.com?

Any help on this will be highly appreciated. I am  totally stuck at this point of time.

Regards,
Suman
Reply all
Reply to author
Forward
0 new messages