Python Firefox Webdriver tmp files
Asked Answered
C

1

11

My python application loads webpages using Selenium Webdriver for a total of 20000 pages more or less in several hours of work. My problem is that "something" is creating a lot of tmp files, filling all my hard drive. For example, this morning the application generates 70GB of tmp files in 6 hours of work :( after rebooting Ubuntu, all these files are gone. I think the responsible is Firefox.

This situation happens both on Linux and OS X.

def launchSelenium (url):
    profile = webdriver.FirefoxProfile()
    profile.set_preference("network.proxy.type", 1)
    profile.set_preference("network.proxy.http", "127.0.0.1")
    profile.set_preference("network.proxy.http_port", 8080)
    profile.set_preference("webdriver.load.strategy", "fast")
    profile.set_preference("permissions.default.stylesheet", 2)
    profile.set_preference("permissions.default.images", 2)
    profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so", "false")
    profile.set_preference("browser.sessionstore.enabled", "false")
    profile.set_preference("browser.cache.disk.enable", "false")
    profile.update_preferences()

    driver = webdriver.Firefox(firefox_profile=profile)

    driver.get(url)
    try:
        element = driver.find_element_by_xpath("//button[@title='Statistics']").click()
    except NoSuchElementException:
        print "Not available"
        driver.close()
        return 0
    driver.close()
    return 1

I added the last two preferences in Firefox Profile trying to solve this problem but nothing changed.

Am I doing something wrong? There's a bug in Selenium? Thanks

Commission answered 31/8, 2013 at 14:16 Comment(0)
C
23

Ok, the solution to the problem is to substitute:

driver.close()

with:

driver.quit()

Bye

Commission answered 3/9, 2013 at 5:26 Comment(1)
You just fixed a problem that has taken me two days to isolateSanbenito

© 2022 - 2024 — McMap. All rights reserved.