2011-12-28 29 views
0

最終目標是在Ruby/Cucumber中編寫自動化測試,以連接到WebDAV服務器並測試驗證,CRUD和加載/性能在Mac OS X.如何使用rb-appscript驅動Mac OS Finder的「連接到服務器」菜單項

我想盡可能模擬用戶行爲,這就是爲什麼我在看rb-appscript,但我打開其他想法。

我最初嘗試這樣的:

app("Finder").open_location("http://example.com/dav") 

但只開啓默認瀏覽器。我猜open_location只是基於協議或擴展使用Mac OS的默認應用程序。

我也試圖以模擬「連接到服務器...」一個Finder鍵盤快捷鍵,但沒有工作,要麼:

app("System Events").processes["Finder"].menu_bars[1].menu_bar_items["Go"].menus["Go"].menu_items["Connect to Server..."].click 

任何想法?

回答

1

您的第二個解決方案應該可以正常工作,但用「連接到服務器...」替換「連接到服務器...」。這是省略號字符(option-;),而不是連續三個句點。

require 'appscript' 

include Appscript 

app('Finder').activate 

# This is a slightly terser way of doing it :) 
# app('System Events').processes['Finder'].menu_bars[1].menus['Go'].menu_items['Connect to Server…'].click 

app("System Events").processes["Finder"].menu_bars[1].menu_bar_items["Go"].menus["Go"].menu_items["Connect to Server…"].click 
相關問題