0

我正在尝试使用 Rautomation 自动化 IE11 通知栏(下载文件时)。使用 MSUIA 适配器,我能够捕捉到保存按钮。但我想使用另存为来提供文件位置和名称。但我不能那样做。

当使用 UIspy 看到时,我看到有一个名为“保存”的拆分按钮。此拆分按钮有另一个名为“”的子拆分按钮(基本上是向下箭头)-我无法访问此控件。

iemainwindow_local = RAutomation::Window.new(:class=>"IEFrame" , :adapter => :ms_uia )
ienotificationbar_frame = iemainwindow_local.child(:class=>"Frame Notification Bar")
ienotificationbar = ienotificationbar_frame.child(:class=>"DirectUIHWND")
if ienotificationbar.exists?
  ienotificationbar.activate
  sleep 1
  mycontrol = ienotificationbar.control(:value =>"Save")
  mycontrol2= mycontrol.control(:children_only => true) 
  mycontrol2.exist?
  mycontrol.click
end

在这一行出现错误 mycontrol2= mycontrol.control(:children_only => true)

undefined method `control' for #<RAutomation::Adapter::MsUia::Control:0x4108e60>

知道如何克服这个障碍吗?

我知道应该有一个与 splitButton 关联的菜单和菜单项,当我单击保存之外的向下箭头时,在 UISpy 我看到菜单/菜单项直接在桌面窗口下创建(尽管 processID 相同) - 如何抓住菜单项另存为?

4

1 回答 1

0

问题

不幸的是,:ms_uia适配器RAutomation无法以当前形式执行此操作。我知道这一点,因为我已经为它编写了很多 UIA 适配器 :) 问题是当前的 API 不允许你真正像那样走树(正如你发现的那样),因为Control该类没有#control方法。如果“保存”按钮有一个本地窗口句柄,你可以这样做:

ieframe = RAutomation::Window.new(class: 'IEFrame')
save = RAutomation::Window.new(hwnd: ieframe.control(value: 'Save').hwnd)
save.control(index: 0)

因为它没有,不幸的是,我知道没有可靠的方法来解决它,因为它没有任何关于它的识别属性(除了作为“保存”按钮的子项)。

选择

我编写了另一个名为的gemuia,它充当 UI 自动化的低级包装器,允许您更紧密地使用 UI 自动化并与它进行交互,如您在 UI Spy 等工具中看到它的方式。最终,我将使用这个宝石,RAutomation但还没有时间。要在您的情况下使用“另存为...”拆分按钮控件,您可以执行以下操作:

ieframe = UIA.find_element(title: /Thanks for downloading/)
save_as = ieframe.find(name: 'Save').find(control_type: :split_button)
save_as.as(:invoke).invoke

save_as.as(:invoke)会将找到的“另存为”视为Element实现该Invoke模式的内容,然后您可以调用该#invoke方法以弹出菜单。

希望这可以帮助!

于 2014-08-25T04:33:16.597 回答