Selenium里WebDriver中窗口的close()与quit()

本文详细解释了WebDriver中的三个关键方法:Close、Quit与Dispose的作用及区别。Close用于关闭当前焦点所在的浏览器窗口;Quit则关闭所有关联窗口并结束浏览器会话;Dispose同样关闭所有窗口并安全地结束整个会话。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查了一下网上的webdreiver 的 api,才发现,

quit()详细信息:  “Quits this driver, closing every associated window”,执行这个方法后,driver会关闭所有关联窗口。

close()详细信息:Close the current window, quitting the browser if it's the last window currently open  ,此方法是关闭当前窗口,或最后打开的窗口。



1. webDriver.Close() - Close the browser window that the driver has focus of //关闭当前焦点所在的窗口
2. webDriver.Quit() - Calls dispose //调用dispose方法
3. webDriver.Dispose() Closes all browser windows and safely ends the session 关闭所有窗口,并且安全关闭session

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值