dhemery / victor

A Java driver for iOS applications
MIT License
11 stars 4 forks source link

How to access UI Element in a app #18

Open santhanakrishnan opened 11 years ago

santhanakrishnan commented 11 years ago

Hi Dhemery,

Please let us know, what the methods available in victor for the below actions.

  1. Tapping on a button
  2. Typing a Text in Textfield.
  3. scroll the iphone/ipad screen
  4. How to inspect the App Elements.
dhemery commented 11 years ago

How to tap a button

// Preparation
IosApplication application = ...;
IosViewIdentifier buttonId = ...; // The shelley or igor view selector for the button
IosView button = application.view(id);

// Tap the button
button.sendMessage("touch");

How to type text into a text field

// Preparation
IosApplication application = ...;
IosViewIdentifier textFieldId = ...; // The view selector for the text field
IosView textField = application.view(textFieldId);

// Tap the text field to raise the keyboard
textField.sendMessage("touch");

// Use the keyboard to type
String text = ...; // the text to type
application.typeIntoKeyboard(text);

// Tap somewhere else to dismiss the keyboard
someOtherView.sendMessage("touch");

How to scroll the screen

I don't know how to do that. I know that Frank adds one or more methods to each UIView in the application, and some of those methods perform scrolling. But I don't know what the methods are.

How to inspect application views

Frank includes a marvelous tool called Symbiote. Frankifying your application installs Symbiote inside your application. Symbiote is a web application hosted inside your iOS application. You can usually access it by visiting http://localhost:37265

I don't know how to quickly explain all of Symbiote's features, but I found it quite intuitive and very helpful.

Symbiote is a Frank tool, and I have no special insight into it. There isn't much information about it on the Testing with Frank site, so if you need help, try the Frank mailing list. https://groups.google.com/forum/?fromgroups#!forum/frank-discuss

santhanakrishnan commented 11 years ago

Hi Dhemery,

Right now how i run my vigor tests is, i launch app using "frank launch" command in commandline and then run Junit tests.

Then my test cases run. From your above code it looks like we can launch device and the app from Junit test case. Can you give example for how to instantiate app using IosApplication class? so that i can use this after device.start(0 method call. Looks like it is an Interface? What its implementation class? In OnVigorapp.java class i see application = victor.application; From where does it take application value.? In my.properties file i just gave the path till my plist file. The app is not at the same location.