1

目标

我正在使用 Frank 和 Cucumber 来测试一个应用程序,我的目标是让它尽可能自动化。其中一部分是在我重置模拟器后重新打开辅助功能检查器。

细节

要重置模拟器,我使用 core_frank_steps.rb 文件中的步骤(第 258-260 行):

When /^I reset the simulator/ do
  simulator_reset_data
end

Accessibility Inspector 可以在 Settings > General > Accessibility 中找到,并且是模拟器中该页面上的唯一开关

问题

基本上,在我重置模拟器后,我可以编写一个脚本或其他东西来让 Accessibility Inspector 重新打开吗?我更喜欢 ruby​​,因为我所有的其他步骤都是用 ruby​​ 编写的

谢谢

4

2 回答 2

1

I am not sure what purpose can Accessibility Inspector have in your automation but here is my answer.

Ruby cannot manipulate "iPhone Simulator" directly, every action (e.g. "Reset") is performed using Apple Script. Apple Script simulates user clicks on the menus.

For some examples, go to Frank HostScripting module source

Modifying the menu indices in

def simulator_reset_data
  %x{osascript<<APPLESCRIPT
activate application "iPhone Simulator"
tell application "System Events"
  click menu item 5 of menu 1 of menu bar item 2 of menu bar 1 of process "#{Localize.t(:iphone_simulator)}"
  delay 0.5
  click button 2 of window 1 of process "#{Localize.t(:iphone_simulator)}"
end tell
  APPLESCRIPT} 
end

should give you the required result (the delay and the 2nd click line can be removed, they handle the "reset" confimation dialog).

于 2013-08-18T11:51:44.070 回答
0

可能是您使用 I18n 翻译,您需要将 I18n 代码复制到您的 localize.yml 文件 在此处输入链接以修复它

于 2014-04-08T01:42:54.420 回答