How to enter text into a textfield in a web view using UIAutomation

可紊 提交于 2019-12-06 09:54:07
Felix

You can do something like:

  1. Get the reference to the webview

    var webView=window.scrollViews()[0].webViews()[0];
    
  2. Tap the textView that you want to edit:

    webView.textFields()[0].tap();
    
  3. Use the keyboard

    UIATarget.localTarget().frontMostApp().keyboard().typeString("text");
    

You can use: webView.logElementTree() to find out your webview.

Yes this is quite possible but instead of going through the position of the text field, I'd suggest going through the id/name of the text field. Another approach is to traverse the application window.

Try following this apple's documentation - http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html

This will give you a head start and many other ideas.

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