2017-01-14 9 views
0

私はAppiumを電卓アプリのテストに使用しようとしています。しかし、私は操作を実行することができません。詳細は以下である:
実モバイル:小米科技Redmi注3
Androidのバージョン:6.0.1
MIUI:8.1
Appiumバージョン:1.4.16
のAndroid SDKのバージョン:24.4.1
appiumのJavaクライアント:4.1.2
コード:ネイティブのアプリケーション自動化のためにappiumを使用して実際のデバイスで操作を実行できません

package unittest; 

import java.io.IOException; 
import java.io.InputStream; 
import java.net.URL; 
import java.util.Properties; 
import org.junit.Test; 
import org.openqa.selenium.By; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import io.appium.java_client.MobileElement; 
import io.appium.java_client.android.AndroidDriver; 
import io.appium.java_client.remote.MobileCapabilityType; 

public class LaunchWardRobe { 

    @Test 
    public void swipeTest() throws IOException { 
     String propFileName = "wardrobe.properties"; 
     InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(propFileName); 
     Properties prop = new Properties(); 
     prop.load(inputStream); 
     DesiredCapabilities cap = new DesiredCapabilities(); 
     cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, prop.getProperty("cap.platform.version")); 
     cap.setCapability(MobileCapabilityType.PLATFORM_NAME, prop.getProperty("cap.platform.name")); 
     cap.setCapability(MobileCapabilityType.DEVICE_NAME, prop.getProperty("cap.device.name")); 
     cap.setCapability("appPackage", prop.getProperty("cap.app.package")); 
     cap.setCapability("appActivity", prop.getProperty("cap.app.activity")); 
     cap.setCapability(MobileCapabilityType.BROWSER_NAME, ""); 
     cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium"); 
     AndroidDriver<MobileElement> browser = new AndroidDriver<MobileElement>(
       new URL(prop.getProperty("cap.hub.url")), cap); 
     MobileElement dig5 = browser.findElement(By.id("com.miui.calculator:id/btn_5")); 
     dig5.tap(1, 3); 
     dig5.click(); 
     browser.closeApp(); 
    } 
} 

プロパティファイル:

cap.platform.version=6.0.1 
cap.platform.name=Android 
cap.device.name=Redmi 
cap.app.package=com.miui.calculator 
cap.app.activity=com.miui.calculator.cal.CalculatorActivity 
cap.hub.url=http://127.0.0.1:4723/wd/hub 
EclipseのコンソールIDE上

例外またはスタックトレース:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 410 milliseconds 
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09' 
System info: host: 'mrunal-laptop', ip: '192.168.56.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111' 
Driver info: io.appium.java_client.android.AndroidDriver 
Capabilities [{appPackage=com.miui.calculator, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=80b83390, platform=LINUX, appActivity=com.miui.calculator.cal.CalculatorActivity, desired={appPackage=com.miui.calculator, appActivity=com.miui.calculator.cal.CalculatorActivity, platformVersion=6.0.1, automationName=Appium, browserName=, platformName=Android, deviceName=Redmi}, platformVersion=6.0.1, webStorageEnabled=false, locationContextEnabled=false, automationName=Appium, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=Android}] 
Session ID: caa419ad-6146-47e0-a1b1-ef700d6645e6 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40) 
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) 
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1) 
    at io.appium.java_client.AppiumDriver.performTouchAction(AppiumDriver.java:336) 
    at io.appium.java_client.MultiTouchAction.perform(MultiTouchAction.java:71) 
    at io.appium.java_client.AppiumDriver.tap(AppiumDriver.java:361) 
    at io.appium.java_client.MobileElement.tap(MobileElement.java:50) 
    at unittest.LaunchWardRobe.swipeTest(LaunchWardRobe.java:33) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 

Appiumログ:

