selenium 定制启动chrome的参数
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的参数的更多相关文章
- python selenium 定制启动Chrome的选项注意事项(十九)
自动化测试的时候为了避免每个case均需要登录的操作,所以把登录后的cookie信息保存下来,在有效期内使用cookie的方式实现登录操作,为了避免展现太多的登录操作,需要通过设置浏览器的option ...
- selenium 定制启动 chrome 的选项
序 使用 selenium 时,我们可能需要对 chrome 做一些特殊的设置,以完成我们期望的浏览器行为,比如阻止图片加载,阻止JavaScript执行 等动作.这些需要 selenium的 Chr ...
- Python学习笔记之selenium 定制启动 chrome 的选项
在自动化中,默认情况下我们打开的就是一个普通的纯净的chrome浏览器,而我们平时在使用浏览器时,经常就添加一些插件,扩展,代理之类的应用.所以使用 selenium 时,我们可能需要对 chrome ...
- selenium webdriver启动Chrome浏览器后无法输入网址的解决办法
通过selenium webdriver启动Chrome浏览器,脚本如下: from selenium import webdriver browser = webdriver.Chrome() br ...
- selenium python 启动Chrome
启动Chrom浏览器 下载chromedriver: http://chromedriver.storage.googleapis.com/index.html 当时找chromedriver与chr ...
- selenium+java启动chrome浏览器
- chrome常用参数
chrome禁止本地浏览时加载本地其他文件,可以采用添加启动参数的方式来支持 添加参数为 --allow-file-access-from-files 或者 --disable-web-securit ...
- selenium启动Chrome时,加载用户配置文件
selenium启动Chrome时,加载用户配置文件 Selenium操作浏览器是不加载任何配置的,网上找了半天,关于Firefox加载配置的多点,Chrome资料很少,下面是关于加载Chrome ...
- 【Selenium专题】WebDriver启动Chrome浏览器(二)
官方API Constructor Summary ChromeDriver() Creates a new ChromeDriver using the default server configu ...
随机推荐
- SVM的概率输出(Platt scaling)
SVM的概率输出(Platt scaling) 2015-10-22 10:38:19 闲渔Love吉他 阅读数 8121 文章标签: Platt Scaling Calibr 更多 分类专栏: 计算 ...
- Java InsertionSort
Java InsertionSort /** * <html> * <body> * <P> Copyright 1994-2018 JasonInternatio ...
- 在论坛中出现的比较难的sql问题:3(row_number函数 分组查询)
原文:在论坛中出现的比较难的sql问题:3(row_number函数 分组查询) 最近,在论坛中,遇到了不少比较难的sql问题,虽然自己都能解决,但发现过几天后,就记不起来了,也忘记解决的方法了. 所 ...
- xposed获取context 的方法
// 应用被加壳,采用这种方式加载类 try { XposedHelpers.findAndHookMethod(Application.class, "attach", Cont ...
- moment——日期格式化常用示例
<template> <div id="app" style="text-align: center;"> <h1>{{ m ...
- 【python】python 自动发邮件
一.一般发邮件的方法 Python对SMTP支持有smtplib和email两个模块,email负责构造邮件,smtplib负责发送邮件. 注意到构造MIMETEXT对象时,第一个参数就是邮件正文,第 ...
- 线段树lazy模板 luogu3372
线段树写得很少,这么基本的算法还是要会的…… #include<bits/stdc++.h> using namespace std; inline long long read() { ...
- CentOS 8 (1905)系统安装
本章内容: CentOS 8 的安装(CentOS-8-1905) 一.安装光盘,选择Install CentOS Linux 8.0.1905 二.选择系统语言,我这里选的是英文,也可以选择中文,往 ...
- jade-render-renderFile
var http = require('http'); var jade = require('jade'); http.createServer(function(req, res){ res.wr ...
- Paper Reading:个性化推荐系统的研究进展
论文:个性化推荐系统的研究进展 发表时间:2009 发表作者:刘建国,周涛,汪秉宏 论文链接:论文链接 本文发表在2009,对经典个性化推荐算法做了基本的介绍,是非常好的一篇中文推荐系统方面的文章. ...