2017-09-26 56 views
2

啓動Chrome時,可以在Watir Webdriver中使用當前保存的Cookie嗎?在Watir Webdriver中使用當前保存的Cookie

我在登錄Facebook時將我的Chrome設置爲「記住我」,以便下次訪問Facebook時,我不必再次輸入用戶名和密碼。 但是,當使用watir webdriver時,Chrome會像新會話一樣打開它,並且像第一次訪問Facebook那樣需要我再次輸入用戶名和密碼。我預計它會直接打開Facebook,而無需再次通過登錄頁面。 有沒有辦法做到這一點?

非常感謝。

回答

2

您需要爲Chrome創建一個custom profile,根據需要調整其設置,然後指定Watir通過設置Chrome switches來使用它。

args = ['--user-data-dir=/path/to/your/custom/profile'] 
Watir::Browser.new :chrome, options: {args: args} 
+0

非常感謝 – FMD