当前位置: 首页 > news >正文

【Python】使用Selenium 操作浏览器 自动化测试 记录

【自动化】Python SeleniumUtil 工具 开启开发者模式 自动安装油猴用户脚本等-CSDN博客文章浏览阅读389次。【自动化】Python SeleniumUtil 工具。https://blog.csdn.net/G971005287W/article/details/144565691?spm=1001.2014.3001.5501【学习记录】浏览器指纹相关学习记录(指纹介绍、获取指纹、修改指纹、随机指纹保护隐私等)-CSDN博客文章浏览阅读1k次,点赞30次,收藏11次。可以识别是同一个用户。https://blog.csdn.net/G971005287W/article/details/144528762【自动化】Python SeleniumUtil 油猴 工具 自动安装用户脚本-CSDN博客文章浏览阅读311次。【自动化】Python SeleniumUtil 工具-CSDN博客。【自动化】Python SeleniumUtil 油猴 工具。【自动化】Python SeleniumUtil 工具。https://blog.csdn.net/G971005287W/article/details/144565736

【Python】使用Selenium 操作浏览器 记录

1.安装python

2.安装 selenium

pip install selenium

3.安装Chrome浏览器驱动

【附件】Selenium chromedriver 驱动及浏览器下载-CSDN博客文章浏览阅读42次。【附件】Selenium chromedriver 驱动及浏览器下载。https://blog.csdn.net/G971005287W/article/details/144556634

from selenium import webdriver
from selenium.webdriver.edge.service import Service as EdgeService
from selenium.webdriver.edge.options import Options as EdgeOptions
import timedef main():# 设置Edge选项edge_options = EdgeOptions()edge_options.add_argument('--start-maximized')  # 窗口最大化启动user_data_dir = r'C:\Users\Administrator\AppData\Local\Microsoft\Edge\User Data'  # Windows 示例路径,请替换为实际路径edge_options.add_argument(f'--user-data-dir={user_data_dir}')  # 窗口最大化启动# 如果需要指定Profile,可以添加 --profile-directory 参数# profile_directory = 'Profile 5'  # 替换为你要使用的具体Profile名称profile_directory = 'Default'  # 替换为你要使用的具体Profile名称edge_options.add_argument(f'--profile-directory={profile_directory}')# edge_options.add_argument("--headless")# 指定Edge WebDriver的位置service = EdgeService(executable_path='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedgedriver.exe')# service = EdgeService(executable_path=executable_path)# 创建一个新的Edge浏览器实例,并启用无痕模式driver = webdriver.Edge(service=service, options=edge_options)driver.set_window_size(300, 500)# 打开目标网页driver.get('https://www.baidu.com')print('打开第一个浏览器')# 设置Edge选项edge_options2 = EdgeOptions()edge_options2.add_argument('--start-maximized')  # 窗口最大化启动# edge_options2.add_argument("--headless")user_data_dir2 = r'C:\Users\Administrator\AppData\Local\Microsoft\Edge\User Data2'  # Windows 示例路径,请替换为实际路径edge_options2.add_argument(f'--user-data-dir={user_data_dir2}')  # 窗口最大化启动# 如果需要指定Profile,可以添加 --profile-directory 参数# profile_directory2 = 'Profile 5'  # 替换为你要使用的具体Profile名称profile_directory2 = 'Default'  # 替换为你要使用的具体Profile名称edge_options2.add_argument(f'--profile-directory={profile_directory2}')# 指定Edge WebDriver的位置service2 = EdgeService(executable_path='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedgedriver2.exe')# service = EdgeService(executable_path=executable_path)# 创建一个新的Edge浏览器实例,并启用无痕模式driver2 = webdriver.Edge(service=service2, options=edge_options2)driver2.set_window_size(300, 500)# 打开目标网页driver2.get('https://www.baidu.com')print('打开第二个浏览器')time.sleep(500000000)if __name__ == "__main__":main()

http://www.lryc.cn/news/507396.html

相关文章:

  • GDPU软件工程习题(挖空版)
  • 【活动邀请·深圳】深圳COC社区 深圳 AWS UG 2024 re:Invent re:Cap
  • Hutool工具包的常用工具类的使用介绍
  • C++简明教程(文章要求学过一点C语言)(2)
  • 防火墙技术与网络安全
  • html 中 表格和表单的关系与区别
  • 基于Java的购物网站毕业论文
  • Redis——缓存预热+缓存雪崩+缓存击穿+缓存穿透
  • wxWidgets使用wxStyledTextCtrl(Scintilla编辑器)的正确姿势
  • 【ETCD】【实操篇(二)】如何从源码编译并在window上搭建etcd集群?
  • 服务器数据恢复—V7000存储中多块磁盘出现故障导致业务中断的数据恢复案例
  • 冯诺依曼架构与哈佛架构的对比与应用
  • Hive其四,Hive的数据导出,案例展示,表类型介绍
  • CMake function使用
  • 【AI学习】Huggingface复刻Test-time Compute Scaling技术
  • 前端导出PDF的组件及方法
  • Mac升级macOS 15 Sequoia后,无法ssh连接本地虚拟机
  • Pytorch | 利用MI-FGSM针对CIFAR10上的ResNet分类器进行对抗攻击
  • linux 无网络安装mysql
  • 自毁程序密码—阿里聚安全(IDA动态调试)
  • 【华为OD-E卷-寻找关键钥匙 100分(python、java、c++、js、c)】
  • vscode 使用说明
  • 【Linux系统编程】:信号(2)——信号的产生
  • Android Studio AI助手---Gemini
  • 【day09】面向对象——静态成员和可变参数
  • Android学习(七)-Kotlin编程语言-Lambda 编程
  • 彻底认识和理解探索分布式网络编程中的SSL安全通信机制
  • 【libuv】Fargo信令2:【深入】client为什么收不到服务端响应的ack消息
  • Vue3自定义事件
  • BeautifulSoup 与 XPath 用法详解与对比