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. Redis的bind的误区(转)

    原文1:https://blog.csdn.net/cw_hello1/article/details/83444013 原文2:https://www.cnblogs.com/suiyueqiann ...

  2. (十一)SpringBoot之文件上传以及

    一.案例 1.1 配置application.properties #主配置文件,配置了这个会优先读取里面的属性覆盖主配置文件的属性 spring.profiles.active=dev server ...

  3. mysql cmd命令行 创建数据库 表 基础语句

    一.连接MYSQL 格式: mysql -h主机地址 -u用户名 -p用户密码 1. 连接到本机上的MYSQL. 首先打开DOS窗口,然后进入目录mysql\bin,再键入命令mysql -u roo ...

  4. Windows群集之NLB【转】

    本文转自:http://www.talkwithtrend.com/Article/31746 网络负载平衡群集(Network Load balancing) 在Internet快速发展的今天,为了 ...

  5. Django rest-framework框架-组件之渲染器

    渲染器: from rest_framework.renderers import BrowsableAPIRenderer,AdminRenderer,HTMLFormRenderer,JSONRe ...

  6. Linux Centos7配置ftp服务器

    一.安装 1.安装 yum install  -y vsftpd 2.设置开机启动 systemctl enable vsftpd.service 3.启动 systemctl start vsftp ...

  7. keras 切换后端 TensorFlow,cntk,theano

    参考 https://keras.io/#configuring-your-keras-backend https://keras.io/backend/ Switching from one bac ...

  8. ccs编译.lib

    新建 New一个CCS Project Output type选择"Static Library" 添加源文件 右击工程 -> Add Files- 编译 编译生成的.lib ...

  9. string leetcode-6.ZigZag

    6. ZigZag Conversion 题面 The string "PAYPALISHIRING" is written in a zigzag pattern on a gi ...

  10. 7.Redis的发布订阅

    Redis消息的订阅/发布 a)是什么 进程间的一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息. b)命令 SUBSCRIBE订阅 PUBLISH发布 c)案例 先订阅后发布后才 ...