-
Notifications
You must be signed in to change notification settings - Fork 407
Fix searching elements inside WebViews for iOS 13.3 #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d06b9f3
to
d870120
Compare
Possibly fixes appium/appium#13776 |
Thanks for this! I'm not sure it will fix the actual going into webviews (as in appium/appium#13776) but it will hopefully fix the accessing of webview contents within the native context (as in appium/appium#13821). This latter has always been a crapshoot, changing from version to version of both iOS and Xcode. |
@imurchie i didn't quite get about
Basically what happens with the fix — is now If someone would have very deep element hierarchy, then probably increasing Most probably we could make the What was happening before — a WebView process would start to consume 100% CPU and method Currently I've tested this fix with several applications using Hopefully it would not require any changes in Appium tools at all (apart from recompiling WebDriverAgent) |
I mean that the way webview contents are generally better handled is to switch to the webview context and interact with the HTML there, rather than interacting through the native layer. The SafariViewController issue is attempting to do that, and it is unlikely that any changes in WebDriverAgent will affect that. |
I tried your new change with new WebDriverAgent and it's working great, thanks. However I still find that few websites like yahoo.com, msn.com, m.weibo.cn webview content is not accessible. For reference here is the actual issue that I posted |
I agree it would be nice to have the depth value configurable. We also had exactly the same issue in Android and workarounded it by setting the maximum recursion depth to 70. |
@mykola-mokhnach i will update the PR in 10-15 min with configurable value |
2b54cbb
to
024f047
Compare
@mykola-mokhnach @imurchie I've modified the PR with allowing to change configuration. |
@rakurati7 If you need bigger level of |
It would be nice to describe this somewhere in the troubleshooting documentation at https://github.com/appium/appium/tree/master/docs/en/writing-running-appium/ios |
622aae8
to
e9f253c
Compare
I'll try to do that |
@mykola-mokhnach please could you take a look if it is ok now |
@@ -411,4 +434,20 @@ + (BOOL)reduceMotionEnabled | |||
} | |||
return NO; | |||
} | |||
|
|||
/** | |||
Returns defaul parameters for traversing elements tree from parents to children while requesting XCElementSnapshot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default
e9f253c
to
b4ec652
Compare
fixed docs |
QQ, So with your new commit I have to build a new WDA, right? and the parameters maxDepth and snapshotTimeout should be passed as a Webdriver capabilities?. Please clarify, thanks. |
@rakurati7 yes, you will need to build WDA. But the parameters For example something like this: This will get session id: DEFAULT_SESSION_ID=$(curl -s http://localhost:8100/status | awk -F'[:]' '/sessionId/ { gsub(/[" ,]/, ""); print $2 }') This will get current settings: curl -s http://localhost:8100/session/${DEFAULT_SESSION_ID}/appium/settings | grep snapshot This will change settings: curl -s -X POST -d '{ "settings" : { "snapshotMaxDepth" : 100, "snapshotTimeout" : 60 } }' http://localhost:8100/session/${DEFAULT_SESSION_ID}/appium/settings | grep snapshot This is example search of an element with a name 'Search' curl -s -X POST -d '{ "using" : "name", "value" : "Search" }' http://localhost:8100/session/${DEFAULT_SESSION_ID}/element This is example response for found element:
This is changing settings to lower values: curl -s -X POST -d '{ "settings" : { "snapshotMaxDepth" : 10, "snapshotTimeout" : 15 } }' http://localhost:8100/session/${DEFAULT_SESSION_ID}/appium/settings | grep snapshot This is example search of an element with a name 'Search' again curl -s -X POST -d '{ "using" : "name", "value" : "Search" }' http://localhost:8100/session/${DEFAULT_SESSION_ID}/element But this time, no element is found:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
It would be nice to add the snapshotMaxDepth in https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/settings.md latere
thanks for this valuable contribution @fr0l! |
Thank you, I am referring to this document and I found Appium settings can be set using 'settings[settingsKey]'. So with this commit can I set the following capabilities in Appium inspector. |
b4ec652
to
06379ab
Compare
06379ab
to
77cd2e1
Compare
@mykola-mokhnach thanks for awesome code review! |
you're welcome. Thanks for your contributions |
77cd2e1
to
cc6eba2
Compare
cc6eba2
to
ed7fbe1
Compare
@fr0l Could you please clear me this? |
@fr0l I tried the new appium@beta with new WDA. I still not able to find elements inside webview for few websites like yahoo.com, nytimes.com. I am passing the following settings as capabilities in appium inspector Original issue here |
Fixes issue with searching and interacting with elements inside WebViews for iOS 13.3
Swizzle
defaultParameters
ofXCAXClient_iOS
to setmaxDepth
to a meaningful level of recursion.Original implementation of
defaultParams
returns this valuesIt is quite possible, that it is enough to change only the
maxDepth
parameter. I'm still experimenting.Please do not merge yet, Just for verification if it does not break stuff.