Suppose you need to use proxy servers for some of your scenarios (unique visitors). Since each test case may use many proxies, changing the global system proxy settings is a rather bad idea. Fortunately HTTP proxies may be configured in a web browser. If you inspect the Firefox about:config panel, you will notice many properties that configure how your browser really acts. We'll be interested in the network.proxy.* settings.
from selenium import webdriver from selenium.common.exceptions import TimeoutException try: proxy = "192.168.1.3" port = 8080 fp = webdriver.FirefoxProfile() fp.set_preference('network.proxy.ssl_port', int(port)) fp.set_preference('network.proxy.ssl', proxy) fp.set_preference('network.proxy.http_port', int(port)) fp.set_preference('network.proxy.http', proxy) fp.set_preference('network.proxy.type', 1) browser = webdriver.Firefox(firefox_profile=fp) browser.set_page_load_timeout(15) browser.get('http://192.168.1.1/test') print browser.find_element_by_id('my_div').text except TimeoutException as te: print "timeout" except Exception as ex: print ex.message finally: browser.quit()
First we need to configure our profile by setting the HTTP, and HTTPS proxies. Secondly we have to tell Firefox to start using them: network.proxy.type -> 1. Finally we create an instance of Firefox with our proxy settings and execute out test routine.
Have fun!
~KR
firefoxProfile = webdriver.FirefoxProfile();
ReplyDeletefirefoxProfile.set_preference("network.proxy.type", 2);
firefoxProfile.set_preference("network.proxy.autoconfig_url", "http://x.x.x.x:xx/proxy.pac");
firefoxProfile.set_preference("network.proxy.no_proxies_on", "localhost");
firefoxProfile.update_preferences()
this man save my life
ReplyDeleteLooking great and it is very helpful content you can read my content here It is really helpful article please read it too my blog Firefox Not Loading.
ReplyDeletekayseriescortu.com - alacam.org - xescortun.com
ReplyDeleteperde modelleri
ReplyDeletemobil onay
Mobil Odeme Bozdurma
https://nftnasilalinir.com
ankara evden eve nakliyat
Trafik Sigortası
dedektör
web sitesi kurma
Ask kitaplari
Good content. You write beautiful things.
ReplyDeletekorsan taksi
mrbahis
sportsbet
mrbahis
sportsbet
hacklink
vbet
vbet
taksi
başakşehir
ReplyDeletebayrampaşa
beşiktaş
beykoz
beylikdüzü
6VDLHP
mecidiyeköy
ReplyDeletesakarya
istanbul
kayseri
ordu
İOJ3
ورنيش شفاف
ReplyDelete