当前位置:网站首页>根据进程名一键批量结束进程(chromedriver.exe)
根据进程名一键批量结束进程(chromedriver.exe)
2022-07-21 05:20:00 【embracestar】
场景介绍
在使用python+selenium+chrome进行自动化测试期间,每次程序出现错误意外终止或者忘记添加driver.quit()都会在电脑后台中驻留一个chromedriver.exe进程,长期下来会驻留一堆进程占用计算机资源,逐个结束进程非常麻烦。
在Windows系统上可以使用命令来一键批量结束进程。值得一提的是,最规范的做法是将可能出现错误的代码放在try块中,并且养成添加driver.quit()的习惯。
方案一
以管理员身份打开电脑的cmd,输入以下指令结束进程,/F表示强制结束进程,/IM表示根据进程名结束进程。
TASKKILL /F /IM chromedriver.exe
方案二
创建一个文本文件,可以命名为“批量结束chromedriver进程.txt”,在里面输入上述指令,最后将后缀名修改为bat,以管理员身份运行该批处理程序即可。(这里输入了pause指令来阻止窗口的退出)
方案三
创建一个py文件,可以命名为“批量结束chromedriver进程.py”,在里面输入以下代码,直接在python中运行cmd指令。
import os
if __name__ == '__main__':
command = 'TASKKILL /F /IM chromedriver.exe'
os.system(command)
输出的乱码是由于Pycharm的输出编码和cmd的输出编码不同导致的,这个问题建议直接忽略,不要去修改默认的输出编码格式。
边栏推荐
- ms17_010 入侵Win7
- Understanding of timer bidirectional break inputs based on stm32h7x3 series
- Oracle数据库存储实验管理
- postman的body中报“Expected ‘,‘instead of ‘p‘”的解决方法
- After modifying the IP address, use ifconfig on the terminal to check that the IP address is not updated
- 遵守指南,快速提升自己:功能测试如何快速转向自动化测试
- 从字符串中提取数字
- 写入文件的有关问题与链表指针
- C语言运用函数七大极易忽略的结论
- 10061 unknown error error is reported when connecting to the previously available MySQL database
猜你喜欢
004_ SSSS_ Image-to-Image Translation with Conditional Adversarial Networks
2021-06-22
How do you understand automated testing? Understand the purpose and essence of automated testing
遵守指南,快速提升自己:功能测试如何快速转向自动化测试
写入文件的有关问题与链表指针
测试用例练习2-厂商账户信息
006_ SS_ Dual Diffusion Implicit Bridges For Image-to-Image Translation
ms17_010 入侵Win7
Application test of timer bidirectional break inputs based on stm32g4 series
实现页面与页面之间的信息交换
随机推荐
测试用例管理工具推荐
sysstat安装并升级到11.5.5版本
006_ SS_ Dual Diffusion Implicit Bridges For Image-to-Image Translation
How to transition from business testing to test development?
支付系统测试
loadrunner清除浏览器缓存
对于依赖第三方的接口如何进行测试?
视图2
编写简单有序链表的创建和查询修改
APP 注册功能,用例怎么写 ?
测试用例练习2-厂商账户信息
jmeter脚本生成基于rap2
Day01 软件测试基础总结
Exploratory software testing
jmeter
MySQL classic interview questions 14
2021-06-22
【小技巧】在当前目录下快速弹出cmd窗口且路径为当前路径的方法
[semiconductor advanced process technology series] HKMG process technology (Part 2)
整数变换问题