自动化测试的时候为了避免每个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的选项注意事项(十九)的更多相关文章

  1. Python学习笔记之selenium 定制启动 chrome 的选项

    在自动化中,默认情况下我们打开的就是一个普通的纯净的chrome浏览器,而我们平时在使用浏览器时,经常就添加一些插件,扩展,代理之类的应用.所以使用 selenium 时,我们可能需要对 chrome ...

  2. selenium 定制启动 chrome 的选项

    序 使用 selenium 时,我们可能需要对 chrome 做一些特殊的设置,以完成我们期望的浏览器行为,比如阻止图片加载,阻止JavaScript执行 等动作.这些需要 selenium的 Chr ...

  3. selenium 定制启动chrome的参数

    selenium 定制启动chrome的参数 设置代理. 禁止图片加载 修改ua https://blog.csdn.net/vinson0526/article/details/51850929 1 ...

  4. selenium webdriver启动Chrome浏览器后无法输入网址的解决办法

    通过selenium webdriver启动Chrome浏览器,脚本如下: from selenium import webdriver browser = webdriver.Chrome() br ...

  5. Python selenium + Firefox启动浏览器

    Python selenium 的运用 from selenium import webdriver # from selenium.webdriver.firefox.firefox_profile ...

  6. Python+Selenium学习--启动及关闭浏览器

    场景 页面上弹出的对话框是自动化测试经常会遇到的一个问题:很多情况下对话框是一个iframe,如之前iframe介绍的例子,处理起来稍微有点麻烦:但现在很多前端框架的对话框是div 形式的,这就让我们 ...

  7. python+selenium下载文件——Chrome

    from selenium import webdriver import time options = webdriver.ChromeOptions() prefs = { 'profile.de ...

  8. selenium+java启动chrome浏览器

  9. python selenium TouchAction模拟移动端触摸操作(十八)

    最近做移动端H5页面的自动化测试时候,需要模拟一些上拉,下滑的操作,最初考虑使用使用selenium ActionChains来模拟操作,但是ActionChains 只是针对PC端程序鼠标模拟的一系 ...

随机推荐

  1. tar命令-压缩,解压缩文件

    tar: -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 上面五个参数是独立的,压缩解压都要用到其中一个,可以和下面的命令连用但只能用其 ...

  2. 『OpenCV3』滤波器边缘检测

    一.原理简介 边缘检测原理 - Sobel, Laplace, Canny算子 X方向Sobel算子 -1 -2 -1 0 0 0 1 2 1 Y方向Sobel算子 -1 0 1 -2 0 2 -1 ...

  3. css实现0.5px

    使用缩放来0.5来实现,注意兼容各种浏览器 .frz-list li:after { content: ''; position: absolute; bottom:; height: 1px; wi ...

  4. 2015-10-12 jQuery4

    十. 直接获取.编辑内容 1.获取内容 alert($("#d1").text());    //获取文本内容 alert($("#d1").html()); ...

  5. Makefile 系统论述

    该篇文章为转载,是对原作者系列文章的总汇加上标注. 支持原创,请移步陈浩大神博客: http://blog.csdn.net/haoel/article/details/2886 概述 什么是make ...

  6. spoj Minimax Triangulation

    题解: dp+计算几何 F[i][j]表示第i-j条边的答案 然后转移一下 代码: #include<bits/stdc++.h> using namespace std; ]; ][]; ...

  7. day050 django第一天 自定义框架

    1.简单的web框架 1. 创建一个简单的python文件: import socket sever=socket.socket() sever.bind(('127.0.0.1',8001)) se ...

  8. SpringCloud使用Feign实现服务间通信

    SpringCloud的服务间通信主要有两种办法,一种是使用Spring自带的RestTemplate,另一种是使用Feign,这里主要介绍后者的通信方式. 整个实例一共用到了四个项目,一个Eurek ...

  9. nodejs -- http模块. request() 方法 , get方法.

    1. request方法: 提交评论到慕课网: var http = require('http'); var querystring = require('querystring'); var po ...

  10. idea设置代码块

    转:https://blog.csdn.net/boy_Kenny/article/details/55223078?utm_source=blogxgwz4 idea设置代码块 1.代码模板场景介绍 ...