Unable to detect Popovers in Cocoa App (Mac)

Hello,

I am attempting to automate a Cocoa based application on OS X using Appium for Mac.
User interaction with the application is only via a popover anchored through a menu bar item.
For example: https://koenig-media.raywenderlich.com/uploads/2017/07/show-QuotesViewController.png

Once I click on the application icon in the menu bar, I am unable to navigate to any of the elements inside the popover using xpath. (for example: “/AXApplication[@AXTitle=‘App_Name’]/AXMenuBar[1]/AXButton/AXPopover[0]/AXButton[@AXTitle=‘Enable’]”

I suspect the problem is that Appium for Mac is not able to detect the presence of a popover, and therefore driver.page_source continues to refer to the previous XML. Since popovers are loaded in the view hierarchy only once you click on the menu icon, all attempts to find the elements using xpath are not successful since the XML is not updated.

driver.window_handles continues to show ‘0’ even after the popover is displayed on screen. All attempts to use driver.switch_to (using default_content, window, active element etc) have not helped.

If I use atomac (https://github.com/pyatom/pyatom), I am able to change focus to the popover by calling AXFocusedWindow on the application object after the click (press) action. Since Appium for Mac also uses the Accessibility API provided by Apple, I was wondering if there is a way to get this to work using Appium for Mac.

Hi all.

I see there’s no reply on this. I compiled the code by-myself and get this working using AXFocusedWindow.AXChildren. But now I am fighting with another problem: when I’m clicking on a status bar icon to open a popup, for some reason, it is not focused when shown. If I click on it manually - everything works. I cannot make it focused using any programmatic way (ActionChains, pyautoui). Any ideas why?

Solved the problem with this:
Actions(driver).click(bar_icon).wait(<wait_for_the_popup_to_appear_time>).move_by_offset(<relative_offset_of_the_popup>).click().perform()

Same issue happens to me. Could someone explain a solution for this query ?
How to click on a UI element in a mac application which launches as a popover window from menu bar ?

The following is my python code

driver.get(“Mac_App_Name”)

driver.find_element(By.XPATH,"/AXApplication[@AXTitle=‘Mac_App_Name’]/AXWindow[@AXSubrole=‘AXUnknown’]/AXPopover[0]/AXGroup[@AXSubrole=‘AXHostingView’]/AXStaticText[@AXValue=‘ABC’]").click()

The code is not throwing any error. The app opens up on running the code but the click is not happening. I am unable to navigate to the elements

Please provide a solution

Hi Appium Team,@megha_sebastian

I have the same issue: popups are not clicked, but the code is executing.

Screenshot 2023-01-10 at 3.33.50 PM

Is it because there are no action types in Actions?

I request that the Appium team, please provide a solution.

Thank you.

Team, I found the solution for this query.

Thank You

Please share the solution if you can. That way those who find this thread from a websearch can benefit.

Hi @MohammedAfroz Kindly share the solution if possible

Hi @megha_sebastian
I was inactive on the forum

WebElement Documents = mac2driver.findElement(AppiumBy.accessibilityId(“Documents”));
a.doubleClick(Documents).perform();
Thread.sleep(3000);