我正在尝试使用Rautomation自动化IE11通知栏(在下载文件时)。使用MSUIA适配器我能够捕获保存按钮。但我想使用“另存为”来提供文件位置和名称。但我不能这样做。
当看到UIspy时,我发现有一个名为""的分割按钮。这个splitbutton有另一个名为""的子拆分按钮。 (这基本上是向下箭头) - 我无法达到此控制。
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相关的菜单和menuitems,当我点击Save之外的向下箭头时,在UISpy我看到菜单/菜单项是直接在桌面窗口下创建的(尽管processID相同) - 如何捕捉menuitem另存为?
答案 0 :(得分:0)
不幸的是,:ms_uia
的{{1}}适配器无法以当前形式执行此操作。我知道这是因为我已经为它写了很多UIA适配器:)问题是当前的API不允许你像那样(正如你发现的那样)真正地走树,因为RAutomation
类没有Control
方法。如果“保存”按钮具有本机窗口句柄,您将能够执行此操作:
#control
因为它没有,遗憾的是没有一种可靠的方式来了解我所知道的,因为它没有任何关于它的识别属性(除了是“保存”按钮的孩子)
我written another gem调用了ieframe = RAutomation::Window.new(class: 'IEFrame')
save = RAutomation::Window.new(hwnd: ieframe.control(value: 'Save').hwnd)
save.control(index: 0)
,它充当了UI自动化的低级包装器,允许您与UI自动化更紧密地合作,并与您进行交互,如何在工具中看到它UI间谍。最终,我会在uia
使用这个宝石,但还没有时间。要在您的环境中使用“另存为...”分割按钮控件,您可以执行以下操作:
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
方法获取菜单流行。
希望这有帮助!