Unable to access WebView elements

别来无恙 提交于 2019-12-25 02:51:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!