appium / appium-for-mac

[deprecated] Application for automating a mac app with JSON wire protocol
Apache License 2.0
193 stars 70 forks source link

Does Appium-for-Mac supports WebView browser that is embedded in a Mac OS X desktop application? #43

Open cassie9 opened 6 years ago

cassie9 commented 6 years ago

i was able to successfully automate mac QQ desktop application through appium-for-mac,and it was fine to get xpaths , but the problem is when ever i try to build the xpath for my company app (which is WebView browser that is embedded in a Mac OS X desktop application), it does not generate the xpath

QQ xpath: "/AXApplication[@AXTitle='QQ']/AXWindow[@AXSubrole='AXStandardWindow']/AXButton[@AXIdentifier='Sessions']"

my company webview app(all elements are like this ): "/AXApplication[@AXTitle='RCE']/AXWindow[@AXTitle='XX企业版' and @AXSubrole='AXStandardWindow']/AXScrollArea"

I hope you can reply as soon as possible,Thank you very much for your reply

stuartbrussell-intuit commented 6 years ago

@cassie9 embedded web views are problematic. From the outside of the application, the accessibility API's don't have access directly into the web view, so it can't always get to the element. Is your application Electron based?

cassie9 commented 6 years ago

@stuartbrussell-intuit Thanks for your fast reply! yes,my application based on Electron .Is there any solution or other advice?Thanks again! The source code screeshot as follows :

2018-07-10 9 48 59
stuartbrussell-intuit commented 6 years ago

I don't have the link handy, but somewhere out in web land you can find references to Electron's reluctance to allow macOS accessibility into its web views. Basically there is a setting you can change and it should work. I haven't tried it myself.

jlipps commented 6 years ago

for testing electron apps, why not use spectron or chromedriver?

stuartbrussell-intuit commented 6 years ago

That would work nicely for the web views, and it also let's you use genuine web XPaths instead of the AXPaths used by AfM. To get into parts of the app outside web views, such as the menu bar, you still need AfM. To do both, your script can create two webdriver instances. One is for spectron or chromedriver, the other is for AfM. As long as each uses a different endpoint, you can use both concurrently in one script.

tomw93 commented 5 years ago

Is the answer for this no then? Can we not automate a WebView within a Mac app?

bumbu commented 4 years ago

Looks like you need to enable accessibility in electron, as by default it is off. Doing that allowed me to get entire accessibility tree (including the web view). I did it by enabling accessibility on macOS (CMD+click touch ID 3 times).

But looks like it also can be done programmatically https://www.electronjs.org/docs/tutorial/accessibility

bumbu commented 4 years ago

But looks like it also can be done programmatically https://www.electronjs.org/docs/tutorial/accessibility

Doing that programmatically also returned the full tree.