Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I have googled for the answer, but the ".stop()" so frequently mentioned doesn't work for me. The Chrome window the test was running in remains open.

def test_getResults(self):
    sel = selenium('localhost', 4444, "*chrome", 'http://blackpearl/')
    sel.start()
    # do stuff

def tearDown(self):
    sel = selenium('localhost', 4444, "*chrome", 'http://blackpearl/')
    sel.close()
    sel.stop()

Any ideas? I'm using Selenium Server 2.8.0 with Python 2.6 and mostly using Chrome 14 windows to test.

Thanks.

share|improve this question
    
Is there a quit method? –  user246 Oct 11 '11 at 22:21
    
Yes there is - browser.quit(); Although when I used to run these types of tests before switching to WebDriver I used to have in my TearDown - self.selenium.stop() That usually did it for me. –  MichaelF Oct 12 '11 at 13:15
    
Okay. I will try .quit(). I found that .stop() will stop the server, but not close the window. –  Aaron Oct 12 '11 at 17:30
    
.quit() did not work –  Aaron Oct 12 '11 at 17:37
1  
I verified in C# that webdriver.Quit() closes a firefox window, I didn't try it with a chrome driver. –  Sam Woods Oct 12 '11 at 23:52

4 Answers 4

driver.close(); or driver.quit();

At here , i only know close() is for one browser to close and quit() is to close all browser using webdriver. But Why close() is not closed at runtime and it is closed at debugging.I don't know that point.so can you explain me?

share|improve this answer
    
Your answer is weak (because you don't give much other information) and doesn't add much to the question and existing answers. You also asked a different question which really should be posted as a separate question (with a lot more information) –  Kate Paulk Jun 4 at 10:58

Using TestNG and Java. Assume this method is located in some BaseTest class which is inherited by test class, so

@AfterClass(alwaysRun = true) protected void tearDown() { driver.quit(); driver = null; }

share|improve this answer
    
why the last command? driver=null; –  Yash Apr 30 at 6:39
    
I use it in scope init driver logic, like if null then new driver instance is being creating. That command is optional however. –  user1829657 May 5 at 11:56

I have worked with Web Driver in both java and C# and I use

In Java :

WebDriver driver;      
driver.quit();

In C# :

IWebDriver Driver;
Driver.Quit();
share|improve this answer

You're actually creating a second Selenium session in your tearDown() function. You need to put the session created in setUp() into an instance variable, then close that session in tearDown().

class TestFoo(unittest.TestCase):
    def setUp(self):
        self.selenium = selenium('localhost', 4444, "*chrome", 'http://blackpearl/')
        self.selenium.start()

    def tearDown(self):
        self.selenium.stop()

    def test_bar(self):
        self.selenium.open("/somepage")
        #and so forth
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.