问题
I tried to access webView elements using Calabash-iOS using following query:
query("webView css:'*'")
But it is unable to detect the elements. When I touch any input field manually, it gets zoomed in and I am able to view the elements using the above query.
Can I get any solution for this?
回答1:
1) First of all, make sure that you know the correct type of webview present in the app. Easiest way of specifying the webview element is by using the element class or the element's id.
To get the correct element class, you can run the following command in the console:
irb> classes '*'
This should return an array of elements, something like:
[0] UIView
[1] UIImageView
[2] UICollectionView
[3] UICollectionViewCell
....
[x] UIWebView
...
To show the id's for all elements, use the command:
irb> identifier '*'
2) Once you identified the correct webview container element, than you can use it in your query:
irb> query "UIWebView css:''"
Alternatively, you can identify the webview container using it's id:
irb> query " id:'web_view' css:'*'"
If you need more information on how to identify elements inside webviews, check the link below:
https://github.com/calabash/calabash-ios/wiki/06-WebView-Support
回答2:
Try query("all webView css:'*'")
来源:https://stackoverflow.com/questions/23883885/unable-to-access-webview-elements