简体   繁体   中英

How to change Opera's proxy settings from Watir-Webdriver?

(This question is loosely related to my previous question )

Hello there.

I have been using Watir-Webdriver with Mozilla FireFox for a week now, and I am quite pleased with it. However, since I am making a test wich tries to connect to some websites multiple times using different proxies, I found that using FireFox was extremely slow. Firefox's starting time is (at least on my computer) about 15 seconds(if you're lucky) so I am looking to find something to speed the thing up. This made me look into other browsers and their start up times. It seems Opera is quite fast. However, since it is 'new' in Selenium Webdriver and thus also in Watir-webdriver there is not much documentation about it.

Enough talking, time for the question:

How can I, using watir-webdriver(or Selenium-webdriver directly), change the proxy that Opera uses for connections?

I'm not quite sure I understand the use case, but as a hack/workaround you can change any Opera setting from OperaWatir by loading opera:config and running JS in it to set preferences. In other words,

browser.goto('opera:config')
browser.execute_script( 'opera.setPreference("Proxy", "HTTP Server", "127.0.0.1:8888")' )
browser.execute_script( 'opera.setPreference("Proxy", "Use HTTP", "1")' )

should work without restart or anything. The opera:config page itself shows you the options you can set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM