def chrome(self):
# https://github.com/SeleniumHQ/selenium/blob/master/py/selenium/webdriver/remote/webdriver.py
# http://www.guguncube.com/2983/python-testing-selenium-with-google-chrome
# https://gist.github.com/addyosmani/5336747
# http://blog.likewise.org/2015/01/setting-up-chromedriver-and-the-selenium-webdriver-python-bindings-on-ubuntu-14-dot-04/
# https://sites.google.com/a/chromium.org/chromedriver/getting-started
# http://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium
chrome = webdriver.Chrome()
return chrome
# @property
# def firefox(self):
# profile = webdriver.FirefoxProfile()
# #firefox = webdriver.Firefox(firefox_profile=profile)
# firefox = WebDriver(firefox_profile=profile)
# return firefox
python类FirefoxProfile()的实例源码
download facebook photos.py 文件源码
项目:Facebook-Photos-Download-Bot
作者: NalinG
项目源码
文件源码
阅读 39
收藏 0
点赞 0
评论 0
def main(username, account_password,destination):
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', destination)
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', "image/png,image/jpeg")
if not username == "NONE" and not account_password == "NONE" and not destination == "NONE":
display = Display(visible=0, size=(800, 600))
display.start()
driver = webdriver.Firefox(firefox_profile=profile)
driver.get("https://www.facebook.com")
email_id = driver.find_element_by_id("email")
password = driver.find_element_by_id("pass")
email_id.send_keys(username)
password.send_keys(account_password)
driver.find_element_by_id("loginbutton").click()
# driver.find_element_by_css_selector("._5afe.sortableItem").click()
driver.find_element_by_id("navItem_2305272732").click()
time.sleep(3)
list_of_images = driver.find_elements_by_css_selector(".uiMediaThumbImg")
list_of_images[0].click()
# print list_of_images
for image in list_of_images:
time.sleep(3)
driver.find_element_by_xpath("//div[@class = 'overlayBarButtons rfloat _ohf']/div/div/a").click()
time.sleep(3)
option = driver.find_element_by_xpath("//div[@class = 'uiContextualLayerPositioner uiLayer']/div/div/div[@class = '_54ng']/ul[@class = '_54nf']/li[4]/a")
option_name = option.find_element_by_xpath(".//*")
option_name = option_name.find_element_by_xpath(".//*")
if option_name.get_attribute('innerHTML').lower() == "download":
option_name.click()
# print option.get_attribute('innerHTML')
driver.find_element_by_css_selector(".snowliftPager.next.hilightPager").click()
display.stop()
else:
print "\nIncomplete Parameters, Program is Shutting Down."
def set_firefoxprofile(proxy_ip, proxy_port):
"""method to update the given preferences in Firefox profile"""
ff_profile = webdriver.FirefoxProfile()
if proxy_ip is not None and proxy_port is not None:
proxy_port = int(proxy_port)
ff_profile.set_preference("network.proxy.type", 1)
ff_profile.set_preference("network.proxy.http", proxy_ip)
ff_profile.set_preference("network.proxy.http_port", proxy_port)
ff_profile.set_preference("network.proxy.ssl", proxy_ip)
ff_profile.set_preference("network.proxy.ssl_port", proxy_port)
ff_profile.set_preference("network.proxy.ftp", proxy_ip)
ff_profile.set_preference("network.proxy.ftp_port", proxy_port)
ff_profile.update_preferences()
else:
ff_profile = None
return ff_profile
# private methods
def getFirefox(tempDir='/tmp', showImage=1):
"""get Firefox Webdriver object
:param showImage: 2 = don't show, 1=show
"""
proxy = Proxy(dict(proxyType=ProxyType.AUTODETECT))
profile = webdriver.FirefoxProfile()
profile.set_preference("plugin.state.flash", 0)
profile.set_preference("plugin.state.java", 0)
profile.set_preference("media.autoplay.enabled", False)
# 2=dont_show, 1=normal
profile.set_preference("permissions.default.image", showImage)
profile.set_preference("webdriver.load.strategy", "unstable")
# automatic download
# 2 indicates a custom (see: browser.download.dir) folder.
profile.set_preference("browser.download.folderList", 2)
# whether or not to show the Downloads window when a download begins.
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", tempDir)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk",
"application/octet-stream"+
",application/zip"+
",application/x-rar-compressed"+
",application/x-gzip"+
",application/msword")
return webdriver.Firefox(firefox_profile=profile, proxy=proxy)
def __init__(self, proxy):
"""init the webdriver by setting the proxy and user-agent
Args:
proxy (str): proxy in the form of ip:port
"""
# set proxy
ip, port = proxy.split(':')
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", ip)
profile.set_preference("network.proxy.http_port", port)
# set user_agent
profile.set_preference("general.useragent.override", generate_user_agent())
profile.update_preferences()
self.driver = webdriver.Firefox(firefox_profile=profile)
print 'current proxy: %s'%proxy
def driver():
if exists(screenshot_dir):
shutil.rmtree(screenshot_dir)
os.mkdir(screenshot_dir)
firefox_path = '{0}/firefox/firefox'.format(DIR)
caps = DesiredCapabilities.FIREFOX
caps["marionette"] = True
caps['acceptSslCerts'] = True
binary = FirefoxBinary(firefox_path)
profile = webdriver.FirefoxProfile()
profile.add_extension('{0}/JSErrorCollector.xpi'.format(DIR))
profile.set_preference('app.update.auto', False)
profile.set_preference('app.update.enabled', False)
driver = webdriver.Firefox(profile,
capabilities=caps, log_path="{0}/firefox.log".format(LOG_DIR),
firefox_binary=binary, executable_path=join(DIR, 'geckodriver/geckodriver'))
# driver.set_page_load_timeout(30)
# print driver.capabilities['version']
return driver
def firefox(headless=True):
"""
Context manager returning Selenium webdriver.
Instance is reused and must be cleaned up on exit.
"""
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
if headless:
driver_key = 'headless'
firefox_options = Options()
firefox_options.add_argument('-headless')
else:
driver_key = 'headed'
firefox_options = None
# Load profile, if it exists:
if os.path.isdir(PROFILE_DIR):
firefox_profile = webdriver.FirefoxProfile(PROFILE_DIR)
else:
firefox_profile = None
if FIREFOX_INSTANCE[driver_key] is None:
FIREFOX_INSTANCE[driver_key] = webdriver.Firefox(
firefox_profile=firefox_profile,
firefox_options=firefox_options,
)
yield FIREFOX_INSTANCE[driver_key]
def start_selenium_driver(module):
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-gzip")
profile.set_preference("browser.helperApps.alwaysAsk.force", False);
profile.set_preference("browser.download.dir", module.params['download_directory'])
driver = webdriver.Firefox(profile)
# Lets make sure that firefox is closed at the exit of the module
atexit.register(driver.close)
driver.implicitly_wait(30)
driver.get(module.params['url'])
return driver
def __init__(self):
# disable the js of firefox to speed up. it is not necessary to run
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList", 2)
firefox_profile.set_preference("javascript.enabled", False)
# get the webdriver of the opened firefox and open the url
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
self.driver.get("http://en.swisswebcams.ch/verzeichnis/traffic/schweiz/beliebt")
# open the file to store the list and write the format of the list at the first line
self.f = open('list_swissWebcam_traffic.txt', 'w')
self.f.write("country#city#snapshot_url#latitude#longitude" + "\n")
# wait object to use
self.wait = ui.WebDriverWait(self.driver, 10)
def __init__(self):
# store the url of homepage and the country code
self.home_url = "http://en.swisswebcams.ch"
self.geo_url = "http://map.topin.travel/?p=swc&id="
self.country = "CH"
# open the file to store the list and write the format of the list at the first line
self.f = open('list_swissWebcam.txt', 'w')
self.f.write("country#city#snapshot_url#latitude#longitude" + "\n")
# open the Firefox
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList", 2)
firefox_profile.set_preference("javascript.enabled", False)
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
# wait object to use
self.wait = ui.WebDriverWait(self.driver, 10)
Brazil_infotrafego_traffic.py 文件源码
项目:CAM2RetrieveData
作者: PurdueCAM2Project
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def __init__(self):
# store the url of homepage, traffic page, the country code, and the state code
self.home_url = "http://infotrafego.pbh.gov.br"
self.traffic_url = "http://infotrafego.pbh.gov.br/info_trafego_cameras.html"
self.country = "BR"
self.state = ""
# open the file to store the list and write the format of the list at the first line
self.list_file = open("list_infotrafego_traffic.txt", "w")
self.list_file.write("city#country#snapshot_url#latitude#longitude" + "\n")
# get the webdriver of the opened firefox and open the url
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList", 2)
firefox_profile.set_preference("javascript.enabled", False)
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
# gps module
self.gps = Geocoding('Google', None)
reload(sys)
sys.setdefaultencoding('utf8')
def __init__(self):
# store the url of homepage, traffic page, the country code, and the state code
self.home_url = "http://www.phillytraffic.com"
self.traffic_url = "http://www.phillytraffic.com/#!traffic-updates/cjn9"
self.country = "USA"
self.state = "PA"
# open the file to store the list and write the format of the list at the first line
self.file = open('list_Philadelphia_PA.txt', 'w')
self.file.write("city#country#state#snapshot_url#latitude#longitude" + "\n")
# open the brwoser
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList", 2)
firefox_profile.set_preference("javascript.enabled", False)
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
self.wait = ui.WebDriverWait(self.driver, 10)
def __init__(self):
# store the url of homepage, traffic page, the country code, and the state code
self.home_url = "http://tmc.baycountyfl.gov"
self.traffic_url = "http://tmc.baycountyfl.gov/"
self.country = "USA"
self.state = "FL"
# open the file to store the list and write the format of the list at the first line
self.f = open('list_FL_baycounty.txt', 'w')
self.f.write("city#country#state#snapshot_url#latitude#longitude" + "\n")
# open the web-browser
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList", 2)
firefox_profile.set_preference("javascript.enabled", False)
self.driver = webdriver.Firefox()
self.wait = ui.WebDriverWait(self.driver, 10)
# gps module
self.gps = Geocoding('Google', None)
def __init__(self):
# store the url of homepage, traffic page, the country code, and the state code
self.home_url = "https://www.theweathernetwork.com"
self.json_url = "https://www.theweathernetwork.com/api/maps/trafficcameras/9/43.84598317236631/-80.71453475531251/43.048384299427234/-78.72600936468751"
self.country = "CA"
self.state = ""
# open the file to store the list and write the format of the list at the first line
self.list_file = open('list_Canada_weatherNetwork.txt', 'w')
self.list_file.write("city#country#snapshot_url#latitude#longitude" + "\n")
# open the browser
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList", 2)
firefox_profile.set_preference("javascript.enabled", False)
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
NorthCarolina_wsoctv.py 文件源码
项目:CAM2RetrieveData
作者: PurdueCAM2Project
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def __init__(self):
# store the url of homepage, traffic page, the country code, and the state code
self.home_url = "http://www.wsoctv.com"
self.traffic_url = "http://www.wsoctv.com/traffic/nc-cams"
self.country = "USA"
self.state = "NC"
# open the file to store the list and write the format of the list at the first line
self.f = open('list_NorthCarolina_wsoctv.txt', 'w')
self.f.write("city#country#state#snapshot_url#latitude#longitude" + "\n")
# open the web-browser
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.download.folderList", 2)
firefox_profile.set_preference("javascript.enabled", False)
self.driver = webdriver.Firefox()
self.wait = ui.WebDriverWait(self.driver, 10)
def getProxyDriver(self):
PROXY_ADDRESS = random.choice(self.proxies.keys())
address = PROXY_ADDRESS.replace("http://", "").replace("https://", "")
host = address.split(':')[0]
port = int(address.split(':')[1])
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", host)
profile.set_preference("network.proxy.http_port", port)
profile.update_preferences()
self.driver = webdriver.Firefox(firefox_profile=profile)
self.logger.info("creating driver: [%s] using proxy [%s]" % (self.driver.name, PROXY_ADDRESS))
self.driver.maximize_window()
driverfactory.py 文件源码
项目:python-behave-automation-framework
作者: pradeepta02
项目源码
文件源码
阅读 26
收藏 0
点赞 0
评论 0
def firefox():
import os
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2)
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', os.getcwd())
profile.set_preference('app.update.auto', False)
profile.set_preference('app.update.enabled', False)
profile.set_preference('app.update.silent', False)
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv/xls/zip/exe/msi')
profile.set_preference('xpinstall.signatures.required', False)
return webdriver.Firefox(profile)
def get_browser(self, proxy):
""" ???????????firefox """
# ?????
firefox_profile = webdriver.FirefoxProfile()
# ????image
#firefox_profile.set_preference('permissions.default.stylesheet', 2)
#firefox_profile.set_preference('permissions.default.image', 2)
#firefox_profile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so', 'false')
# ??
if proxy.is_valid():
myProxy = '%s:%s' % (proxy.host, proxy.port)
ff_proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy': ''})
browser = webdriver.Firefox(firefox_profile=firefox_profile, proxy=ff_proxy)
else:
browser = webdriver.Firefox(firefox_profile=firefox_profile)
return browser
def proxy(PROXY_HOST,PROXY_PORT):
fp = webdriver.FirefoxProfile()
print "[" + t.green("+") + "]Proxy host set to: " + PROXY_HOST
print "[" + t.green("+") + "]Proxy port set to: " + PROXY_PORT
print "\n[" + t.green("+") + "]Establishing connection..."
fp.set_preference("network.proxy.type", 1)
fp.set_preference("network.proxy.http",PROXY_HOST)
fp.set_preference("network.proxy.http_port",int(PROXY_PORT))
fp.set_preference("general.useragent.override","'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36'")
fp.update_preferences()
return webdriver.Firefox(firefox_profile=fp)
# Function to generate and process results based on input
def firefox_driver():
# Doesn't work with geckodriver! :(
capabilities = webdriver.DesiredCapabilities().FIREFOX
capabilities['acceptSslCerts'] = True
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
return webdriver.Firefox(firefox_profile=profile, capabilities=capabilities)
def start_foxdr(thread):
uaList = [line[:-1] for line in open('Base_Data\\ualist.txt')]
open('Base_Data\\ualist.txt').close()
i = random.choice(uaList)
profile = webdriver.FirefoxProfile('c:\\Users\\'+thread)
profile.set_preference('permissions.default.image', 2)
profile.set_preference("general.useragent.override", i)
path1 = 'C:\\Program Files (x86)\\Mozilla Firefox\\geckodriver.exe'
path2 = 'C:\\Program Files\\Mozilla Firefox\\geckodriver.exe'
try:
dr= webdriver.Firefox(executable_path = path1,firefox_profile = profile )
except:
dr= webdriver.Firefox(executable_path = path2,firefox_profile = profile )
return dr,uaList
def getGift(roomid):
fp = webdriver.FirefoxProfile(
r'/Users/eclipse/Library/Application Support/Firefox/Profiles/tmsbsjpg.default')
browser = webdriver.Firefox(fp)
browser.implicitly_wait(15) # seconds
browser.get("http://www.douyu.com/" + roomid)
try:
indexvideo = browser.find_element_by_class_name('cs-textarea')
print type(indexvideo)
indexvideo.send_keys('2333333333333')
print indexvideo
time.sleep(5)
sendbut = browser.find_element_by_class_name('b-btn')
ActionChains(browser).move_to_element(
indexvideo).click(sendbut).perform()
gift = browser.find_element_by_class_name('peck-cdn')
except Exception, e:
print str(e)
browser.quit()
times = 0
while True:
try:
ActionChains(browser).move_to_element(gift).click(gift).perform()
time.sleep(1)
print times
times += 1
except Exception, e:
print 'completed by an error'
browser.quit()
def __init__(self, download_dir, *mime_types):
"""
Create a Firefox webdriver that downloads into the path download_dir,
and initiates downloads automatically for any of the given MIME types.
"""
self.download_dir = download_dir
self.profile = webdriver.FirefoxProfile()
self.profile.set_preference('browser.helperApps.neverAsk.saveToDisk',
', '.join(mime_types))
# Enable setting the default download directory to a custom path.
self.profile.set_preference('browser.download.folderList', 2)
self.profile.set_preference('browser.download.dir', self.download_dir)
super().__init__(self.profile)
def getFirefoxBrowser():
proxy = {'host': "proxy.abuyun.com", 'port': 9020, 'usr': "HWJB1R49VGL78Q3D", 'pwd': "0C29FFF1CB8308C4"}
# userProfileFilePath = r"C:\Users\LZ\AppData\Roaming\Mozilla\Firefox\Profiles\vbqy66hj.default"
# kadUserProfileFilePath = r"C:\Users\zml\AppData\Roaming\Mozilla\Firefox\Profiles\lotur5zd.default"
fp = webdriver.FirefoxProfile(localData.FirefoxUserProfileFilePath)
fp.add_extension('resource/closeproxy.xpi')
fp.set_preference('network.proxy.type', 1)
fp.set_preference('network.proxy.http', proxy['host'])
fp.set_preference('network.proxy.http_port', int(proxy['port']))
fp.set_preference('network.proxy.ssl', proxy['host'])
fp.set_preference('network.proxy.ssl_port', int(proxy['port']))
fp.set_preference('network.proxy.ftp', proxy['host'])
fp.set_preference('network.proxy.ftp_port', int(proxy['port']))
fp.set_preference('network.proxy.no_proxies_on', 'localhost, 127.0.0.1')
# ???????????
fp.set_preference('permissions.default.image', 2)
credentials = '{usr}:{pwd}'.format(**proxy)
credentials = b64encode(credentials.encode('ascii')).decode('utf-8')
fp.set_preference('extensions.closeproxyauth.authtoken', credentials)
browser = webdriver.Firefox(executable_path="resource/geckodriver", firefox_profile=fp)
# browser = webdriver.Firefox(executable_path="geckodriver")
browser.set_page_load_timeout(1)
return browser
def load_firefox(config):
"""Start Firefox webdriver with the given configuration.
Args:
config (dict): The configuration loaded previously in Cabu.
Returns:
webdriver (selenium.webdriver): An instance of Firefox webdriver.
"""
binary = None
profile = webdriver.FirefoxProfile()
if os.environ.get('HTTPS_PROXY') or os.environ.get('HTTP_PROXY'):
proxy_address = os.environ.get('HTTPS_PROXY', os.environ.get('HTTP_PROXY'))
proxy_port = re.search('\:([0-9]+)$', proxy_address).group(1)
profile.set_preference('network.proxy.type', 1)
profile.set_preference(
'network.proxy.http',
proxy_address
)
profile.set_preference('network.proxy.http_port', proxy_port)
profile.update_preferences()
if 'HEADERS' in config and config['HEADERS']:
profile = Headers(config).set_headers(profile)
if config['DRIVER_BINARY_PATH']:
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary(config['DRIVER_BINARY_PATH'])
return webdriver.Firefox(firefox_binary=binary, firefox_profile=profile)
def test_firefox_headers_loading(self):
self.app.config['DRIVER_NAME'] = 'Firefox'
profile = webdriver.FirefoxProfile()
headers = Headers(self.app.config)
profile = headers.set_headers(profile)
self.assertEquals(
profile.__dict__['default_preferences']['general.useragent.override'],
'Mozilla/6.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36'
' (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36'
)
def __init__(self, filename):
config = ConfigParser.ConfigParser()
config.read(filename)
self.LOGIN_USER_VALUE = config.get('credentials', 'login_user_value')
self.LOGIN_PASS_VALUE = config.get('credentials', 'login_pass_value')
# self.client = fbchat.Client(self.LOGIN_USER_VALUE, self.LOGIN_PASS_VALUE)
profile = webdriver.FirefoxProfile()
profile.set_preference("javascript.enabled", False)
self.driver = webdriver.Firefox(profile)
# self.driver = webdriver.PhantomJS()
# self.driver = webdriver.Chrome('./chromedriver')
self.driver.set_page_load_timeout(self.TIMEOUT)
def get_proxy_browser():
""" ?????????????? """
global proxies
global meta_info
if not proxies:
proxies = get_proxy(if_force=True)
while 1:
_, meta_info = generate_proxy(proxies)
host, port, http_method = meta_info
try:
profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy.type', 1) # 0 => direct connect, 1 => use config defautl to 0
if http_method == 'HTTP':
profile.set_preference('network.proxy.socks', host)
profile.set_preference('network.proxy.socks_port', port)
elif http_method == 'HTTPS':
profile.set_preference('network.proxy.ssl', host)
profile.set_preference('network.proxy.ssl_port', port)
profile.update_preferences()
browser = webdriver.Firefox(profile)
browser.get('http://weixin.sogou.com')
return browser
except:
print meta_info, 'was failed, now is going to choose another one'
proxies.remove(meta_info)
print 'Still have ', len(proxies), 'proxies'
if not proxies:
proxies = get_proxy(if_force=True)
_, meta_info = generate_proxy(proxies)
def setProxy(self, proxy):
profile = FirefoxProfile()
profile.accept_untrusted_certs = True
profile.assume_untrusted_cert_issuer = True
prefix = "network.proxy."
profile.set_preference("%stype" % prefix, 1)
for type in ["http", "ssl", "ftp", "socks"]:
profile.set_preference("%s%s" % (prefix, type), proxy.getHost())
profile.set_preference("%s%s_port" % (prefix, type), int(proxy.getPort()))
return profile
def new_firefox_driver(self, javascript_enabled=True):
assert javascript_enabled, 'Cannot disable javascript anymore, see: https://github.com/seleniumhq/selenium/issues/635'
from selenium.webdriver import FirefoxProfile, DesiredCapabilities
# FF does not fire events when its window is not in focus.
# Native events used to fix this.
# After FF34 FF does not support native events anymore
# We're on 48.0 now on local machines, but on 31 on travis
fp = FirefoxProfile()
# fp.set_preference("focusmanager.testmode", False)
# fp.set_preference('plugins.testmode', False)
fp.set_preference('webdriver_enable_native_events', True)
fp.set_preference('webdriver.enable.native.events', True)
fp.set_preference('enable.native.events', True)
fp.native_events_enabled = True
fp.set_preference('network.http.max-connections-per-server', 1)
fp.set_preference('network.http.max-persistent-connections-per-server', 0)
fp.set_preference('network.http.spdy.enabled', False)
fp.set_preference('network.http.pipelining', True)
fp.set_preference('network.http.pipelining.maxrequests', 8)
fp.set_preference('network.http.pipelining.ssl', True)
fp.set_preference('html5.offmainthread', False)
dc = DesiredCapabilities.FIREFOX.copy()
if not javascript_enabled:
fp.set_preference('javascript.enabled', False)
dc['javascriptEnabled'] = False
wd = webdriver.Firefox(firefox_profile=fp, capabilities=dc)
self.reahl_server.install_handler(wd)
return wd