selenium 定制启动chrome的参数

设置代理. 禁止图片加载 修改ua

https://blog.csdn.net/vinson0526/article/details/51850929

1.配置chrome以手机模拟器

https://blog.csdn.net/u013948858/article/details/81123951

from selenium import webdriver

mobile_emulation = { "deviceName": "Nexus 5" }

chrome_options = webdriver.ChromeOptions()

chrome_options.add_experimental_option("mobileEmulation", mobile_emulation) # 这里看清楚了,不是add_argument

driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',desired_capabilities = chrome_options.to_capabilities())

#====
from selenium import webdriver from selenium.webdriver.chrome.options import Options mobile_emulation = { "deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 }, "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19" } chrome_options = Options() chrome_options.add_experimental_option("mobileEmulation", mobile_emulation) # 这里看清楚了,不是add_argument driver = webdriver.Chrome(chrome_options = chrome_options) # 这里的chrome_options 建议都使用 desired_capabilities ,应为在Grid分布式中比较方便

2.取消显示 收到自动化软件的控制 / 静默方式运行

from selenium import webdriver

# 加启动配置
option = webdriver.ChromeOptions()
option.add_argument('disable-infobars')
#return webdriver.Chrome(chrome_options = option,desired_capabilities = None) # 打开chrome浏览器
driver = webdriver.Chrome(chrome_options=option)
driver.get("https://www.baidu.com") from selenium import webdriver # 加启动配置
option = webdriver.ChromeOptions()
option.add_argument('headless') # 打开chrome浏览器
driver = webdriver.Chrome(chrome_options=option)
driver.get("https://www.baidu.com")

selenium 定制启动chrome的参数的更多相关文章

  1. python selenium 定制启动Chrome的选项注意事项(十九)

    自动化测试的时候为了避免每个case均需要登录的操作,所以把登录后的cookie信息保存下来,在有效期内使用cookie的方式实现登录操作,为了避免展现太多的登录操作,需要通过设置浏览器的option ...

  2. selenium 定制启动 chrome 的选项

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

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

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

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

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

  5. selenium python 启动Chrome

    启动Chrom浏览器 下载chromedriver: http://chromedriver.storage.googleapis.com/index.html 当时找chromedriver与chr ...

  6. selenium+java启动chrome浏览器

  7. chrome常用参数

    chrome禁止本地浏览时加载本地其他文件,可以采用添加启动参数的方式来支持 添加参数为 --allow-file-access-from-files 或者 --disable-web-securit ...

  8. selenium启动Chrome时,加载用户配置文件

    selenium启动Chrome时,加载用户配置文件   Selenium操作浏览器是不加载任何配置的,网上找了半天,关于Firefox加载配置的多点,Chrome资料很少,下面是关于加载Chrome ...

  9. 【Selenium专题】WebDriver启动Chrome浏览器(二)

    官方API Constructor Summary ChromeDriver() Creates a new ChromeDriver using the default server configu ...

随机推荐

  1. (九)Struts标签基础(二)

    2.3 非表单标签 2.3.1 <s:actionerror>标签, this.addActionError("错误信息1");   //使用addActionErro ...

  2. .net core partial view的一些心得

    原文:.net core partial view的一些心得 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog. ...

  3. docker 学习1 WSL docker ,Windows docker

    获取Linux内核版本 //使用 lsb_release -a 可见我电脑上的 WSL Linux 版本是 Ubuntu的. 安装docker for ubuntu (遇到问题) 转[http://b ...

  4. RANSAC拟合算法

    最小二乘法只适合与误差较小的情况.试想一下这种情况,假使需要从一个噪音较大的数据集中提取模型(比方说只有20%的数据时符合模型的)时,最小二乘法就显得力不从心了. 算法简介 随机抽样一致算法(RANd ...

  5. 如何在Web应用里消费SAP Leonardo的机器学习API

    去年5月的时候,Jerry曾经写了一篇文章:使用Java程序消费SAP Leonardo的机器学习API,而最近另外做的一个项目,需要在Web应用里做同样的事情. 因为有了前一篇文章的铺垫,避免了很多 ...

  6. ASE19团队项目 beta阶段 model组 scrum2 记录

    本次会议于12月3日,19时整在微软北京西二号楼sky garden召开,持续10分钟. 与会人员:Jiyan He, Kun Yan, Lei Chai, Linfeng Qi, Xueqing W ...

  7. harbor小结

    1.harbor是什么? docker容器是集装箱,harbor就是放集装箱的港湾. docker工具下有:①自带镜像库房:image      ②容器管理清单 :container     ③doc ...

  8. 跨平台打开一个URL的方法

    unit u_urlOpen; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System ...

  9. macro 标签,和静态文件,以及templates

    1 模板 -Templates 1 什么是模板 模板,在Flask中就是允许响应给用户看的网页在模板中,允许包含“占位变量”来表示动态的内容 模板最终也会被解析成字符串再响应给客户端,这一过程通常称为 ...

  10. Docker部署code-server

    Docker部署code-server 版本:codercom/code-server:v2 code-server可以放在服务器上,随时随地在浏览器中,编写代码.运行.调试: 手机,pad都可以进行 ...