Python最强自动化测试工具,竟然吊打Playwright!

260 篇文章 0 订阅
196 篇文章 0 订阅

软件测试面试刷题,这个小程序(永久刷题),靠它可以快速找到工作!https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502​编辑https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502icon-default.png?t=N7T8https://blog.csdn.net/AI_Green/article/details/134931243?spm=1001.2014.3001.5502

DrissionPage 是一个基于 Python 开发的网页自动化工具,它结合了浏览器自动化的便利性和 requests 库的高效率,旨在为用户提供一个功能强大且易于使用的解决方案。该工具不仅支持控制浏览器,还能进行数据包的收发,同时兼顾了两者的优势。

「一、安装」

pip install DrissionPage

「二、使用」

「1.CSS语法解析(非自动化)」

from DrissionPage import SessionPage
page = SessionPage()
for i in range(1, 5):
    page.get(f'https://gitee.com/explore/all?page={i}')
    links = page.eles('.title project-namespace-path')
    for link in links:
        print(link.text, link.link)

「输出」

一只会思考的猪/minio-plus https://gitee.com/lxp135/minio-plus
IYque/企微活码-iYqueCode https://gitee.com/iyque/iYqueCode
广东威人/springboot-btc-eth-trx https://gitee.com/Linriqiang/springboot-btc-eth-trx
aizuda/zlm4j https://gitee.com/aizuda/zlm4j
tl-open-source/tl-rtc-file https://gitee.com/tl-open-source/tl-rtc-file
dromara/warm-flow https://gitee.com/dromara/warm-flow
不如摸鱼去/wot-design-uni https://gitee.com/wot-design-uni/wot-design-uni
李佳航/orion-visor https://gitee.com/lijiahangmax/orion-visor
Shenzhi Wang/Llama3-8B-Chinese-Chat https://gitee.com/shenzhi-wang/Llama3-8B-Chinese-Chat
AI-IoTDB/openGemini https://gitee.com/ai-iotdb/openGemini
祝威廉/byzer-lang https://gitee.com/allwefantasy/byzer-lang
sAGiTTaR/thru https://gitee.com/sagittar/thru
Gtr/SparkDesk-Java https://gitee.com/grt1228/SparkDesk-Java
kercylan98/minotaur https://gitee.com/kercylan98/minotaur
ArexTest/arex-agent-java https://gitee.com/arextest/arex-agent-java
深圳高通半导体有限公司/GT-HMI-Engine https://gitee.com/genitop/GT-HMI-Engine
小诺/Snowy https://gitee.com/xiaonuobase/snowy
Shenzhi Wang/Llama3-70B-Chinese-Chat https://gitee.com/shenzhi-wang/llama3-70b-chinese-chat
dromara/MilvusPlus https://gitee.com/dromara/MilvusPlus
飞龙/feilong https://gitee.com/ifeilong/feilong
aixcoder-model/aixcoder-7b https://gitee.com/aixcoder-model/aixcoder-7b
NEVSTOP-LAB/Communicable-State-Machine https://gitee.com/NEVSTOP-LAB/Communicable-State-Machine
Ascend/MindSpeed https://gitee.com/ascend/MindSpeed
lishanwen/sgl https://gitee.com/li-shan-asked/sgl
OpenGeometry 开源社区/OGG https://gitee.com/opengeometry/OGG
openEuler/compass-ci https://gitee.com/openeuler/compass-ci
codefuse-ai/codefuse-chatbot https://gitee.com/codefuse-ai/codefuse-chatbot
Ascend/ModelLink https://gitee.com/ascend/ModelLink
xgc/JavaVision https://gitee.com/giteeClass/java-vision
平凯星辰(北京)科技有限公司/tikv https://gitee.com/pingcap/tikv
平凯星辰(北京)科技有限公司/tiflash https://gitee.com/pingcap/tiflash
WangChao/PANDASimSD https://gitee.com/zhikaiyici/PANDASimSD
wu-clan/httpfpt https://gitee.com/wu_clan/httpfpt
Vue.js/vue-router https://gitee.com/vuejs/vue-router
Vue.js/vuepress https://gitee.com/vuejs/vuepress
Vue.js/vue https://gitee.com/vuejs/vue
Vue.js/vuefire https://gitee.com/vuejs/vuefire
AvenirTech 未来科技/Chessmate https://gitee.com/onlyyyy/chessmate
Phytium嵌入式软件/Phytium-FreeRTOS-SDK https://gitee.com/phytium_embedded/phytium-free-rtos-sdk
freeeyes/PSS_ASIO https://gitee.com/freeeyes/PSS_ASIO
就眠儀式/Rudis https://gitee.com/Jmysy/rudis
Tele-AI/TeleChat https://gitee.com/Tele-AI/tele-chat
王华/航天算法库AstroLib https://gitee.com/wanghmail/AstroLib
guolong/manci https://gitee.com/guojongg/manci
gzbkey/LingDongGUI https://gitee.com/gzbkey/LingDongGUI

