2012-03-06 84 views
0

是否可以創建tmp文件夾webdriver-profile20120306-5313-a3chgu即時通訊特定的文件夾?Watir-webdriver清潔tmp文件

或者在關閉瀏覽器時點亮?

坦克

+0

我看到一個clear_cookies,但沒有其他臨時文件。也許clear_cookies包含其他臨時文件。如果沒有,也許Ruby可以直接做到這一點。 – 2012-03-06 17:48:09

+0

但我不知道它創建的女巫文件夾,所以我不能刪除然後。 – macwadu 2012-03-06 20:29:55

+0

這可能是在webdriver級別下降。添加webdriver標籤。 – 2012-03-07 22:03:58

回答

0

我想這是對Firefox(因爲我沒有看到Chrome或IE瀏覽器中創建該文件夾)?

如果是這樣,的Watir-webdriver的自動刪除當您運行的臨時文件夾:

browser.close() 

如下面的測試可見,一個配置文件目錄中打開火狐後存在和關閉火狐後沒有存在。

temp_dir = 'C:/Documents and Settings/Setup/Local Settings/Temp/' 

browser = Watir::Browser.new :firefox 

temp_profiles = Dir.entries(temp_dir).select {|entry| entry =~ /webdriver-profile/} 
puts temp_profiles.length # => 1 

browser.close 

temp_profiles = Dir.entries(temp_dir).select {|entry| entry =~ /webdriver-profile/} 
puts temp_profiles.length # => 0 

這是否適合您或您想要/需要手動關閉瀏覽器?