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

相关推荐
光影6275 小时前
Selenium自动化测试---实战踩坑实录
python·selenium·测试工具·百度
掌动智能7 小时前
传统数据工厂之死:RunnerAgent如何开启AI驱动的“数据生产”新纪元
人工智能·测试工具·自动化
wuchen10041 天前
使用Postman测试grpc接口-传参错误的反例
测试工具·postman
蒲公英内测分发1 天前
Typeoff 实时润色体验:语音转文字让写作效率提升 3 倍
测试工具·产品运营·项目管理
Luminbox紫创测控1 天前
氙灯太阳光模拟器加速老化测试
人工智能·测试工具·测试标准
wangl_921 天前
Wireshark 使用指南:从入门到高级分析
网络·网络协议·tcp/ip·测试工具·wireshark·modbus
Byron Loong1 天前
【网络】Wireshark过滤器表达式的规则
网络·测试工具·wireshark
MESMarketing2 天前
互动分享 | Shift-Left实践落地
功能测试·测试工具·自动化·自动驾驶·敏捷开发
lifewange2 天前
主流性能诊断工具
测试工具
程序员杰哥2 天前
独立搭建UI自动化测试框架
自动化测试·软件测试·python·selenium·测试工具·ui·测试用例