First, AppIUM Tools

1. Introduction to appium

1. Appium is an open source automated testing framework that supports mobile testing. The official website is appium.io

2. Platforms supported by appium: Android, iOS, some windows applications

3. Types of mobile APPs supported during testing

  Native: Implementation technology (Android: java, iOS: objective-c)

  web (html5)

   hybrid (hybrid): both native and web

4. Features

   open source

p>

   does not limit the programming language of client test scripts, supports Python, java, javascript, c/c++, ruby

   mainly adopts c/s architecture: server (appium server implementation technology node.js ), the client side (the java version is used here to develop and run in eclipse)

5. Working principle

  Write a test script in eclipse and run it

  Send to the appium server for processing

  The server controls the tested mobile terminal for automated operation

  Appium client-server communication protocol JSON wired protocol

< p>Second, test environment

1, appium server: appium desktop

2, appium client

  eclipse: introduce the appium java-client package (java- client, selenium, commos-Apache open source project, used to extend the original java class library)

  Android SDK: Android development kit (platform-tools), adb, configuration environment variable ANDROID-HOME (android sdk path)

  JDK: configure the environment variable JAVA-HOME (jdk path)

3, the tested mobile device: simulator or real machine

Three, Java language knowledge points

   create project, create package, create class, member attribute, member method, create class object, static attribute, static method, encapsulation, overload, import package and class, Exception handling, generics

Four, create test scripts

1, process

   create java project

p>

  Create package

  Create java class

  Introduce appium package

   Write script in java class (create session, test operation, end session)

2, get the package name and the name of the interface (activity)

   directly adb shell dumpsys activity|find “Focused”

   first enter adb shell and then execute dumpsys activity| grep “Focused”

Four. Common API

1, session

(1) Screenshot

  getScreenshotAs();

(2) Horizontal and vertical screen

  getOrientation();

  driver.rotate(ScreenOrientation.LANDSCAPE);

  driver.rotate(ScreenOrientation.PORTRAIT );

(3) Element positioning waiting timeout (implicit waiting)

  driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

2, Devices

(1) Switch between different apps

  driver.startActivity(new Activity(“package name”,”class name”));< /p>

(2) Physical button

  driver.pressKey(new KeyEvent(AndroidKey.VOLUME_UP));

  driver.pressKey(new KeyEvent(AndroidKey.VOLUME_MUTE)) ;

  driver.pressKey(new KeyEvent(AndroidKey.VOLUME_DOWN));

  driver.pressKey(new KeyEvent(AndroidKey.BACK));

  driver. pressKey(new KeyEvent(AndroidKey.HOME));

  driver.pressKey(new KeyEvent(Androi dKey.POWER));

(3) Open the notification bar

  driver.openNotifications();

(4) Get the current time of the phone

  System.out.println(driver.getDeviceTime());

3, element

(1) Tools

   uiautomator viewer under Android sdk

  The inspector tool that comes with the appium server

(2) Method

  driver.findElement, driver.findElements

    by id

p>

    by class name

    by accessibility id

    by xpath

(3) Element operation

   Click .click( )

  input text.sendKey(“content”)

   clear text.clear()

(4) Get element attributes

Get the text of the element.getText()

4, interaction

touch

(1) Create AndroidTouchAction object

  AndroidTouchAction ta1 = new AndroidTouchAction(driver);

(2) Click the coordinate point

  ta1.tap(PointOption.point(110, 228));

(3) execute Operation

  ta1.perform();

(4) Long press

  ta1.longPress(PointOption.point(90, 320));

(5) Slide

  ta1.moveTo(PointOption.point(450, 320));

  ta1.moveTo(PointOption.point(90, 680));

  ta1.moveTo(PointOption.point(450, 680));

( 6) Release

  ta1.release();

5. Testing framework

Automated testing process

   demand analysis

  Design test cases

   Convert test cases into automated test scripts

  Parameterization (preparing test data)

   Checkpoint (Assertion)

  Execute test

  Generate test report

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2241 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.