Using proxy auto config for Android WebDriver

766 views
Skip to first unread message

Lukus

unread,
Jan 3, 2012, 5:38:08 PM1/3/12
to Selenium Users
Having trouble getting the Android webdriver to use a proxy. I
believe I'm coding this correctly as shown below. I've even been
able
to set proxy settings for Android Browser and Opera Mini on the
emulator, but cannot get webdriver to use those settings, nor get it
to work through the capabilities object.
-------------
DesiredCapabilities capabilities = DesiredCapabilities.android();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
Proxy proxy = new Proxy();
proxy.setProxyAutoconfigUrl("http://crossbrowsertesting.com/
proxypac.php");
capabilities.setCapability(CapabilityType.PROXY, proxy);
driver = new AndroidDriver(capabilities);
--------------
Can anyone confirm that this is the correct way to set a PAC file on
the Android emulator, and that this works for them?

Dounia Berrada

unread,
Jan 6, 2012, 2:22:40 PM1/6/12
to seleniu...@googlegroups.com
Hi Lukus,

Sorry for the late reply. This isn't implemented for Android WebDriver yet. I suspect it is feasible because it can be done manually in the Android browser settings. I haven't found any obvious APIs in Android to allow setting a setting in WebView, however a search showed  that many seem to be doing this using reflexion, like this for instance

Would you be willing to implement this? If so please sign our CLA and send me your patch when ready. In the meantime let me know if you have other questions.

Cheers,

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.




--
Dounia

Lukus

unread,
Jan 18, 2012, 2:20:11 PM1/18/12
to Selenium Users
Thanks for the reply.

I'm not sure that I will embark on editing the source myself. I will
mention that there are two ways I've been able to get this working for
the emulator where both Android's Browser and Opera Mini use the
proxy. What's confusing is that WebDriver obviously doesn't use
whatever reference these other browser use in determining the path of
network communication.

One is by launching the emulator with the -http-proxy flag found here:
http://developer.android.com/guide/developing/tools/emulator.html
I was surprised that WebDriver didn't use this proxy when the whole
emulator instance was set to use this. The other browsers worked
correctly when launched this way.

The other way to get a proxy working on the emulator (might work for
physical device but haven't tested) is to update the device's
database.
1. Shell into the device: adb shell
2. cd /data/data/com.android.providers.telephony/databases
3. sqlite3 telephony.db
4. update carriers set proxy='your-proxy-hostname', port='your-proxy-
port'' where _id=2
5. then kill the com.android.phone process so it picks up the new
setting

Both of these methods are applicable to the Android Browser and to
Opera Mini. So what are they doing that is different from WebDriver?
That would be direction I might look at versus implementing
reflexion.

If I do get a chance to look at this further, I will submit more info
or a patch to you.

Thanks.
Reply all
Reply to author
Forward
0 new messages