簡體   English   中英

使用Java實現Appium自動化

[英]appium automation using java

我嘗試使用Selenium Webdriver自動化android本機應用程序。 請參閱下面的代碼。

package appium.eclipse;

import org.testng.annotations.Test;

import java.io.IOException;
import java.net.URL;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;

public class NewTest {
    AppiumDriver<WebElement> dr;

    @BeforeClass
    public void setup() throws IOException{
        DesiredCapabilities first = new DesiredCapabilities();
        first.setCapability(MobileCapabilityType.DEVICE_NAME, "donatello");
        first.setCapability(MobileCapabilityType.APP_ACTIVITY,"com.myapplication.MainActivity");
        first.setCapability(MobileCapabilityType.APP_PACKAGE,"com.myapplicationdev");
        dr=new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),first);
    }

    @Test
    public void launchapp() throws Throwable {
        Thread.sleep(9000);
        //insert pin
        for (int i =0; i<5; i ++) {
            dr.findElementByXPath("//android.view.View[@content-desc='1']").click();
            System.out.println("I clicked" + i );
            Thread.sleep(1000);
        }
        //click login
        Thread.sleep(4000);
        dr.findElementByXPath("//android.view.View[@index='2']").click();
        System.out.println("I clicked Login");
        Thread.sleep(9000);
    }
}

但是,Appium會五次單擊該圖釘,但不會單擊循環外的登錄按鈕。 Appium將成功返回給我用於測試的Java客戶端(日食)。

請問我做錯了什么。 我將不勝感激提供的任何幫助。

@Manidroid,請參閱下面的appium日志

> Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 19 --automation-name Appium --device-name "donatello" --log-no-color
> warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
> info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"deviceName":"donatello","platformName":"Android","platformVersion":"19","automationName":"Appium"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"appActivity":"com.myapplicationdev.MainActivity","appPackage":"com.myapplication","platformName":"Android","deviceName":"donatello"}}
> info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_101)
> info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
> info: [debug] Creating new appium session 60ee80cd-ab62-4dcd-8e18-aac9de15aed6
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.8.0_101
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe
> warn: No app capability, can't parse package/activity
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" devices
> info: [debug] 1 device(s) connected
> info: Found device 169.254.160.177:5555
> info: [debug] Setting device id to 169.254.160.177:5555
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 wait-for-device
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Getting device API level
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 19
> info: Device API level is: 19
> info: [debug] Extracting strings for language: default
> info: [debug] Apk doesn't exist locally
> info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "rm -rf /data/local/tmp/strings.json"
> info: [debug] Not uninstalling app since server not started with --full-reset
> info: [debug] Skipping install since we launched with a package instead of an app path
> info: [debug] Forwarding system:4724 to device:4724
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 forward tcp:4724 tcp:4724
> info: [debug] Pushing appium bootstrap to device...
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 push "C:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
> info: [debug] Pushing settings apk to device...
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
> info: [debug] Pushing unlock helper app to device...
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
> info: Starting App
> info: [debug] Attempting to kill all 'uiautomator' processes
> info: [debug] Getting all processes with 'uiautomator'
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "ps 'uiautomator'"
> info: [debug] No matching processes found
> info: [debug] Running bootstrap
> info: [debug] spawning: C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe -s 169.254.160.177:5555 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.myapplicationdev -e disableAndroidWatchers false
> info: [debug] [UIAUTOMATOR STDOUT] WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
> info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
> info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
> info: [debug] [BOOTSTRAP] [debug] Loading json...
> info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
> info: [debug] Waking up device if it's not alive
> info: [debug] Pushing command to appium work queue: ["wake",{}]
> info: [debug] [BOOTSTRAP] [debug] Client connected
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: wake
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "dumpsys window"
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> info: [debug] Screen already unlocked, continuing.
> info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] dataDir set to: /data
> info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
> info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data","status":0}
> info: [debug] Getting device API level
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "getprop ro.build.version.sdk"
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
> info: [debug] Device is at API Level 19
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.myapplicationdev/com.myapplicationdev.MainActivity"
> info: [debug] Waiting for pkg "com.myapplicationdev" and activity "com.myapplicationdev.MainActivity" to be focused
> info: [debug] Getting focused package and activity
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "dumpsys window windows"
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "getprop ro.build.version.release"
> info: [debug] Device is at release version 4.4.4
> info: [debug] Device launched! Ready for commands
> info: [debug] Setting command timeout to the default of 60 secs
> info: [debug] Appium session started with sessionId 60ee80cd-ab62-4dcd-8e18-aac9de15aed6
> info: <-- POST /wd/hub/session 303 12203.233 ms - 74 
> info: --> GET /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6 {}
> info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.4","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appActivity":"com.myapplicationdev.MainActivity","appPackage":"com.myapplication","platformName":"Android","deviceName":"donatello"},"appActivity":"com.myapplicationdev.MainActivity","appPackage":"com.myapplication","platformName":"Android","deviceName":"169.254.160.177:5555"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- GET /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6 200 7.357 ms - 644 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.4","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appActivity":"com.myapplicationdev.MainActivity","appPackage":"com.myapplication","platformName":"Android","deviceName":"donatello"},"appActivity":"com.myapplicationdev.MainActivity","appPackage":"com.myapplication","platformName":"Android","deviceName":"169.254.160.177:5555"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element {"using":"xpath","value":"//android.view.View[@content-desc='1']"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[@content-desc='1'] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.view.View, INSTANCE=4]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"1"},"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element 200 512.676 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/1/click {"id":"1"}
> info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"1"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: click
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/1/click 200 545.815 ms - 76 {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element {"using":"xpath","value":"//android.view.View[@content-desc='1']"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[@content-desc='1'] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.view.View, INSTANCE=5]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"2"},"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"2"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element 200 312.892 ms - 87 {"status":0,"value":{"ELEMENT":"2"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/2/click {"id":"2"}
> info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"2"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"2"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: click
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/2/click 200 635.001 ms - 76 {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element {"using":"xpath","value":"//android.view.View[@content-desc='1']"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[@content-desc='1'] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.view.View, INSTANCE=5]
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"3"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element 200 693.547 ms - 87 {"status":0,"value":{"ELEMENT":"3"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"3"},"status":0}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/3/click {"id":"3"}
> info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"3"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"3"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: click
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/3/click 200 457.090 ms - 76 {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element {"using":"xpath","value":"//android.view.View[@content-desc='1']"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[@content-desc='1'] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.view.View, INSTANCE=6]
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"4"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element 200 233.350 ms - 87 {"status":0,"value":{"ELEMENT":"4"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"4"},"status":0}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/4/click {"id":"4"}
> info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"4"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"4"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: click
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/4/click 200 437.992 ms - 76 {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element {"using":"xpath","value":"//android.view.View[@content-desc='1']"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.View[@content-desc='1']","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[@content-desc='1'] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.view.View, INSTANCE=7]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"5"},"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"5"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element 200 371.092 ms - 87 {"status":0,"value":{"ELEMENT":"5"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/5/click {"id":"5"}
> info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"5"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"5"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: click
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/5/click 200 231.014 ms - 76 {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element {"using":"xpath","value":"//android.view.View[@index='2']"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.view.View[@index='2']","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.View[@index='2']","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //android.view.View[@index='2'] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.view.View, INSTANCE=3]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":{"ELEMENT":"6"},"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"6"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element 200 170.945 ms - 87 {"status":0,"value":{"ELEMENT":"6"},"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: --> POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/6/click {"id":"6"}
> info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"6"}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"6"}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: click
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: <-- POST /wd/hub/session/60ee80cd-ab62-4dcd-8e18-aac9de15aed6/element/6/click 200 326.695 ms - 76 {"status":0,"value":true,"sessionId":"60ee80cd-ab62-4dcd-8e18-aac9de15aed6"}
> info: [debug] Didn't get a new command in 60 secs, shutting down...
> info: Shutting down appium session
> info: [debug] Pressing the HOME button
> info: [debug] executing cmd: "C:\Users\Eagle\Desktop\Appium\Installations and Configuration\android-sdk-windows\platform-tools\adb.exe" -s 169.254.160.177:5555 shell "input keyevent 3"
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down","status":0}
> info: [debug] [BOOTSTRAP] [debug] Closed client connection
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
> info: [debug] [UIAUTOMATOR STDOUT] Time: 87.663
> info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
> info: [debug] UiAutomator shut down normally
> info: [debug] Cleaning up android objects
> info: [debug] Cleaning up appium session
> info: [debug] We shut down because no new commands came in

您可以嘗試單擊元素的坐標,看看它是否有效嗎?

試試這樣的事情-

Point point = element.getLocation();
int x = point.x;
int y = point.y;

TouchAction touchAction = new TouchAction(driverMobile);
touchAction.tap(x, y).perform();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM