实现Firefox自定义加载profile, 主要解决以下问题:
- 解决走默认profile配置有插件、各种配置干扰问题
- 解决老profile遗留导致不能启动firefox问题
- 注:selenium版本:2.53.17-py2.7
profile模板:
[General]
StartWithLastProfile=1
[Profile0]
Name=default
IsRelative=1 #如果设置 为0表示关闭相关设置
Path=Profiles/jz6mhrzv.default
Default=1
代码块
代码块语法遵循标准markdown代码,例如:
from selenium import webdriver
def load_firefox_browser():
cus_profile_dir = "\yourpath" # 你自定义profile的路径
cus_profile = wedriver.FirefoxProfile(cus_profile_dir)
browser = webdriver.Firefox(cus_profile)
borwser.implicitly_wait(30)