northwoodspd / uia

A ruby gem for interacting with automation elements in Windows
MIT License
17 stars 4 forks source link

Commands does not return while interacting with Acrobat Reader elements #9

Open Pramanth opened 8 years ago

Pramanth commented 8 years ago

Thank you for developing this wrapper which is simple and easy to use :)

Since our application has few elements integrated with Acrobat Reader was trying to automate the same using "uia"(v 0.6) but after executing the commands nothing gets returned and execution hangs. Please is it possible to provide some pointers to resolve the issue.

ar = Uia.find_element title: /Adobe Reader/i ar.find(:name => "Attachments").click

Was able to interact with Acrobat Reader menus using "send_keys".

Even tried the other wrapper "RAutomation" where you have contributed but same issue identified.

leviwilson commented 8 years ago

Do you have any UI Automation inspection tools (like Inspect or UIAutomation Verify?

The first step in troubleshooting that I normally do is to open up one of those applications to inspect what the elements within the application are exposing.

If you can see what you're trying to get to in that tree, then you want to see what kind of interfaces the element says that it exposes. From there it's easier to determine how you'll be able to interact.

Can you find the element you're trying to interact with in one of those tools and let me know what kind of information it says about it?

Pramanth commented 8 years ago

Thanks for your valuable reply.

Yes I am using UISpy tool to inspect elements and below is the properties of the element with which I am trying to interact.

Here class name of the elements is NULL is it the problem.

Window Properties:

image

image

image

Any command trying to interact with above elements does not return. Ex: ar.find(:name => "Attachments").click ar.find(:name => "Files").click ar.find(:name => "Files").visible?

When it comes to RAutomation,

ar.menu(name => "Files").exists? - returns true ar.menu(name => "Files").click - does not return with any value

leviwilson commented 8 years ago

RAutomation

This is probably a bit trangential, but there are a handful of open RAutomation issues (jarmo/RAutomation#73, jarmo/RAutomation#79, jarmo/RAutomation#97) that likely will require swapping out the underlying RAutomation :ms_uia driver to actually use this gem. RAutomation is great (I cut my teeth in Windows automation with ruby with it :) but it does not have an entirely consistent pattern in which it interacts with different elements, reports errors, etc.

This gem was sort of birthed out of my experience with RAutomation. That being said, moving forward I think that this gem is best to work with to have a consistent API. I also have a page-object wrapper gem called mohawk that actually uses the uia gem under the hood now.

Your Issue

The reason I mention this is because I see you're dumping out what RAutomation reports; could you maybe try using the mohawk gem to see what it does?

When you Element#click on something, it's going to do a mouse-click. It tries to find the clickable point ((null) in the cases above) and hit that, otherwise it tries to find the center of the element ("Bounding Rectangle"). That is not always reliable when dealing with menu items.

I mention all of this because mohawk, when working with menu items, tries to be fancier in how it selects a menu path. Rather than doing mouse-clicks, it tries to use the InvokePattern (you see up above) to do that, and I think it falls back to mouse-clicks if necessary? [example]https://github.com/northwoodspd/uia/blob/master/ext/UiaDll/UiaDll/MenuItemMethods.cpp#L42)

TL;DR;

You might try one of the above approaches; likely mouse-clicking is not going to work for you. I mention mohawk because it is a little cleaner in defining how you access menus.

Pramanth commented 8 years ago

Thanks. Sure will try mohawk and update.

Cannot use RAutomation for specified application even if it recognise the elements but when clicking on any element like menu, button hangs the command without returning.

Pramanth commented 8 years ago

When I execute below script,

require 'mohawk'

Mohawk.default_adapter = Mohawk::Adapters::UiaAdapter

class ARWindow include Mohawk window(title: 'ThreeKingdoms.pdf - Adobe Reader')

menu_item(:menu_item_by_path, path: ['File']) menu_item(:menu_item_by_text, text: 'File') end

main = ARWindow.new puts main.exist? puts main.menu_item_by_text.exist?

main.exist? - returns "true" main.menu_item_by_text.exist? - nothing gets return even error and script hangs in command prompt

Hope the script is correct as I am new to Ruby :)

And please can you guide on how to overcome this issue. Whatever action I try to perform on any element using any gems(RAutomation, uia, mohawk) the command hangs :(

Thank you for all the support.

leviwilson commented 8 years ago

Are you automating Adobe Acrobat? Which version and what are you trying to do?

On Fri, Jan 15, 2016 at 3:01 PM Pramanth notifications@github.com wrote:

When I execute below script,

require 'mohawk'

Mohawk.default_adapter = Mohawk::Adapters::UiaAdapter

class ARWindow include Mohawk window(title: 'ThreeKingdoms.pdf - Adobe Reader')

menu_item(:menu_item_by_path, path: ['File']) menu_item(:menu_item_by_text, text: 'File') end

main = ARWindow.new puts main.exist? puts main.menu_item_by_text.exist?

main.exist? - returns "true" main.menu_item_by_text.exist? - nothing gets return even error and script hangs in command prompt

Hope the script is correct as I am new to Ruby :)

And please can you guide on how to overcome this issue. Whatever action I try to perform on any element using any gems(RAutomation, uia, mohawk) the command hangs :(

Thank you for all the support.

— Reply to this email directly or view it on GitHub https://github.com/northwoodspd/uia/issues/9#issuecomment-172070061.

Pramanth commented 8 years ago

Trying on Adobe Reader 11. Our application has few elements registered in the menu option and disable few options in sidebar like attachments based on policy. We even support Adobe Acrobat 11,DC etc. which I have not tried automating.

I can do few validation with send_keys but nice to have control on elements.

leviwilson commented 8 years ago

Is it possible that the Adobe Reader is running in an elevated session and the test suite is not?

On Fri, Jan 15, 2016 at 3:15 PM Pramanth notifications@github.com wrote:

Trying on Adobe Reader 11. Our application has few elements registered in the menu option and disable few options in sidebar like attachments based on policy. We even support Adobe Acrobat 11,DC etc. which I have not tried automating.

I can do few validation with send_keys but nice to have control on elements.

— Reply to this email directly or view it on GitHub https://github.com/northwoodspd/uia/issues/9#issuecomment-172078406.

Pramanth commented 8 years ago

I have logged in as Administrator in the windows host. Even tried once again but no success.

Actually our application has components registered in explorer, outlook, word and able to interact with most of the elements in these applications with the gems but the gems only fail in Acrobat Reader.