Common keywords of Appium+RobotFramework

Open Application, start the specified app

To open the specified app on the simulator or mobile phone, you need to use the open application method. Here is a brief introduction to this method:

1.http://localhost:4723/wd/hub:

The url path where Appium is located (here appium is built on this machine, so the url format is fixed)

2.platformName :

The name of the platform under test, Android or ios

3.platformVersion:

Platform version, such as the version number of Android

4.deviceName:

The name of the device, that is, the model of the device running the emulator or real machine

5.app:

The storage path of the application under test

6.appPackage:

The package name of the app

7.appActivity:

 The activity name of the app

Note: The method of obtaining the package name and activity name of the app has been introduced in the study of Monkeyrunner in this blog; please refer to the method in Monkeyrunner.

8. How to get actual parameters

1) deviceName acquisition

Obtained by entering the adb devices command in the cmd command line

2)app

With appPackage and appActivity, you can choose one of two; that is, when you choose to fill in the appPackage and appActivity parameters, you can omit the app parameter and not fill in; when you do not fill in the app, the default device under test already has the app; when filling in the app parameter , the system will reinstall the specified app

3)appPackage

Method 1: Get through uiautomatorviewer

Method 2: aapt dump badging [apk local storage path on the computer], there must be no spaces in the apk path (specific reference: http://www.cnblogs.com/lynn-li/p/5885001.html "How to obtain An app's package name and activity")

4)appActivity

Method 1: aapt dump badging [apk storage path locally on the computer], there must be no spaces in the apk path (specific reference: http://www.cnblogs.com/lynn-li/p/5885001.html "How to obtain An app's package name and activity")

Method 2: Open the home page activity name and get the command adb logcat ActivityManager:I*:s

At this point, we can successfully open the specific app on the specified device.

Common keywords

1. Practical functions

keywords

meaning

example

Remark

Click Button

Click the button

Click Button Logout

The class attribute of "logout" here must be Button

Click Element

click element

Click Element [locator]

Locator can be resource-id or xpath; but it must be the only one on the current page; generally, this keyword can be used to complete all element clicks

Click Text

click text

Click Text My

"mine" needs to be the only one that exists on the current page

Input Text

Enter text in the specified element

InputText [locator] 111111

Locator can be resource-id or xpath

Swipe

Swipe the screen

Swipe 1000 1800 100 1800

 

 

Get Text

Get the content of a tag

${account}   Get Text  [locator]  

After getting the content, store it in the specified variable, so that the content can be called in subsequent scripts

 

2. Check function

keywords

meaning

example

Remark

Element Name Should Be

Check the element's name attribute

 

Element Name Should Be  [locator]  登录

locator can be resource-id or xpath

Element Should Be Enabled

Check if element is available/visible

Element Should Be Enabled  [locator]

 

Page Should Contain Element

Check that the interface contains certain elements

Page Should Contain Element   [locator]

 

Page Should Contain Text

Check that the interface contains some textual information

Page Should Contain Text

 

Page Should Not Contain Element

Check that the interface does not contain certain elements

Page Should Not Contain Element  [locator]

 

Page Should Not Contain Text

Check interface does not contain some text information

Page Should Not Contain Text

 

 

3. Wait function

keywords

meaning

example

Remark

Wait Until Page Contains

Wait until the interface contains some text before proceeding to the next step

Wait Until Page Contains

The default wait time is 5s

Wait Until Page Contains Element

Wait until the interface contains certain elements before proceeding to the next step

Wait Until Page Contains Element   [locator]

locator can be resource-id or xpath

Wait Until Page Does Not Contain

Wait until the interface does not contain some text before proceeding to the next step

Wait Until Page Does Not Contain

 

Wait Until Page Does Not Contain Element

 

Wait until the interface does not contain certain elements before proceeding to the next step

Wait Until Page Does Not Contain Element  [locator]

 

 

Use summary:

How to enter Chinese

method:

At the end of the open application parameter, add unicodeKeyboard=True resetKeyboard=True; if these two parameters are not added, Chinese cannot be input

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324927963&siteId=291194637