Appium未单击按钮,并通过测试


I am new in appium. So, i did complete setup and my application launch successfully. But after launching app, No click action is performed on element.
Code--->

package functionlity;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
public class Login {
    WebDriver driver;
    @BeforeClass(alwaysRun = true)
    public void Loadsetup() {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("deviceName", "dcd9e0817d63");
        capabilities.setCapability("VERSION", "6.0");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("appPackage", "com.engagebeyond.load");
        capabilities.setCapability("appActivity", "com.engagebeyond.load.Splesh");
        try {
            driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    }
    @Test(priority=1)
    public void Logincase_01() throws InterruptedException{

        Thread.sleep(5000);
        WebElement w=driver.findElement(By.id("com.engagebeyond.load:id/c1"));
        System.out.println(w);
        w.click();

    }
}
Appium Log--->

> Launching Appium server with command: C:Program Files (x86)Appiumnode.exe libservermain.js --address 127.0.0.1 --port 4723 --app D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk --no-reset --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
> info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"app":"D:\Appiumnewproject\Load-com.engagebeyond.load-33-v3.3.apk","address":"127.0.0.1","noReset":true,"logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"Android","VERSION":"6.0","deviceName":"dcd9e0817d63","appActivity":"com.engagebeyond.load.Splesh","browserName":"","appPackage":"com.engagebeyond.load"}}
> info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.7.0_79)
> info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : VERSION
> info: [debug] Using local app from command line: D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk
> info: [debug] Creating new appium session 2980c636-5d38-4e5c-8c75-0717d1da26b9
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.6.0_16
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from D:android-sdk-windowsplatform-toolsadb.exe
> info: [debug] Using fast reset? false
> info: [debug] Preparing device for session
> info: [debug] Checking whether app is actually present
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device dcd9e0817d63
> info: [debug] Setting device id to dcd9e0817d63
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 wait-for-device
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Getting device API level
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 23
> info: Device API level is: 23
> info: [debug] Extracting strings for language: default
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "getprop persist.sys.language"
> info: [debug] Current device persist.sys.language: 
> info: [debug] java -jar "C:Program Files (x86)Appiumnode_modulesappiumnode_modulesappium-adbjarsappium_apk_tools_1.6.jar" "stringsFromApk" "D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk" "c:Tempcom.engagebeyond.load" 
> info: [debug] No strings.xml for language '', getting default strings.xml
> info: [debug] java -jar "C:Program Files (x86)Appiumnode_modulesappiumnode_modulesappium-adbjarsappium_apk_tools_1.6.jar" "stringsFromApk" "D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk" "c:Tempcom.engagebeyond.load"
> warn: Error getting strings.xml from apk
> info: [debug] Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file
>   at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:54)
>   at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:540)
>   at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:76)
>   at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:68)
>   at io.appium.apktools.StringsXML.run(StringsXML.java:84)
>   at io.appium.apktools.Main.main(Main.java:31)
> Caused by: java.io.IOException: Expected: 0x001c0001, got: 0x00000000
>   at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:48)
>   at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:43)
>   at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:100)
>   at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:81)
>   at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
>   ... 5 more
> 
> warn: Could not get strings, continuing anyway
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "echo '{}' > /data/local/tmp/strings.json"
> info: [debug] Checking whether aapt is present
> info: [debug] Using aapt from D:android-sdk-windowsbuild-tools26.0.0-previewaapt.exe
> info: [debug] Retrieving process from manifest.
> info: [debug] executing cmd: D:android-sdk-windowsbuild-tools26.0.0-previewaapt.exe dump xmltree D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk AndroidManifest.xml
> info: [debug] Set app process to: com.engagebeyond.load
> info: [debug] Not uninstalling app since server not started with --full-reset
> info: [debug] Checking app cert for D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk.
> info: [debug] executing cmd: java -jar "C:Program Files (x86)Appiumnode_modulesappiumnode_modulesappium-adbjarsverify.jar" D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk
> info: [debug] App already signed.
> info: [debug] Zip-aligning D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk
> info: [debug] Checking whether zipalign is present
> info: [debug] Using zipalign from D:android-sdk-windowsbuild-tools26.0.0-previewzipalign.exe
> info: [debug] Zip-aligning apk.
> info: [debug] executing cmd: D:android-sdk-windowsbuild-tools26.0.0-previewzipalign.exe -f 4 D:AppiumnewprojectLoad-com.engagebeyond.load-33-v3.3.apk c:Temp117320-672-a5var0appium.tmp
> info: [debug] MD5 for app is 1ef6766ab258f337503deaecd232d00c
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "ls /data/local/tmp/1ef6766ab258f337503deaecd232d00c.apk"
> info: [debug] Getting install status for com.engagebeyond.load
> info: [debug] Getting device API level
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 23
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "pm list packages -3 com.engagebeyond.load"
> info: [debug] App is installed
> info: [debug] Forwarding system:4724 to device:4724
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 forward tcp:4724 tcp:4724
> info: [debug] Pushing appium bootstrap to device...
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 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: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 install "C:Program Files (x86)Appiumnode_modulesappiumbuildsettings_apksettings_apk-debug.apk"
> info: [debug] Pushing unlock helper app to device...
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 install "C:Program Files (x86)Appiumnode_modulesappiumbuildunlock_apkunlock_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: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "ps 'uiautomator'"
> info: [debug] No matching processes found
> info: [debug] Running bootstrap
> info: [debug] spawning: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.engagebeyond.load -e disableAndroidWatchers false
> 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] json loading complete.
> 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] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "dumpsys window"
> 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] [BOOTSTRAP] [debug] Got command action: getDataDir
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"/data/local/tmp"}
> info: [debug] dataDir set to: /data/local/tmp
> info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
> 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: {"status":0,"value":false}
> info: [debug] Getting device API level
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 23
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.engagebeyond.load/com.engagebeyond.load.Splesh"
> info: [debug] Waiting for pkg "com.engagebeyond.load" and activity "com.engagebeyond.load.Splesh" to be focused
> info: [debug] Getting focused package and activity
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "dumpsys window windows"
> info: [debug] executing cmd: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 shell "getprop ro.build.version.release"
> info: [debug] Device is at release version 6.0.1
> 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 2980c636-5d38-4e5c-8c75-0717d1da26b9
> info: <-- POST /wd/hub/session 303 16397.110 ms - 74 
> info: --> GET /wd/hub/session/2980c636-5d38-4e5c-8c75-0717d1da26b9 {}
> info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","VERSION":"6.0","deviceName":"dcd9e0817d63","appActivity":"com.engagebeyond.load.Splesh","browserName":"","appPackage":"com.engagebeyond.load"},"platformName":"Android","VERSION":"6.0","deviceName":"dcd9e0817d63","appActivity":"com.engagebeyond.load.Splesh","appPackage":"com.engagebeyond.load"},"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}
> info: <-- GET /wd/hub/session/2980c636-5d38-4e5c-8c75-0717d1da26b9 200 7.609 ms - 641 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","VERSION":"6.0","deviceName":"dcd9e0817d63","appActivity":"com.engagebeyond.load.Splesh","browserName":"","appPackage":"com.engagebeyond.load"},"platformName":"Android","VERSION":"6.0","deviceName":"dcd9e0817d63","appActivity":"com.engagebeyond.load.Splesh","appPackage":"com.engagebeyond.load"},"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}
> info: --> POST /wd/hub/session/2980c636-5d38-4e5c-8c75-0717d1da26b9/timeouts {"type":"implicit","ms":15000}
> info: [debug] Set Android implicit wait to 15000ms
> info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}
> info: <-- POST /wd/hub/session/2980c636-5d38-4e5c-8c75-0717d1da26b9/timeouts 200 6.394 ms - 76 {"status":0,"value":null,"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}
> info: --> POST /wd/hub/session/2980c636-5d38-4e5c-8c75-0717d1da26b9/element {"using":"id","value":"com.engagebeyond.load:id/c1"}
> info: [debug] Waiting up to 15000ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.engagebeyond.load:id/c1","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.engagebeyond.load:id/c1","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 com.engagebeyond.load:id/c1 using ID with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.engagebeyond.load:id/c1]
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}}
> info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}
> info: <-- POST /wd/hub/session/2980c636-5d38-4e5c-8c75-0717d1da26b9/element 200 32.339 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}
> info: --> POST /wd/hub/session/2980c636-5d38-4e5c-8c75-0717d1da26b9/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: {"status":0,"value":true}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}
> info: <-- POST /wd/hub/session/2980c636-5d38-4e5c-8c75-0717d1da26b9/element/1/click 200 64.664 ms - 76 {"status":0,"value":true,"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}
> 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: D:android-sdk-windowsplatform-toolsadb.exe -s dcd9e0817d63 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] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> 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: 68.444
> 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

请建议我解决方案。在这里,我的代码有什么问题。我是新的appium。因此,我确实完成了设置,并成功启动了申请。但是启动应用程序后,没有对元素进行单击操作

如果您看到日志文件,则具有此输出 -

> 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: {"status":0,"value":true}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"2980c636-5d38-4e5c-8c75-0717d1da26b9"}

这意味着Appium能够基于您提供的标识符成功单击该元素。也许您使用的标识符存在问题,这就是为什么Appium没有单击正确的元素的原因。

您是否可以共享UiautomatorViewer屏幕截图,以便我们查看对象属性?

最新更新