如何使用 rb-appscript 驱动 Mac OS Finder 的“连接到服务器”功能菜单项

发布于 2024-12-23 00:53:28 字数 547 浏览 5 评论 0原文

最终目标是用 Ruby/Cucumber 编写一个自动化测试,用于连接到 WebDAV 服务器并测试 Mac OS X 中的身份验证、CRUD 和负载/性能。

我试图尽可能地模拟用户行为,这就是为什么我'我正在查看 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

有什么想法吗?

The end goal is to write an automated test in Ruby/Cucumber for connecting to a WebDAV server and testing authentication, CRUD and load/performance in Mac OS X.

I'm trying to simulate user behavior as much as possible which is why I'm looking at rb-appscript, but I'm open to other ideas.

I initially tried this:

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

but that just opens your default browser. I'm guessing open_location just uses Mac OS' default app based on protocol or extention.

I also tried to simulate a Finder Keyboard shortcut for "Connect to Server...", but that didn't work either:

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

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反目相谮 2024-12-30 00:53:28

您的第二个解决方案应该可以正常工作,但请将“连接到服务器...”替换为“连接到服务器...”。这是省略号字符(选项-;),而不是连续的三个句点。

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

Your second solution should work just fine, but replace the "Connect to Server..." with "Connect to Server…". That's the ellipsis character (option-;), not three periods in a row.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文