Appiumlibrary Basic Operation

Source: Internet
Author: User
Tags xpath

Settings * * *
Library appiumlibrary
Library Collections
Library String
Library Dialogs

Test Cases * * *
Open app
Comment Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 Devicename= ' Android Simulator '
... app=${curdir}/tudou_phone_tudouweb.apk
Comment Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 Devicename= ' Android Simulator '
... appactivity=com.tudou.ui.activity.welcomeactivity apppackage=com.tudou.android
Comment Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 Devicename= ' Android Simulator '
... browsername=chrome
Comment Go to Url http://www.baidu.com

Background app
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android
Sleep 10s
Background APP 5

Close App
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android
Sleep 10s
Close All applications

Delete App
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android
Remove Application Com.tudou.android

Reset App
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android
Pause execution
Reset Application

Positioning
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android
Pause execution
Comment Click Element Id=com.tudou.android:id/mytudoutext
Comment Click Element name= my
Comment Click Element xpath=//android.widget.textview[contains (@text, ' my ')]
Comment Click Element class= "Android". Widgets. TextView
Click Element android=new uiselector (). Text ("my")
Pause execution
Close All applications

Input
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Comment Input Text id=com.tudou.android:id/login_name asdasd
Comment Input Text id=com.tudou.android:id/login_pwd 2312121
Comment Input Value id=com.tudou.android:id/login_name 34534534sdf

Keys
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Comment Press KeyCode 3
Comment Press KeyCode 24

Clear Content
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Clear Text Id=com.tudou.android:id/login_name

Click the button
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Click Button My
Comment Click Button to determine

Click on the element
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Click Element name= My
Click Element name= Login Now
Click Element Id=com.tudou.android:id/title_right_text

Click coordinates
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Click A Point 300 200

Tap
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Tap Name= mine.
Tap name= Login Now
Tap Id=com.tudou.android:id/title_right_text

Landscape
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' Browsername=chrome
... unicodekeyboard=${true} Resetkeyboard=${true}
Pause execution
Landscape

Hide keyboard
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Hide Keyboard

Shake a Shake
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Shake

Network
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
${a} Get Network Connection Status
Set Network Connection Status 1

Sliding
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Swipe 500 500 100 500 500
Sleep 2s
Swipe 500 500 100 500 500

Scroll
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Comment Scroll name= New Nan Network name= Voice Show
Scroll to Id=com.tudou.android:id/channel_subclass

Zoom
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' Appactivity=com.baidu.baidumaps.welcomescreen
... apppackage=com.baidu.baidumap unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Pinch Id=com.tudou.android:id/channel_subclass 200% 50

Get
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
Comment Get Element Attribute
Comment Get Element Location
Comment Get Element Size
Comment Get Elements
Comment Get Source
Comment Log Source

Shoudl
Element Attribute should Match
Element Name should be
Element should be Disabled
Element should be Enabled
Element Value should be
Page should contain Element
Page should contain Text
Page should not contain Element
Page should not contain Text

WebView
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android unicodekeyboard=${true} resetkeyboard=${true}
Pause execution
${a} Get Contexts
${B} Get Current Context
Switch to Context ${a[1]}
Log Source
Comment Click Element xpath=//a[text () = ' Open-hung! Those bull-shining cows.
Go to Url Http://www.w3school.com.cn/tiy/t.asp?f=jsref_dialog_create
Pause execution
Sleep 2s
Select Frame name=i
Click Element//button[text () = ' Try It '
Sleep 2s
Unselect Frame
Click Element//input[@value = ' Commit code ')
${url} Get Element Attribute xpath=//*[@id = "Footer"]/p/a href

Webview2
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android
Pause execution
${a} Get Contexts
${B} Get Current Context
Switch to Context ${a[1]}
Go to Url Http://www.w3school.com.cn/tiy/loadtext.asp?f=html_dropdownbox
Pause execution
Wait Until Page Contains Element name=cars
Select from List name=cars Fiat
Comment Click Element Name=cars
Comment Switch to Context ${a[0]}
Comment Click Element Name=audi
Comment Switch to Context ${a[1]}
Get Element Attribute Picture position src

Webview3
Open application Http://localhost:4723/wd/hub alias=tudouapp platformname=android platformversion=4.4 devicename= ' Android Simulator ' appactivity=com.tudou.ui.activity.welcomeactivity
... apppackage=com.tudou.android
Pause execution
${CONTEXTS} Get Contexts
Switch to Context ${contexts[1]}
Click Element//a[text () = ' Midnight Taxi: North Drift maid Bar survival ']

(GO) appiumlibrary basic operation

Related Article

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.