解决Python调试OSError: [WinError 193] %1 不是有效的 Win32 应用程序
2023-09-11 14:15:55 时间
今天在练习selenium运行后报错 ,网上找了很多方法,最终终于解决。
我的问题是 chromeDriver驱动不匹配。
解决步骤1:先打开谷歌浏览器查看我们的浏览器版本,在打开以下网址下载对应的 chromeDriver版本 ,https://chromedriver.storage.googleapis.com/index.html;
讲下载后的chromedriver.exe放到 python 安装包目录的\Python38\Scripts 下面
重新运行程序,打开浏览器正常,报错消失。
查看版本方法
下载浏览器对应的驱动版本
解压后保存目录
# coding=utf-8
'''
Author:
Email:
Version: V1.0.0
Date: 2022/9/19
Desc:
'''
import pytest
import allure
import time
from selenium import webdriver
import os
from os.path import dirname
@allure.testcase("https://www.baidu.com的搜索功能")
@pytest.mark.parametrize('test_data1', ['allure', 'pytest', 'unittest'])
def test_steps_demo(test_data1):
with allure.step('step one:打开浏览器'):
a = dirname(dirname(__file__)) +os.sep+ '/driver/chromedriver'
print(a)
# driver = webdriver.Chrome(executable_path='C:\\Users\\user\\PycharmProjects\\testframework\\frameworkDemo\\driver\\chromedriver')
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
with allure.step('step two:在搜索栏输入allure,并点击百度一下'):
driver.find_element('id', 'kw').send_keys(test_data1)
time.sleep(1)
driver.find_element('id', 'su').click()
time.sleep(1)
with allure.step('step three:截图保存到项目中'):
driver.save_screenshot('./result/b.png')
allure.attach.file("./result/b.png", attachment_type=allure.attachment_type.PNG)
allure.attach('<head></head><body> 首页</body>', 'Attach with HTML type', allure.attachment_type.HTML)
with allure.step('step four:关闭浏览器'):
driver.quit()
if __name__ == '__main__':
pytest.main(['--alluredir=./report/', 'test_allure_screen.py'])
os.system('allure serve ./report')
运行后allure显示效果
现在我邀请你进入我们的软件测试学习交流群:【
746506216
】,备注“入群”, 大家可以一起探讨交流软件测试,共同学习软件测试技术、面试等软件测试方方面面,还会有免费直播课,收获更多测试技巧,我们一起进阶Python自动化测试/测试开发,走向高薪之路。
喜欢软件测试的小伙伴们,如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一 键三连哦!
相关文章
- 【Python】ValueError: unsupported pickle protocol: 5解决方案/同一个项目 python环境尽量保持一致
- 【华为OD机试真题 python】按索引范围翻转文章片段【2022 Q4 | 100分】
- [好课推荐]数据结构与算法python实现
- 地球引擎初级教程——Python API 语法(内涵JavaScript转python工具包介绍)
- Python怎么就火起来了?学会python可以做的兼职
- 零基础教你快速入门Python怎么学python入门?python新手学习路线
- 35岁了转行python可以吗?什么样的人合适学习Python?
- 每天一个python小知识——如何在Python 3中转换数据类型
- 【python实战】拒绝黄牛!我要用python原价冲周董演唱会~Python自动秒杀抢票脚本
- Python中python-nmap模块的使用
- gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.
- Python 迭代器 & __iter__方法
- 《Python和Pygame游戏开发指南》——1.5 Ubuntu和Linux上的安装说明
- python学习之OpenCV-Python模块的部分应用示例(生成素描图和动漫图)
- 基于 C++和 Python 实现计算机视觉Final Project【100010472】
- Python基础必掌握的集合Set使用
- Python高级架构模式的整理
- Python 实现被动收入教程之我如何使用 python 制作我的第一个高级telegram机器人
- python error: TypeError: cannot serialize '_io.TextIOWrapper' object
- Python 基础 之 python 中 进程、线程、协程对比 区别和联系
- 【Linux】linux下用python获取底层硬件信息接口