如何从而失去硒RC服务器上关闭浏览器,它的客户 [英] How to close a browser on a selenium RC server which lost it's client
问题描述
假设一个客户端启动一个RC服务器上的硒会议,但在会议中间的客户端走了。该浏览器将保持开放,最终,经过这样够下降会议,将有足够的孤儿的浏览器到计算机运行速度减慢。
suppose a client starts a selenium session on an RC server, but at the middle of the session the client "went away". The browser will remain open, and eventually, after enough such dropped sessions, there will be enough "orphan" browsers to slow down the computer.
推荐答案
任何浏览器实例具有可以存储一个SESSION_ID。 Python的例子:
Any browser instance has a session_id you can store. Python example:
>>> import selenium
>>> browser = selenium.selenium("localhost",4444, "*firefox", "http://www.santiycr.com.ar")
>>> browser.start()
>>> browser.sessionId
u'b4ad1f1d624e44d9af4200b26d7375cc'
所以,如果你存储这些中的sessionId一个文件时,你的测试开始,然后删除它,当你的测试结束后,你必须与该最终没有正确的测试会话日志文件。
So, if you store these sessionId in a file when your test starts and then remove it when your tests ends, you'll have a log file with sessions for tests that didn't end up properly.
现在使用cron的,或任何常规的执行,可以读取该文件,遍历存储在其中的sessionIds并打开以下网址(使用浏览器,甚至是HTTP库为您的编程语言):
Now using cron, or any regular execution, you can read that file, iterate over the sessionIds stored in it and open the following url (using a browser or even an http library for your programing language):
<一个href=\"http://localhost:4444/selenium-server/driver/?sessionId=THE-SESSION-ID&cmd=testComplete\">http://localhost:4444/selenium-server/driver/?sessionId=THE-SESSION-ID&cmd=testComplete
这是应该做的伎俩。
编辑:我发现这个问题太有趣了,我在有关解决方案的博客创建的信息。如果你是一个Python的家伙,你会发现很有趣:
<一href=\"http://www.santiycr.com.ar/djangosite/blog/posts/2009/aug/25/close-remaining-browsers-from-selenium-rc\">http://www.santiycr.com.ar/djangosite/blog/posts/2009/aug/25/close-remaining-browsers-from-selenium-rc
I found this question so interesting that created a post in my blog about the solution. If you're a python guy you'll find it interesting: http://www.santiycr.com.ar/djangosite/blog/posts/2009/aug/25/close-remaining-browsers-from-selenium-rc
这篇关于如何从而失去硒RC服务器上关闭浏览器,它的客户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!