selenium-google-code-issue-archive icon indicating copy to clipboard operation
selenium-google-code-issue-archive copied to clipboard

IDE never closes browsers or quits driver instances

Open lukeis opened this issue 9 years ago • 3 comments

Originally reported on Google Code with ID 8022

What steps will reproduce the problem?
1. Use the new option for webdriver playback in Selenium IDE
2. Run a test suite
3. Each test case opens a new browser window and starts another instance of the driver

What is the expected output? What do you see instead?

I'd expect that if each test case is going to create a new instance of the driver and
open a new browser window, that at the end of the test case the driver would quit and
the window would close. The way it is now, when I run a test suite with 40 test cases
in it, I'll end up with 40 open windows and 40 processes for the driver instances running.
This ends up making my tests fail with weird glitches, probably from having too many
instances of the driver running.

Reported by matthewkastor on 2014-10-11 16:45:35

lukeis avatar Mar 04 '16 09:03 lukeis

I've made some changes to the current release (2.8.0) so that it will close the browser
windows and kill the session after tests complete.

In the extension I've edited two files:
\chrome\content\selenium-runner.js
and 
\chrome\content\webdriver-backed-selenium.js

In webdriver-backed-selenium.js I've added a method at line 247 called "killWebdriverSession"
that will send a DELETE request to the server against the session id of the current
running test. This causes the driver instance to terminate and the window to close.
The standalone selenium server continues to run so more tests can be performed and
drivers can be instantiated. The code follows

WebdriverBackedSelenium.prototype.killWebdriverSession = function() { // DELETE /session/:sessionId var contentType = {'Content-Type': 'application/json; charset=utf-8'}; var url = 'session/:sessionId'; if (this.webdriverSID) { url = url.replace(':sessionId', this.webdriverSID); } HTTP.request('DELETE', 'http://localhost:4444/wd/hub/' + url, null, contentType, function() {}); };


In selenium-runner.js I've altered the constructor for IDETestLoop, at line 276, so
that the testComplete method now calls the new method I added to the other file. When
the test completes, the session will be destroyed, which causes the browser window
that was opened to be closed as well. So, there won't be any extra processes left running
or browser windows scattered all over.


testComplete: function() { LOG.info("Execute using web driver = " + executeUsingWebDriver); if (executeUsingWebDriver) { selenium.killWebdriverSession(); } LOG.debug("testComplete: failed=" + testCase.debugContext.failed); currentTest = null; //editor.setState(null); //editor.view.rowUpdated(testCase.debugContext.debugIndex); var failed = testCase.debugContext.failed; testCase.debugContext.reset(); if (this.handler && this.handler.testComplete) this.handler.testComplete(failed); },



I don't know a lot about how the IDE works internally, I saw some variable related
to closing or stopping that I have no idea if I should be setting. I also don't know
if there are cases where the testComplete method might not be called after the driver
instance is created. At any rate, it seems to be working whether a test passes or fails.
So, unless there's a way to crash the IDE during a test, it should always close the
sessions generated during webdriver playback in Selenium IDE.

Attaching copies of the altered files.

Reported by matthewkastor on 2014-10-12 21:05:25


- _Attachment: [selenium-runner.js](https://storage.googleapis.com/google-code-attachments/selenium/issue-8022/comment-1/selenium-runner.js)_ - _Attachment: [webdriver-backed-selenium.js](https://storage.googleapis.com/google-code-attachments/selenium/issue-8022/comment-1/webdriver-backed-selenium.js)_

lukeis avatar Mar 04 '16 09:03 lukeis

Reported by barancev on 2014-10-13 13:57:30

  • Labels added: Component-IDE

lukeis avatar Mar 04 '16 09:03 lukeis

Reported by luke.semerau on 2015-09-17 17:47:06

  • Labels added: Restrict-AddIssueComment-Commit

lukeis avatar Mar 04 '16 09:03 lukeis