「2.自动化测试(爬取抖音无水印视频下载链接)」

from DrissionPage import ChromiumPage
from DrissionPage import ChromiumOptions
path = r'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' #设置浏览器为Edge
ChromiumOptions().set_browser_path(path).save()
page = ChromiumPage()
page.get('https://v.douyin.com/i2WYE9yu/')
v = page.ele('tag:source')
print(v.link)

「输出」

https://v3-weba.douyinvod.com/70b30efa09669e148c6de125e55b36c3/66606c23/video/tos/cn/tos-cn-ve-15/o0APseplF75EnZpz9bfBF2AQgCDQADaE2l87II/?a=6383&ch=26&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=1098&bt=1098&cs=0&ds=4&ft=GTeMyqDMffPdpK~BY1cNvAq-antLjrKxyBa.Rka_t5laejVhWL6&mime_type=video_mp4&qs=0&rc=Zzw2ZjloNDc6ODQ4OzdoaEBpM3BoaTs6ZnM4cTMzNGkzM0AuLjAxMDJeNTAxY2IyX2EyYSMxZ3NicjRfL2pgLS1kLS9zcw%3D%3D&btag=80000e00008000&cquery=100z_100a_100w_100B_100x&dy_q=1717587964&feature_id=46a7bb47b4fd1280f3d3825bf2b29388&l=20240605194604E0E7D2F216CB94093E2D

「官方文档」

https://drissionpage.cn/

「推荐文档」

https://blog.csdn.net/runsong911/article/details/136221291

最后: 下方这份完整的软件测试视频教程已经整理上传完成,需要的朋友们可以自行领取【保证100%免费】

​​​软件测试面试文档

我们学习必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有字节大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。

在这里插入图片描述

在这里插入图片描述

使用 PlaywrightPython 可以方便地进行自动化测试。以下是一个简单示例,演示如何使用 Playwright 进行浏览器自动化测试: 1. 安装 PlaywrightPython: 在命令行中运行以下命令来安装 PlaywrightPython: ``` pip install playwright ``` 2. 初始化 Playwright: 在命令行中运行以下命令来初始化 Playwright: ``` playwright install ``` 3. 编写测试脚本: 创建一个 Python 脚本,并导入所需的模块和类: ```python from playwright.sync_api import sync_playwright def test_example(): with sync_playwright() as playwright: browser = playwright.chromium.launch() context = browser.new_context() page = context.new_page() # 打开网页 page.goto('https://www.example.com') # 在文本框中输入内容 page.fill('input[name="q"]', 'Playwright') # 点击搜索按钮 page.click('button[type="submit"]') # 等待搜索结果加载完毕 page.wait_for_load_state() # 断言页面标题是否包含关键字 assert 'Playwright' in page.title() # 关闭浏览器 context.close() browser.close() if __name__ == '__main__': test_example() ``` 在上述代码中,我们使用 Playwright 启动 Chromium 浏览器,创建一个新的页面,并在页面上执行一系列操作,包括打开网页、填充文本框、点击按钮、等待加载和断言页面标题。最后关闭浏览器。 4. 运行测试脚本: 在命令行中运行以下命令来执行测试脚本: ``` python test_script.py ``` 这将启动浏览器并执行测试脚本中的操作。如果一切正常,你将看到测试结果输出。 这只是一个简单的示例,Playwright 还提供了更多功能和 API,例如处理表单、截图、模拟用户行为等。你可以查阅 Playwright 的官方文档以了解更多详细信息和示例代码。希望这个示例能帮助你入门 PlaywrightPython 自动化测试
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值