Robotium from getting started to discarding four Robotium common APIs

Source: Internet
Author: User

Get control

GetText ()

Getedittext ()

Getbutton ()

GetImage ()

Getimagebutton ()

Getedittext ()

GetView ()

Getwebelement ()

Getweburl ()

Getcurretviews ()

Click the Action Control

Clickbutton () can identify controls by index or text

Clickonview () first gets the control and then implements the click Control via Clickonview

Clickonscreen (float x, float y, int numberofclicks) Click on the specified coordinates

Clicklongonscreen (float x, float y, int time) Specify the coordinates long press

Slide screen operation

Solo.scrolltoside (keyevent.keycode_dpad_right); Slide right

Drag (float fromx, float toX, float fromy,float toY, int stepcount) Drag, the less step moves faster

Jump

GoBack ()

Gobacktoactivity ("Activity name"); jump to the specified activity

Click the button

The index in the lower-right corner of the control property, which is usually used when traversing the entire sub-object, navigates to the parent object, and then takes the child object in this way

Solo.clickonbutton (0);

If there is a text attribute on the key

Solo.clickonbutton ("Enquiry");

If the text on the key is displayed in the picture, only the id attribute in the system needs to be encapsulated by itself, and the solo class does not have a ready-made method to manipulate the case through the control ID, you can manipulate the key with ID in the following way

Solo.clickonview (Solo.getview ("ID of the Control"));

To enter an edit box

Navigate to the input box element by ID

Edittextedittext=solo.getview (ID);

Enter text for the control you have anchored to

Solo.entertext (edittext, text);

Get Control Text Property

ToString (). Trim () turns the acquired name first into a character, and if there is a space before and after it, the space is automatically removed.

Solo.getview ("id"). getclass (). toString (). Trim ();

Long press the control

Position the control according to its text and perform a long press operation

Solo.clicklongontext (text);

Depending on the text position in the control, and the same interface has multiple identical text in the following way, where match is of type int, which represents the search for the first text

Solo.clicklongontext (Text,match);

Sometimes a space is not found on the current screen, you need to scroll the screen in the following way, where scroll is Boolean, true when the control is not found automatically scroll

Solo.clicklongontext (text, match, scroll);

Menu operation

Click a menu

Solo.clickonmenuitem (text);

Drop-down list operation (Android called Spinner control)

Select the item you want based on the text value

solo.isspinnertextselected (text);

 

Drag control

FromX, ToX, x-axis drag from point to point

FromY, ToY, y-axis drag from point to point

SOLO.D Rag (FromX, ToX, ToY, stepcount);

Solo.clickonscreen (x, y);

Solo.scrolldown () Drag the screen down

Solo.scrolltobottom () Scroll to the bottom of the screen

Solo.scrollup () scrolling up the screen

Solo.scrolltotop () scroll to the top of the screen

 

Assertion method

Used to verify that the current activity name is correct

Solo.assertcurrentactivity (message, Activityclass)

Verifying Memory value Information

Solo.assermemorynotlow ();

Because the JUnit package is referenced in the test, the same city can also use the JUnit assertion method to verify that the modal results match the actual results.

Assert.assertequals (expected, actual);

Condtion get is a Boolean if condition gets the true use case through

Assert.asserttrue (condition);

If condition gets the false use case through

Assert.assertfalse (condition);

Object non-null judgment

Assert.assertnotnull (object);

Assertassernull (object);

Object-to-object comparison

Assert.assertsame (expected, actual);

Robotium from getting started to discarding four Robotium common APIs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.