關於GhostDriver的Cookie隔離問題
GhostDriver包括了Java驅動phantomjsdriver,PhantomJS WebDriver,詳細的不再贅述。看上一片文章。
Java用phantomjsdriver時,碰到需要Cookie隔離問題,同一個網頁,多個RemoteWebDriver會共享同一個Cookie。比如想要並行登陸並執行操作,這樣是不行的。PhantomJS WebDriver其實內部就起了一個PhantomJS的進程。而PhantomJS模擬的是真實的瀏覽器。
這個問題GhostDriver開發人員也在解決,在Ghostdriver 1.1.1上添加了這個功能。並且PhantomJS也得添加支持,在PhantomJS 1.9.6,已經包含了Ghostdriver 1.1.1。詳見討論:here, there
按照我自己的測試,最新版本phantomjsdriver 1.2.0只與PhantomJS 1.9.2適配成功。
所以目前只能用PhantomJS 1.9.2,使用PhantomJSDriver來創建PhantomJS進程