selenium启动参数设置

1. selenium

selenium启动配置参数接收是ChromeOptions类,创建方式如下:

bash 复制代码
from selenium import webdriver
option = webdriver.ChromeOptions()
bash 复制代码
class SELEDEMO:
    def __init__(self):
	    #启动配置参数接收是ChromeOptions类,创建方式如下:
        options = webdriver.ChromeOptions()
        prefs = {
            'profile.default_content_setting_values': {
                'images': 2,  # 无图
                'javascript': 2,  # 禁止脚本加载
                'permissions.default.stylesheet': 2,  # 禁用css
            }}
        options.add_experimental_option('prefs', prefs)
        # 禁用插件
        options.add_argument('--disable-plugins')
        # 禁用显卡
        options.add_argument('--disable--gpu')
        # 浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败
        options.add_argument("--headless")
        # 添加UA
        options.add_argument(
            "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
            "Chrome/95.0.4638.69 Safari/537.36")
        # 指定引擎,可以加快启动时间
        self.driver = webdriver.Chrome(service=Service('E:\document\chromedriver-win64\chromedriver.exe'), options=options)
        # 刷新页面
        self.driver.refresh()
        self.wait = WebDriverWait(self.driver, 10)

chromedriver.exe下载地址:

下载地址:https://chromedriver.chromium.org/downloads

相关推荐
依旧很淡定1 天前
Selenium(Python)创建Chrome浏览器实例
chrome·python·selenium
小熊出擊1 天前
【pytest】finalizer 执行顺序:FILO 原则
python·测试工具·单元测试·pytest
云闲不收1 天前
接口请求工具对比 apifox apipost swagger postman等
测试工具·postman
sitellla2 天前
Testify Go测试工具包入门教程
git·测试工具·其他·golang
我的xiaodoujiao2 天前
从 0 到 1 搭建 Python 语言 Web UI自动化测试学习系列 9--基础知识 5--常用函数 3
前端·python·测试工具·ui
可可南木2 天前
ICT 数字测试原理 8 - -VCL 的测试参数
开发语言·功能测试·测试工具·pcb工艺
加油20192 天前
爬虫框架: selenium API使用介绍
爬虫·selenium·测试工具
shelter -唯3 天前
基于selenium库的爬虫实战:京东手机数据爬取
爬虫·python·selenium
IDOlaoluo3 天前
Postman-win64-8.6.2-Setup安装教程(附详细步骤,Win64版Postman下载安装指南)
测试工具·postman
运维小菜鸟h3 天前
利用wxpython开发API接口调试工具,类似postman
测试工具·postman