简体   繁体   English

硒中的程序被意外杀死时,如何关闭浏览器?

[英]How can I close the browser when program is killed accidentally in selenium?

I had a test script with Selenium RC . 我在Selenium RC有一个测试脚本。 Now I don't know what could happen during the test but I want the browser to be shut down if the program is killed accidentally. 现在,我不知道测试过程中会发生什么,但是我希望在程序被意外终止的情况下关闭浏览器。 BTW, the script is running in a sub-process. 顺便说一句,脚本正在子进程中运行。

Now I tried method __del__ but it doesn't work and I don't see if there's any exceptions. 现在,我尝试了方法__del__但是它不起作用,并且我看不出是否有任何异常。 So I have no idea where to put try --- except or with --- in . 所以我不知道在哪里try --- exceptwith --- in

If I run the script in main-process it works fine. 如果我在主进程中运行脚本,则可以正常工作。 Any help? 有什么帮助吗?

Version of Selenium is 2.33. Selenium版本是2.33。 Browser is Firefox 21.0 浏览器是Firefox 21.0

make the del method return boolean. 使del方法返回布尔值。 True on success, false otherwise. 成功则为真,否则为假。

If it returns false, close the driver in main. 如果返回false,请关闭main中的驱动程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM