Appium use instructions


Driver, Ltd. Free Join
# element positioning
driver.find_element_by_id ( "id") # id positioning
driver.find_element_by_name ( "name") # name positioning
driver.find_element_by_link_text ( "text") # link names positioning
driver.find_element_by_partial_link_text ( "text") # by elements part of the visible link text positioning
driver.find_element_by_tag_name ( "name") # name positioned elements by searching for the tags of html
driver.find_element_by_xpath ( "xpath") # path to locate
driver.find_element_by_class_name ( "android.widget.LinearLayout") # class name positioning
driver .find_element_by_css_selector ( "css") # css selector positioned

# plurality of positioning elements set
driver.find_elements_by_id ( "id") # id element in the set
driver.find_elements_by_name ( "name") # name element set
driver.find_elements_by_link_text ( "text") # Link name elements of the collection
driver.find_elements_by_partial_link_text ( "text") # some elements visible link collection
driver.find_elements_by_tag_name ( "name") # html tag name set
driver.find_elements_by_xpath ( "xpath") # positioning path set
driver.find_elements_by_class_name ( "android.widget.LinearLayout") # Class Name Location set
driver.find_elements_by_css_selector ( "css") select # CSS positioned set

# input box
driver.element.send_keys ( "Britain")

# lock screen
driver.lock (. 5)

# the current application in the background
driver.background_app (. 5)

# stowed keyboard
driver.hide_keyboard ()

# Activity or open an application, only Andrews end
driver.start_activity ( 'com.example.android.apis', '.foo')

# open the drop-down notification bar Android only
driver.open_notifications ()

# drag element, the element origin_el onto the target element destination_el
driver.drag_and_drop (Self, origin_el, destination_el):

# Check whether the installed app
driver.is_app_installed ( 'com.example.android.apis')

# is mounted to the appliance
driver.install_app ( 'path / to / my.apk')

# remove application
driver.remove_app ( 'com.example.android.apis')

# analog devices shake
driver.shake ()


# close the application
driver.close_app ()

# start (launch)
# service according to the keyword (desired capabilities) to start the session (session). Note that this must take effect when setting autoLaunch = false keywords.
# This is not the start the specified app / activities ---- you can use to achieve this effect start_activity ----
# This is used to continue using autoLaunch = initialization of false keyword (Launch) process.
driver.launch_app ()

# reset the application, which is equivalent to re-uninstall
driver.reset ()

# available context (context) lists all the available context
# translate NOTE: context can be understood as a window accessible. For example, for native application, available context and the default context are NATIVE_APP.
# For details, see the automated testing of hybrid applications
driver.contexts

# List current context
driver.current_context

# switch to the default context (context)
# switch context to the default context
driver.switch_to.context (None)

# string acquisition application
driver.app_strings

# key event (Key Event) to the device sending a key event
driver.keyevent (176)

# Get the current Activity
driver.current_activity

# touch operation (TouchAction) / multi-touch operation (MultiTouchAction)
action = TouchAction (Driver)
action.press (EL Element =, X = 10, . y = 10) .release () perform ()

sliding # slide (the Swipe) analog subscriber
# Note: appium slide rule is x increases from left to right, y increases from top to bottom
driver.swipe (start = 75, = 500 startY, EndX = 75, Endy = 0, DURATION = 800)

# kneader (Pinch) kneaded screen (two fingers to move to narrow the screen)
driver.pinch (= EL Element)

# amplification (zoom) to enlarge the screen (bis refers to move outwardly to enlarge the screen)
driver.zoom (= EL Element)

# Slid onto an element (the To the Scroll)
TODO: Python

# pull the document (Pull File) from the device
driver.pull_file ( 'Library / the AddressBook / AddressBook.sqlitedb')

# push into the device file
data = "some data The File for "
path =" /data/local/tmp/file.txt "
driver.push_file (path, data.encode ( 'Base64'))

# asserted
Assert.assertEquals (" I am a div " , div.getText ( )); // jump to a specific page and the page it interacts with the id of the element

whether # check the text in line with expectations
assertEqual ( 'the I AM A div', div.text)

# input method for activity to return true and false
is_ime_active ( Self):

# returns the currently available input devices Andrews
driver.available_ime_engines (Self):

# input to activate Andrews developing apparatus
driver.activate_ime_engine (Self, Engine):

# Close the current input method (Android)
driver.deactivate_ime_engine ( self):

# Open position location device disposed on Android
driver.toggle_location_services ()

# set the device's latitude and longitude
: Args:
- Latitude Latitude - String or numeric value and the BETWEEN -90.0 90.00
- longitude longitude - String or numeric value and the BETWEEN -180.0 180.0
- Altitude's altitude - String or numeric value
Usage driver .set_location (latitude, longitude, altitude)

# click
element.click ()

# remove an element content
element.clear ()

# returns the element's text content
element.text ()

# submit the form
element.submit (Self):

# element is available
element.is_enabled ()

# optional whether the element
element.is_slected ()

# element is visible
element.is_displayed ()

# Get the element size (height and width)
new_size [ "height"] = size [ "height"]
new_size [ " width "] = size [" width "]
driver.element.size

Obtaining coordinates of the upper left corner element #
# usage driver.element.location
'' 'return element x coordinate, int type' ''
driver.element.location.get ( 'x')
return to the y coordinate of the element '' ', int type '' '
driver.element.location.get (' Y ')

# Get the current element screenshot Base64 encoded string
img_b64 = element.screenshot_as_base64

# perform the JS
# current window / frame (especially the Html iframe) synchronization javascript code execution
driver.execute_script ( 'document.title')
# asynchronously execute code in other code execution
driver.execute_async_script ( 'document.title')

# Get the current URL
driver.current_url

# get page source
driver.page_source

# close the current window
driver.close ()


# close the application
driver.quit ()

test on Chrome #
{
'PlatformName':'Android',
'platformVersion': '4.4',
'deviceName': 'the Android Emulator',
'BrowserName': 'the Chrome'
}

# real test
{
'automationName': 'Selendroid',
'PlatformName': 'the Android',
'platformVersion': '2.3',
'deviceName': 'the Android Emulator',
'App': myApp,
'appPackage': 'com.mycompany.package',
'appActivity': '.MainActivity'
}

# multitouch
"" "
specification available events:
* press (press)
* release (release)
* move to (moveTo)
* click (TAP)
* waiting (the wait)
* press (longPress)
* cancel (the cancel)
* execute (the perform)
"" "



5.8 server parameters
Appium server parameters

to use: node [flag].
Server flag

All flags are optional, but there are some signs need to be combined together to take effect.

<expand_table>
flag Default Description Example
--shell null mode into the REPL
--localizable-strings-dir en.lproj IOS only : relative path --localizable-strings-dir en.lproj .strings directory location where
--app null iOS: bundle_id based on absolute or target device simulator compiled the app; Android: apk file absolute path /abs/path/to/my.app - aPP
--ipa null (the IOS-only) the .ipa file /abs/path/to/my.ipa absolute path --ipa
-U, physical device connection --udid null unique device identifiers 1adsf-sdfas-asdf --udid-123sdf
-a, --address monitor 0.0.0.0 ip address 0.0.0.0 --address
-p, --port 4723 4723 listening port --port
-ca, null callback - callback-address IP address (default: the same IP address) --callback-address 127.0. 0.1
-cp, port-null callback - callback port number (default: the same port number) - callback-port 4723
-bp, port number --bootstrap-port 4724 (Android-only ) connection device --bootstrap- port 4724
-k, --keep-artifacts false deprecated, invalid. trace information is now reserved tmp directory, before each run will clear the information in the directory. See also --trace-dir.
-r, --backend-retries 3 (iOS -only) encounter crash or a timeout, the number of Instrument restart. 3-retries --backend
--session-false allows the override session covered (if conflict)
--full-the RESET false (iOS) Delete the entire simulator directory. (Android) by unloading the application (instead of clearing data) application reset state. On Android, the application will be deleted after the session is completed.
not reset between --no-reset false session application state (iOS: do not delete the plist file applications; Android:. is not deleted before creating a new application of the session)
the -l, --pre-Launch false in the first Last session, pre-boot applications (iOS needs --app parameters, Android needs --app-pkg-Activity and --app)
-lt, --launch-timeout 90000 (iOS-only) Instruments waiting time to start
-g , --log null output to a specified log file /path/to/appium.log --log
--log-level Debug logging level; default (console [: file]): debug [: debug] --log-level Debug
--log-timestamp in the timestamp to false display the output on terminal
--local-timezone false local time stamp using
a display color --log-no-colors false output terminal is not
-G, --webhook null simultaneously send logs to the localhost HTTP listener --webhook: 9876
The --native-Instruments- lib false (iOS-only) iOS built a strange impossible to avoid delays. We fixed it in Appium years. If you want to use the original, you can use this parameter.
--app-pkg null (Android-only ) java package you want to run the apk. (For example, com.example.android.myApp) --app-pkg com.example.android.myApp
when --app-activity null (Android-only ) to open the application, start the Activity name (for example, MainActivity) - app-activity MainActivity
package name --app-wait-package false (Android -only) you want to wait for the Activity of. (For example, com.example.android.myapp) - APP-the wait-Package Penalty for com.example.android.myapp
- APP-the wait-Activity false (Android-only) you want to wait Activity name (for example, SplashActivity) - -app-wait-activity SplashActivity
--android-coverage false (Android-only ) full compliance with the instrumentation class condition. As commands adb shell am instrument -w of -e coverage true -w parameter-coverages com.my.Pkg - Android / com.my.Pkg.instrumentation.MyInstrumentation
AVD --avd null (Android-only) to start name
--avd-args null (Android-only ) to add additional parameters to start the -no-args---avd AVD-the Load Snapshot
--device-rEADY-timeout 5 (Android-only) waits for the device ready time, in seconds timeout. 5-READY---device
- Safari to false (the IOS-Only) and Safari application
--device-name the name of the mobile device --device-name iPhone Retina null to be used (4-inch) , Android Emulator
name --platform-name null mobile platforms: iOS, Android, or FirefoxOS --platform -name iOS
version --platform-version null mobile platform version 7.1---platform
--automation-name null automation tools name: Appium or Selendroid --automation-name Appium
Name --browser-name null mobile browsers: Safari or Chrome --browser-name Safari
--default-Device, -DD false (IOS-Simulator-only) use instruments to start their own default simulator
--force-iphone false (iOS-only) no matter what application to use the simulator, forced to use the iPhone simulator
--force-ipad false (iOS-only ) use no matter what the simulator application, mandatory use of iPad simulator
--language null iOS / Android EN language simulator --language
--locale the null Locale for the iOS simulator / emulator --locale the Android the en_US
--calendar the format-null (the IOS-only) the iOS simulator the format-Gregorian calendar format --calendar
--orientation null (IOS-only) initialization request, using lANDSCAPE the (landscape) or pORTRAIT (portrait) --orientation lANDSCAPE the
--tracetemplate null (IOS-only) Instruments used to specify file tracetemplate --tracetemplate / Users / me / Automation .tracetemplate
--show-SIM-log to false (the IOS-only) If set, iOS terminal emulator log will be written up
--show-ios-log false (IOS -only) If set, iOS system log terminal will be written up
--nodeconfig null specify the configuration file in JSON format, used to register appiumd --nodeconfig / abs in selenium grid in /path/to/nodeconfig.json
-ra, --robot 0.0.0.0 Robot-address-address ip address 0.0.0.0 --robot
-rp, -1 Robot --robot-port port address --robot-port 4242
--selendroid-port 8080 is used to interact with the local port and Selendroid --selendroid-port 8080
port --chromedriver-port --chromedriver-port 9515 ChromeDriver 9515 running
full path --chromedriver-executable null ChromeDriver executable file
--use-keystore false (Android-only ) set the signature apk of the keystore
--keystore-path (Android-only) the keystore path
--keystore-password android (Android-only ) keystore password
--key-alias androiddebugkey ( Android-only) Key alias
--key-password android (Android-only ) Key password
--show-config false Appium print server configuration information, then exit
--no-perms-check false skip Appium whether the read / write checks necessary documents
--command-timeout 60 receives commands all default session timeout (timeout is not received within a new command to automatically close the session). The new timeout will be overwritten
--keep-keychains false (iOS) when Appium startup or shutdown of whether to retain Keychains (Library / Keychains)
the --strict-Caps false If the selected device is a valid device appium does not recognize, It will cause the session to fail
--isolate-sim-device false Xcode 6 there is a bug, that is, on some platforms a particular simulator can only be established in the absence of any errors if other analog devices to be deleted. This option causes the Appium had to remove the device is being used in addition to all the other devices. Please note that this is a permanent delete, you can use the device management category simctl or xcode be used Appium.
--tmp null Appium can be used to manage the directory (absolute path) temporary files, such as the built-in iOS applications need to store the move. The default variable is APPIUM_TMP_DIR, in * nix / Mac is / tmp environment on the windows so they set TEMP directory.
--trace-dir null for storing iOS instruments trace of appium directory, an absolute path, the default is <tmp dir> / appium-instruments
intent action --intent-action android.intent.action.MAIN --intent- action android.intent.action.MAIN (Android-only) for activating activity of
--intent-category android.intent.category.LAUNCHER (Android intent category -only) used to start activity-category android.intent.category.APP_CONTACTS of --intent
--intent-flag flags 0x10200000 (Android-only) start-flags 0x10200000 activity of --intent
--intent-args null ( additional parameters included with intent --intent-args 0x10200000 when activity Android-only) start
--suppress-adb-kill-server false (Android-only) If set to prevent Appium kill adb instance.




Guess you like

Origin www.cnblogs.com/ly570/p/11014105.html