diff --git a/README.md b/README.md index b206dba..1d4984e 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,13 @@ If you're using capybara-webkit with Sinatra, don't forget to set Capybara.app = MySinatraApp.new ``` +Offline Application Cache +------------------------- + +The offline application cache needs a directory to write to for the cached files. Capybara-webkit +will look at if the working directory has a tmp directory and when it exists offline application +cache will be enabled. + Non-Standard Driver Methods --------------------------- diff --git a/src/WebPage.cpp b/src/WebPage.cpp index 7dd4e11..b506423 100644 --- a/src/WebPage.cpp +++ b/src/WebPage.cpp @@ -40,8 +40,11 @@ WebPage::WebPage(WebPageManager *manager, QObject *parent) : QWebPage(parent) { settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); settings()->setAttribute(QWebSettings::JavascriptCanCloseWindows, true); settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); - settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); - settings()->setOfflineWebApplicationCachePath("tmp"); + + if(QFileInfo("tmp").isDir()) { + settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); + settings()->setOfflineWebApplicationCachePath("tmp"); + } createWindow(); }