我正在尝试使用IE11自动化来自动化通知栏(同时下载文件)。使用MSUIA适配器,我能够捕获保存按钮。但是我想使用Save来提供文件的位置和名称。但我不能这么做。
当看到UIspy时,我看到有一个名为"Save“的拆分按钮。这个拆分按钮有另一个名为"“(基本上是向下箭头)的子拆分按钮--我无法到达这个控件。
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是相同的)--如何捕获菜单项--另存为?
发布于 2014-08-25 04:33:16
问题
不幸的是,用于:ms_uia的RAutomation适配器无法以其当前的形式执行此操作。我之所以知道这一点,是因为我已经为它编写了许多UIA适配器:)问题是,当前的API不允许您真正像这样遍历树(正如您发现的那样),因为Control类没有#control方法。如果"Save“按钮有一个本机窗口句柄,则可以这样做:
ieframe = RAutomation::Window.new(class: 'IEFrame')
save = RAutomation::Window.new(hwnd: ieframe.control(value: 'Save').hwnd)
save.control(index: 0)由于它没有,不幸的是,没有一个可靠的方法来深入到它,我知道,因为它没有任何标识属性(除了作为“保存”按钮的子类)。
替代方案
我已经将写另一块宝石称为uia,它充当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).invokesave_as.as(:invoke)将把找到的“另存为”Element视为实现Invoke模式的东西,然后可以调用#invoke方法以使菜单弹出。
希望这能有所帮助!
https://stackoverflow.com/questions/25080375
复制相似问题