简体   繁体   中英

Selenium Firefox Webdriver sometimes not closing

my problem is that sometimes when I am testing a website, the FF webdriver is not closing the Browser Window after the test, although it continues the testing process until there are so many windows open that there is no memory left. I have tried using driver.close() and driver.quit(), as well as both of them, but SOMETIMES they just do not seem to work. Is there a way to force the driver to quit? I looked into killing the process but I can't seem to get the PIDs of the started Webdrivers... Am I the only one who has encountered this problem yet?

Well, I am not sure how your code looks like (since you didn't provide it) but usuall flow for this kind of test is to have class with following methods.

public class TestClass {

     private WebDriver driver;

     @BeforeClass
     public void setUp() {
         driver = new FirefoxDriver(); //or any other one
     }

     @Test
     public void test1() {}

     @Test
     public void test2() {}

     @AfterClass
     public void tearDown() {
         driver.quit();
     }
}

Note that you don't have to call WebDriver#close or WebDriver#quit in the test methods, you can just reuse the browser session during testing.

You need to call driver.quit() in the framework tearDown for each testCase , just as you should assign it in the framework setUp for each testCase. Have a look here http://siking.wordpress.com/2013/02/28/what-is-wrong-with-groovytestcase-and-selenium/ which somewhat describes your problem.

I got Firefox to work with driver.quit(). What I did was uninstall my current version and downloaded an older version of Firefox from this directory that Modzilla keeps public: https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/

The version I downloaded was “Firefox Setup 27.0.exe” from here: https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/27.0/win32/en-US/

Everything worked after that.


Before I switched Firefox versions, I used Firefox browser to download Selenium IDE from here: http://www.seleniumhq.org/download/ 在此处输入图片说明

Selenium IDE is a Firefox Plugin.

What I think was happening was this= When I had Firefox version 32 (newest version) and I looked in the “Extensions” options, the Selenium IDE wouldn't show up. Now that I have Firefox version 27, the Selenium IDE shows up and it looks like this: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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