selenium

Selenium基础:SSL证书错误处理 13

1、chrome解决办法 在chromeoptions()中添加”--ignore-certificate-errors"为true的选项 #-*-coding: utf-8-*- from selenium import webdriver options = webdriver.ChromeOp ......
Selenium 证书 错误 基础 SSL

Anaconda环境下使用pip install selenium安装失败的解决办法

背景: 在Anaconda环境下执行pip install selenium,一直报time out错误 解决方法: python -m pip install selenium 参考资料: https://blog.csdn.net/qq_45538469/article/details/1138 ......
Anaconda selenium install 办法 环境

Selenium基础:配置chrome浏览器 12

1、屏蔽浏览器对selenium的检测 ”chrome正受到自动测试软件的控制。“ 解决方法: options = webdriver.ChromeOptions() options.add_experimental_option('excludeSwitches', ['enable-automa ......
Selenium 浏览器 基础 chrome 12

Selenium基础:其他设置 11

1、限制页面加载时间 设置页面加载限制时间:set_page_load_timeout(time) #-*-coding:utf-8-*- from selenium import webdriver from selenium.common.exceptions import TimeoutExc ......
Selenium 基础 11

Selenium基础:时间等待 10

1、强制等待 time.sleep() 指定一个固定的线程休眠时间 #-*-coding:utf-8-*- from datetime import datetime import time print(datatime.now()) #等待5S time.sleep(5) print(datati ......
Selenium 基础 时间 10

selenium优雅打开并关闭网页

with 上下文管理器 在python中是这样介绍的所有实现了__enter__ __exit__ dunder method魔术方法的对象都可以用with 接下来以Chrome为例查看底层 def __enter__(self): return self def __exit__(self, ex ......
selenium 网页

Python+selenium报错raise NoSuchDriverException(f"Unable to obtain {service.path} using Selenium Manager; {err}")...解决方案

一、问题描述 进行自动化测试执行程序报错如下图: 二、解决方案 在网上找了好久都没找到答案,最后根据以往经验想到是不是selenium版本有问题,本人python版本是3.11.0,所以将selenium版本也降到3.11.0之后问题解决。 selenium降版本: pip3 install sel ......

[-003-]-Python3+Unittest+Selenium Web UI自动化测试之显示等待WebDriverWait

1、WebDriverWait基本用法 引入包 # 文件引入 from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as E ......

[-002-]-Python3+Unittest+Selenium Web UI自动化测试之定位元素(包括父子,兄弟)及常见操作

1、常见的定位方式 id定位:find_element_by_id() name定位:find_element_by_name() class定位:find_element_by_class_name() link定位:find_element_by_link_text() partial link ......
父子 Unittest Selenium 元素 常见

Python错误:selenium自带click方法点击不到元素

问题描述: selenium自带click方法,有的时候不好用,元素定位到了,但是就是点不上。 解决办法: 原因分析:点击不到元素! 解决办法: (1). selenium自带的click()方法: from selenium import webdriverel = driver.find_ele ......
selenium 元素 错误 方法 Python

selenium ui自动化遇到切换窗口,点击高级并继续访问的处理方式

在python自动化中(ui),遇到了一个需要浏览器切换窗口,点击“高级”-“接受风险并继续”的操作,前期在本地编写代码调试时,没有任何问题。 切换环境,放到Linux服务中,使用无头模式去运行代码时,发现切换窗口时,总是找不到页面元素,查看截图发现页面为空白,检查两天无果。 场景图片,如下图所示, ......
selenium 方式

selenium中操作Cookie

Cookie介绍: Cookie,有时也用其复数形式 Cookies。类型为“小型文本文件”,是某些网站为了辨别用户身份,进行Session跟踪而储存在用户本地终端上的数据(通常经过加密),一般存放在客户端上 以百度首页为例,打开调试工具(F12),点击Application(应用程序),选择 St ......
selenium Cookie

如何隐藏Selenium特征

from selenium import webdriver from selenium.webdriver.common.proxy import Proxy, ProxyType # 亿牛云爬虫加强版代理IP 地址、端口号、用户名和密码 proxy_address = 'www.16yun.cn ......
Selenium 特征

selenium中使用三种时间等待方式:强制等待、隐式等待、显示等待

正文: 强制等待 隐式等待 显示等待 强制等待 from time import sleep from selenium import webdriver driver = webdriver.Chrome("../resources/chromedriver.exe") 20) # 访问网址 dr ......
selenium 方式 时间

selenium中截屏方法

有时候打印的错误信息不够直观 如果在脚本执行出错时能够对当前窗口进行截图并保存,那么就可以非常直观地看到脚本出错的原因。 WebDriver 提供了截图函数 save_screenshot (),可用来截取当前窗口 from selenium import webdriver driver = we ......
selenium 方法

关于selenium加载用户文件保持登录状态

如下脚本是一个微博用selenium'自动化登录的简单例子 import time from selenium import webdriver from loguru import logger from selenium.webdriver.chrome.options import Optio ......
selenium 状态 文件 用户

selenium之滑块验证

登录时,会有遇到滑块验证码,一般有2种:1.拖到最右边;2.拖到指定位置。 本文只介绍下第一种情况。 第二种情况,可以参考:https://zhuanlan.zhihu.com/p/624497402 例如第一次登录lazada网站需要滑块验证:https://sellercenter.lazada ......
selenium

全栈测试开发系列----WebDriver API及对象识别技术(二)---selenium验证码处理的多种实现方式

前言 对于测试人员而言,不管是进行性能测试还是自动化测试,验证码的处理都是棘手的存在,在WEB应用中,大部分系统在用户登录的时候都要求用户输入验证码,且验证码的种类繁多,如纯数字、纯字母、汉子组合、数学题运算、滑动图标、图片、短信、邮箱、语音等。 既然要实现验证码的处理操作,那么就需要了解验证码的作 ......
WebDriver selenium 多种 对象 方式

tool_Selenium IDE(录制浏览器操作的工具)

一、安装工具 打开chrome浏览器 -> 扩展程序->访问Chrome应用商店 搜索 selenium ide后,点击Selenium IDE,添加至Chrome 点击浏览器右上角插件按钮,将Selenium IDE固定,点击Se图标就可打开工具 ......
tool_Selenium Selenium 浏览器 工具 tool

Selenium自动化程序被检测为爬虫,怎么屏蔽和绕过

先打开浏览器,再链接操作 1、打开浏览器时添加以下参数: --remote-debugging-port=9222 --user-data-dir="C:\\selenium\\ChromeProfile" 2、selenium中设置浏览器选项,通过上面设置的 9222端口连接浏览器: from s ......
爬虫 Selenium 程序

全栈测试开发系列----WebDriver API及对象识别技术(二)---selenium文件上传及下载

目录 一、文件上传 二、文件下载 正文 一、文件上传:selenium+AutoIT 在网页上传文件的时候,Selenium无法直接操作如Flash、JavaScript 或Ajax 等技术所实现的上传功能,selenium是根据网页上的标签来定位的,但是上传文件时却是调用的非网页上的窗口,针对se ......
WebDriver selenium 对象 文件 技术

[-001-]-Python3+Unittest+Selenium Web UI自动化测试之环境准备

1、Python环境,网上很多教程,查询配置即可 2、选用的浏览器及driver驱动 以google为例子: 首先查看你的google浏览器的版本,比如我的:114.0.5735.199 找driver驱动:https://registry.npmmirror.com/binary.html?pat ......
Unittest Selenium Python3 环境 Python

selenium鼠标操作和键盘操作

鼠标操作 在 WebDriver 中,与鼠标操作相关的方法都封装在 ActionChains 类中 # 引入 ActionChains 类 from selenium.webdriver import ActionChains 常用方法: perform():执行 ActionChains 类中存储 ......
selenium 键盘 鼠标

selenium中使用xpath定位

在 XML 文档中,XPath 是一种定位元素的语言。因为 HTML 可以看作 XML 的一种实 现,所以 WebDriver 提供了这种在 Web 应用中定位元素的方法 绝对路径选择 elements = driver.find_elements(By.XPATH, "/html/body/div ......
selenium xpath

WEB自动化-selenium-定位方式

定位元素的时候可以修改JS样式来确定定位的元素是否正确 # 通过selenium修改JS属性, 用来确定我定位的元素是什么? driver.execute_script( "arguments[0].setAttribute('style',arguments[1]);", el, "border: ......
selenium 方式 WEB

(五)selenium定位方式Xpath

豆瓣网:https://book.douban.com/ 作为例子,更好的理解和探索Xpath的定位方法(网页定期更新后如果元素不存在了,请参考截图) 简单的定位例子: //div[@class='top-nav-info'] 准备工作: 打开网页elements: ctrl+shift+c 自带的 ......
selenium 方式 Xpath

Selenium基础:cookie javascript调用 屏幕截图 09

1、cookie操作 绕过登录 get_cookies():以字典形式返回cookie所有信息 get_cookies(name):返回cookie字典中key为name的值 add_cookie(cookie_dict):手动添加cookie。cookie_dict为字典数据格式,cookie_d ......
截图 javascript Selenium 屏幕 基础

Selenium基础:文件上传下载操作 08

文件上传 input标签使用send_keys()方法上传,非input标签需要借助工具 1、input标签使用send_keys()方法 #文件上传 #“\\"第一个”\"为转义字符 driver.find_element_by_id('uploadfile').send_keys('D:\\Us ......
上传下载 Selenium 文件 基础 08

爬虫:爬到的数据存到mysql中、爬虫和下载中间件、加代理,cookie、header、加入selenium、集成selenium、==去重规则源码分析(布隆过滤器)、布隆过滤器、scrapy-redis实现分布式爬虫

[toc] ### 爬到的数据存到mysql中 ```python class FirstscrapyMySqlPipeline: def open_spider(self, spider): print('我开了') self.conn = pymysql.connect( user='root' ......

selenium中使用CSS 定位

CSS 是一种语言,用来描述 HTML 和 XML 文档的表现。CSS 使用选择器为页面元素 绑定属性。 CSS 选择器可以较为灵活地选择控件的任意属性,一般情况下,CSS 定位速度比 XPath 定位速度快 通过 CSS Selector 选择单个元素的方法是 find_element(By.CS ......
selenium CSS