我们自动化测试的时候,有时不需要图片加载出来,提高浏览器加载速度,从而提高脚本的执行速度。另外在一些网络比较差的环境下,禁用css、图片等加载可以提高访问速度

方法:

      1、创建自己的firefoxprofile

关闭所有Filefox浏览窗口—》运行Firefox Manager,点击windows“开始”-->“运行”,然后在输入框输入firefox.exe -ProfileManager

Firefox创建firefoxprofile

点击“确定”按钮-》创建一个新的Profile,只需点击“创建配置文件”按钮,在接着出现的向导窗口里输入配置文件名

Firefox创建firefoxprofile

Firefox创建firefoxprofile

Firefox创建firefoxprofile

Firefox创建firefoxprofile

现在就创建了一个独立的Firefox Profile配置文件,启动Profile配置文件的Firefox


新建一个bat文件,输入命令行

set MOZ_NO_REMOTE=1 
start "" "C:\Program Files\Mozilla Firefox Formal\firefox.exe" -P firefoxprofile文件名

在新打开的浏览器中,你可以随意设置火狐,这些设置都保存在你的个性化firefoxprofile中

 

     2、现在使用selenium调用firefoxprofile

firefox_profile = webdriver.FirefoxProfile("D:\Downloads")

browser = webdriver.Firefox(firefox_profile=firefox_profile)
D:\Downloads路径存放着我firefoxprofile

相关文章:

  • 2022-12-23
  • 2021-09-19
  • 2021-05-23
  • 2021-11-08
  • 2021-04-19
  • 2022-12-23
  • 2021-07-27
  • 2021-05-27
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2021-12-15
  • 2022-01-15
  • 2021-04-25
  • 2021-08-28
相关资源
相似解决方案