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
show 4 more comments

2 Answers

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
add comment

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
add comment

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.