python selenium 定制启动Chrome的选项注意事项(十九)
自动化测试的时候为了避免每个case均需要登录的操作,所以把登录后的cookie信息保存下来,在有效期内使用cookie的方式实现登录操作,为了避免展现太多的登录操作,需要通过设置浏览器的option来改变是否可视化;
最早采用phantomjs方式来实现,但是在使用phantomjs时候提示浏览器已经自带属性,所以我们这里不需要再使用phantomjs来实现无界面操作,这个时候需要使用 options.set_headless(headless=True) 设置无界面;
options = webdriver.ChromeOptions()
options.set_headless() # 设置启动无界面化
driver = webdriver.Chrome(chrome_options=options) # 启动时添加定制的选项
此时通过 chrome_options 选项来添加定制的Chrome 来选项参数,但是此时一直提示“DeprecationWarning: use options instead of chrome_options warnings.warn('use options instead of chrome_options', DeprecationWarning)“ 根据错误提示阅读了下源码
if chrome_options:
warnings.warn('use options instead of chrome_options', DeprecationWarning)
options = chrome_options if options is None:
# desired_capabilities stays as passed in
if desired_capabilities is None:
desired_capabilities = self.create_options().to_capabilities()
else:
if desired_capabilities is None:
desired_capabilities = options.to_capabilities()
else:
desired_capabilities.update(options.to_capabilities())
根据源码的提示发现使用chrome_options 时会将chrome_options 值传给options,然后在给一个警告信息,根据错误信息已经源码的注解了解到未来options会取代chrome_options,所以我们只需要chrome_options改成options即可,该问题应该在最近的版本更改的目前我这边使用的是selenium==3.9.0,有兴趣的可以去看下官方文档,那个版本开始做的此项的修改。
python selenium 定制启动Chrome的选项注意事项(十九)的更多相关文章
- Python学习笔记之selenium 定制启动 chrome 的选项
在自动化中,默认情况下我们打开的就是一个普通的纯净的chrome浏览器,而我们平时在使用浏览器时,经常就添加一些插件,扩展,代理之类的应用.所以使用 selenium 时,我们可能需要对 chrome ...
- selenium 定制启动 chrome 的选项
序 使用 selenium 时,我们可能需要对 chrome 做一些特殊的设置,以完成我们期望的浏览器行为,比如阻止图片加载,阻止JavaScript执行 等动作.这些需要 selenium的 Chr ...
- selenium 定制启动chrome的参数
selenium 定制启动chrome的参数 设置代理. 禁止图片加载 修改ua https://blog.csdn.net/vinson0526/article/details/51850929 1 ...
- selenium webdriver启动Chrome浏览器后无法输入网址的解决办法
通过selenium webdriver启动Chrome浏览器,脚本如下: from selenium import webdriver browser = webdriver.Chrome() br ...
- Python selenium + Firefox启动浏览器
Python selenium 的运用 from selenium import webdriver # from selenium.webdriver.firefox.firefox_profile ...
- Python+Selenium学习--启动及关闭浏览器
场景 页面上弹出的对话框是自动化测试经常会遇到的一个问题:很多情况下对话框是一个iframe,如之前iframe介绍的例子,处理起来稍微有点麻烦:但现在很多前端框架的对话框是div 形式的,这就让我们 ...
- python+selenium下载文件——Chrome
from selenium import webdriver import time options = webdriver.ChromeOptions() prefs = { 'profile.de ...
- selenium+java启动chrome浏览器
- python selenium TouchAction模拟移动端触摸操作(十八)
最近做移动端H5页面的自动化测试时候,需要模拟一些上拉,下滑的操作,最初考虑使用使用selenium ActionChains来模拟操作,但是ActionChains 只是针对PC端程序鼠标模拟的一系 ...
随机推荐
- Ajax+Struts2用户注册功能实现
详细请参考源码(Github):https://github.com/QQ3330447288/ajaxRegister 1.目录结构 2.截图 3.核心代码: register.jsp <sc ...
- 七天学会ASP.NET MVC ——深入理解ASP.NET MVC
七天学会ASP.NET MVC (一)——深入理解ASP.NET MVC 系列文章 七天学会ASP.NET MVC (一)——深入理解ASP.NET MVC 七天学会ASP.NET MVC (二) ...
- 【快捷键】IntelliJ IDEA For Mac 常用快捷键
一.符号对应关系 ⌃ control ⌥ option ⌘ command ⇧ shift 二.常用快捷键 1.control+shift+J 两行整理成一行 2.command+shift+F12 ...
- Matlab:椭圆方程的导数边值问题
tic; clear clc N=; M=*N; h1=/M; h2=/N; x=:h1:; y=:h2:; fun=inline('exp(x)*sin(pi*y)','x','y'); f=inl ...
- MongoDB数据库基本命令
MongoDB的启动 先找到MongoDB所在的路径,然后执行以下代码 mongod --dbpath=E:\Program Files\MongoDB\Server\3.4\data\db --db ...
- Starting MySQL....The server quit without updating PID file[失败]/lib/mysql/ip12189.pid). 错误一例
[root@ip12189 etc]# service mysqld startStarting MySQL....The server quit without updating PID file[ ...
- 使用mint-ui中弹框组件与原生弹框阻止父页面不滑动方法
1,使用mint-ui框架中<mt-popup></mt-popup>,在组件中加入 lockScroll="true" 阻止父页面不滑动. 2,原生弹框中 ...
- ansible的管理与剧本
首先我们安装一个ansible. 在7版本,直接用yum安装就可以 yum -y install ansible 然后清空ansible的配置文件,在里面写入自己需要管理的服务器的ip和相应的登陆密码 ...
- git多账号切换
修改: git config --global user.name "Your_Username" git config --global user.email username@ ...
- 长字符串换行word-break
word-break: break-all,每个字符换行 word-break: break-word按照单词换行,长字符之间换行