MachinePublishers / jBrowserDriver

A programmable, embeddable web browser driver compatible with the Selenium WebDriver spec -- headless, WebKit-based, pure Java
Other
809 stars 143 forks source link

jbrowserdriver - remote - proxy #239

Open walterjwhite opened 7 years ago

walterjwhite commented 7 years ago

I am setting the necessary proxy (for traffic to be routed) in desired capabilities, but jbrowser driver appears to ignore those settings when I run it as a remote driver.

walterjwhite commented 7 years ago

I tried:

  1. setting the system proxy on the command line where I'm starting the driver
  2. setting capabilities
  3. setting system properties where I'm initializing the remote web driver instance (I know, this was just a last ditch effort).

None of the above had any impact.

Thanks,

Walter

GrzegorzDrozd commented 7 years ago

I also have this problem. I tried everything I could think of:

DesiredCapabilities cap = new DesiredCapabilities();
Proxy proxy = new Proxy();
proxy
        .setHttpProxy("127.0.0.1:8181")
        .setFtpProxy("127.0.0.1:8181")
        .setSslProxy("127.0.0.1:8181")
        .setSocksProxy("127.0.0.1:8181")
        .setProxyType(Proxy.ProxyType.MANUAL);
        cap.setCapability(CapabilityType.PROXY, proxy);
return new JBrowserDriver(cap);
DesiredCapabilities cap = new DesiredCapabilities();
Proxy proxy = new Proxy();
proxy
        .setSocksProxy("127.0.0.1:8181")        
        .setProxyType(Proxy.ProxyType.MANUAL);
        cap.setCapability(CapabilityType.PROXY, proxy);
return new JBrowserDriver(cap);

Produces right away : org.openqa.selenium.WebDriverException: org.openqa.selenium.Proxy Caused by: java.io.NotSerializableException: org.openqa.selenium.Proxy

And any combination of:

Settings.Builder settings = Settings.builder();
settings.userAgent(UserAgent.CHROME);
settings.timezone(Timezone.EUROPE_LONDON);

ProxyConfig config = new ProxyConfig(ProxyConfig.Type.SOCKS, "localhost", 8181);
settings.proxy(config);
return new JBrowserDriver(settings.build());

With or without:

System.setProperty("socksProxyHost", "localhost");
System.setProperty("socksProxyPort", "8181");

System.setProperty("jbd.proxyhost", "localhost");
System.setProperty("jbd.proxyport", "8181");
System.setProperty("jbd.proxytype", ProxyConfig.Type.SOCKS.toString());

Creates timeouts because url I am trying to load is accessible only using proxy. Please fix that.

GrzegorzDrozd commented 7 years ago

Stack trace for serialization error: https://gist.github.com/GrzegorzDrozd/ce0b8fa74de1a18bdad0e7a82d4b9f01

GrzegorzDrozd commented 7 years ago

It fails :/

Settings.Builder settings = Settings.builder();
settings.proxy(new ProxyConfig(ProxyConfig.Type.SOCKS, "localhost", 8181));
settings.userAgent(UserAgent.CHROME);
settings.timezone(Timezone.EUROPE_LONDON);

driver = new JBrowserDriver(settings.build());

Fails with exception: https://gist.github.com/GrzegorzDrozd/4c0ea0a338e9ec25d715dad1892bc58a