2017-06-22 98 views
1

我正在關注This以在MVC應用程序中獲取網站的動態內容。Phantomjs緩存問題

我接收到的數據一次或兩次,但在那之後,我得到一個錯誤 -

ApplicationCache driver.ApplicationCache扔 類型的異常「System.InvalidOperationException」 OpenQA.Selenium.Html5 .IApplicationCache {System.InvalidOperationException} 消息: 驅動程序不支持操縱HTML5應用程序緩存。使用HasApplicationCache屬性測試爲駕駛能力

回答

0

,你遇到的錯誤是由於這樣的事實,PhantomJS找不到在appCache任何東西,因此引發此異常。請參閱下面的代碼here,其中規定

public IApplicationCache ApplicationCache 
    { 
     get 
     { 
      if (this.appCache == null) 
      { 
       throw new InvalidOperationException("Driver does not support manipulating the HTML5 application cache. Use the HasApplicationCache property to test for the driver capability"); 
      } 

      return this.appCache; 
     } 
    } 

其原因,爲什麼這個即將成爲null是當前PhantomJS不支持此應用程序緩存。 PhantomJS代碼中的默認功能設置爲false。你可以看到這here,其中提到

_defaultCapabilities{ 
     "applicationCacheEnabled" : false, 
}