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

相关推荐
爱敲代码的菜菜17 小时前
【测试】自动化测试
css·selenium·测试工具·junit·自动化·xpath
123过去1 天前
wireshark使用教程
linux·网络·测试工具·wireshark
123过去1 天前
hexinject使用教程
linux·网络·测试工具
测试19981 天前
功能测试、自动化测试、性能测试的区别?
自动化测试·软件测试·python·功能测试·测试工具·性能测试·安全性测试
爱敲代码的菜菜1 天前
【测试】Selenium
selenium·测试工具·xpath·webdriver·cssselector
shughui2 天前
Fiddler下载、安装、使用、汉化,详细图文教程(2026附安装包)
前端·测试工具·fiddler
若惜2 天前
selenium自动化测试web自动化测试 框架封装Pom
前端·python·selenium
2501_915921432 天前
常用iOS性能测试工具大全及使用指南
android·测试工具·ios·小程序·uni-app·cocoa·iphone
半个俗人2 天前
3.postman全局变量和环境变量
测试工具·postman