info: [debug] Appium session started with sessionId caa419ad-6146-47e0-a1b1-ef700d6645e6 info: <-- POST /wd/hub/session 303 10720.889 ms - 74 info: --> GET /wd/hub/session/caa419ad-6146-47e0-a1b1-ef700d6645e6 {} 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":{"appPackage":"com.miui.calculator","appActivity":"com.miui.calculator.cal.CalculatorActivity","platformVersion":"6.0.1","automationName":"Appium","browserName":"","platformName":"Android","deviceName":"Redmi"},"appPackage":"com.miui.calculator","appActivity":"com.miui.calculator.cal.CalculatorActivity","automationName":"Appium","platformName":"Android","deviceName":"80b83390"},"sessionId":"caa419ad-6146-47e0-a1b1-ef700d6645e6"} info: <-- GET /wd/hub/session/caa419ad-6146-47e0-a1b1-ef700d6645e6 200 1.228 ms - 700 {"status":0,"value":{"platform":"LINUX","browserName":"","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appPackage":"com.miui.calculator","appActivity":"com.miui.calculator.cal.CalculatorActivity","platformVersion":"6.0.1","automationName":"Appium","browserName":"","platformName":"Android","deviceName":"Redmi"},"appPackage":"com.miui.calculator","appActivity":"com.miui.calculator.cal.CalculatorActivity","automationName":"Appium","platformName":"Android","deviceName":"80b83390"},"sessionId":"caa419ad-6146-47e0-a1b1-ef700d6645e6"} info: --> POST /wd/hub/session/caa419ad-6146-47e0-a1b1-ef700d6645e6/element {"using":"id","value":"com.miui.calculator:id/btn_5"} info: [debug] Waiting up to 0ms for condition info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.miui.calculator:id/btn_5","context":"","multiple":false}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.miui.calculator:id/btn_5","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.miui.calculator:id/btn_5 using ID with the contextId: multiple: false info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.miui.calculator:id/btn_5] info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}} info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"caa419ad-6146-47e0-a1b1-ef700d6645e6"} info: <-- POST /wd/hub/session/caa419ad-6146-47e0-a1b1-ef700d6645e6/element 200 82.020 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"caa419ad-6146-47e0-a1b1-ef700d6645e6"} info: --> POST /wd/hub/session/caa419ad-6146-47e0-a1b1-ef700d6645e6/touch/perform {"actions":[{"action":"press","options":{"element":"1"}},{"action":"wait","options":{"ms":3}},{"action":"release","options":{}}]} info: [debug] Pushing command to appium work queue: ["element:getLocation",{"elementId":"1"}] info: [debug] Pushing command to appium work queue: ["element:getSize",{"elementId":"1"}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"1"}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"x":270,"y":1317}} info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"1"}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: getSize info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"width":270,"height":201}} info: [debug] Pushing command to appium work queue: ["element:getLocation",{"elementId":"1"}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"1"}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: getLocation info: [debug] Pushing command to appium work queue: ["element:getSize",{"elementId":"1"}] info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"x":270,"y":1317}} info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getSize","params":{"elementId":"1"}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: getSize info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"width":270,"height":201}} info: [debug] Pushing command to appium work queue: ["element:touchDown",{"elementId":"1","x":405,"y":1417.5}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:touchDown","params":{"elementId":"1","x":405,"y":1417.5}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: touchDown info: [debug] [BOOTSTRAP] [debug] Performing TouchDown using element? true x: 405, y: 1417 info: [debug] [BOOTSTRAP] [error] error while invoking method private boolean com.android.uiautomator.core.InteractionController.touchDown(int,int) on object [email protected] with parameters [405, 1417] null info: [debug] [BOOTSTRAP] [debug] Problem invoking touchDown: java.lang.RuntimeException: error while invoking method private boolean com.android.uiautomator.core.InteractionController.touchDown(int,int) on object [email protected] with parameters [405, 1417] info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Failed to execute touch event"},"sessionId":"caa419ad-6146-47e0-a1b1-ef700d6645e6"} info: <-- POST /wd/hub/session/caa419ad-6146-47e0-a1b1-ef700d6645e6/touch/perform 500 358.523 ms - 198 info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":13,"value":"Failed to execute touch event"} 

答えて

0

は、それが動作します、これを試してみてください。
static AndroidDriver<WebElement> ds; File appDir = new File("Folder_Path");
File app = new File(appDir,"App_Name");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","device_name");
capabilities.setCapability("platformVersion", "device_version");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "package_name");
capabilities.setCapability("appActivity", "app_Activity");
capabilities.setCapability("noReset","true");
ds = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

操作してください。

+0

Ok..wellそれが小米科技Redmi注3(ビッグタイム)を吸うようだ...あるように私は、サムスンの携帯に私のものを試してみました、それが働いていた、我々は特別な何かをする必要がある場合、あなたは知っているだろうXiaomiの携帯電話用。注:私は自分のコードでネイティブアプリケーションを起動することができましたが、何も操作できませんでした –

+0

MIUIの問題かもしれません。 –

+0

@Mrunal Gosar同じ問題は私がredmi note 3に直面しています。 – Chetan

4

私も同じ問題が発生し、解決策を見つけました。Redmi note 3は、有効にした後でのみ、開発者のオプションにセキュリティレベルを追加しました。それはいくつかのスローされます、これを有効に

  • (あなたはすでに有効になっている)USBデバッグの下にあなたが別のオプションを見つけるでしょう、ここでは開発者向けオプション
    1. ゴー「USBデバッグ(セキュリティ設定)」:試してみてください警告ポップアップ、許可を続けると有効になり、すべてのアクションを実行できるようになります。テストが完了したら、これを無効にすることができます。

    enter image description here

  • 関連する問題