alibaba / macaca

Automation solution for multi-platform. 多端自动化解决方案
https://macacajs.github.io
MIT License
3.16k stars 418 forks source link

macaca安卓如何解决非预期的弹窗,配置了"autoAcceptAlerts": true不起作用,并且会在跑用例的时候点了测试步骤外的元素 #967

Open yuanjie111 opened 4 years ago

yuanjie111 commented 4 years ago
macaca-bot commented 4 years ago

This is the translated issue:


How to solve macaca Andrews unintended pop, arranged "autoAcceptAlerts": true does not work, and the element will point the outside when run with the test procedure of Example

houseshi commented 4 years ago

No problems were found with Java

houseshi commented 3 years ago
  • Macaca Version:2.2.0
  • Macaca Doctor Logs: Node.js checklist: node env: C:\Program Files\nodejs\node.exe node version: v8.9.2 Android checklist: JAVA version is 1.8 JAVA_HOME is set to C:\Program Files\Java\jdk1.8.0_121 ANDROID_HOME is set to C:\android-sdk Platforms is set to C:\android-sdk\platforms\android-25 ADB tool is set to C:\android-sdk\platform-tools\adb.exe GRADLE_HOME is set to D:\gradle\gradle-4.6-all\gradle-4.6 Installed driver list: android: 2.1.0 location: D:\work\schedule-list\node_modules\macaca-android
  • Operate System:
  • Programming Language:

可以贴出你的配置代码么?

macaca-bot commented 3 years ago

This is the translated issue comment: @houseshi


  • Macaca Version : 2.2.0
  • Macaca Doctor Logs : Node.js checklist: Node env: C: \ Program Files \ nodejs \ node.exe Node version: v8.9.2 Android checklist: JAVA version is 1.8 JAVA_HOME is set to C: \ Program Files \ Java \ jdk1.8.0_121 ANDROID_HOME is set to C: \ android-sdk Platforms is set to C: \ android-sdk \ platforms \ android-25 ADB tool is set to C: \ android-sdk \ platform-tools \ adb.exe GRADLE_HOME is set to D: \ gradle \ gradle-4.6-all \ gradle-4.6 Installed driver list: Android: 2.1.0 Location: D: \ work \ schedule-list \ node_modules \ macaca-android
  • Operate System :
  • Programming Language :

You can put your configuration code it?

xudafeng commented 3 years ago

@houseshi @yuanjie111

可以尝试复现下这里的逻辑

https://github.com/macacajs/UIAutomatorWD/blob/master/app/src/androidTest/java/com/macaca/android/testing/server/controllers/AlertController.java#L88-L106

macaca-bot commented 3 years ago

This is the translated issue comment: @xudafeng


@houseshi @ yuanjie111

You can try complex logic holds many lessons here

https://github.com/macacajs/UIAutomatorWD/blob/master/app/src/androidTest/java/com/macaca/android/testing/server/controllers/AlertController.java#L88-L106

houseshi commented 3 years ago

@yuanjie111

我测试使用的配置


        JSONObject props = new JSONObject();
        props.put("autoAcceptAlerts", true);
        props.put("platformName", "Android"); 
        props.put("package", TestConfig.APP_PACKAGE);//appPackage
        props.put("activity",TestConfig.APP_ACTIVITY);//appActivity
        driver.curPlatform = BaseMacacaClient.PlatformType.ANDROID;
        desiredCapabilities.put("desiredCapabilities", porps);
        driver.initDriver(desiredCapabilities);

// 测试场景 :
// 调用安卓摄像头 提示 “允许使用 App拍摄照片和录制视频吗?”   ( 此处自动点击“允许”)

// 我的测试结果是ok的 ,不知道你那边的具体情况,可以参考。

我的环境配置:

  macaca-doctor version: 2.0.18

  Node.js checklist:

  node env: C:\Program Files\nodejs\node.exe
  node version: v12.15.0

  Android checklist:

  JAVA version is `1.8`
  JAVA_HOME is set to `D:\Java\jdk8u252-b09`
  ANDROID_HOME is set to `E:\android-sdk-windows`
  Platforms is set to `E:\android-sdk-windows\platforms\android-29`
  ADB tool is set to `E:\android-sdk-windows\platform-tools\adb.exe`
  GRADLE_HOME is set to `D:\gradle-6.2.2`

  Installed driver list:

  android: 2.2.1
  location: C:\Users\Administrator\AppData\Roaming\npm\node_modules\macaca-android

  chrome: 1.1.1
  location: C:\Users\Administrator\AppData\Roaming\npm\node_modules\macaca-chrome

测试机版本

android 9

macaca-bot commented 3 years ago

This is the translated issue comment: @houseshi


@ Yuanjie111

configuration I tested used

`Java

    JSONObject props = new JSONObject ();
    props.put ( "autoAcceptAlerts", true);
    props.put ( "platformName", "Android");
    props.put ( "package", TestConfig.APP_PACKAGE); // appPackage
    props.put ( "activity", TestConfig.APP_ACTIVITY); // appActivity
    driver.curPlatform = BaseMacacaClient.PlatformType.ANDROID;
    desiredCapabilities.put ( "desiredCapabilities", porps);
    driver.initDriver (desiredCapabilities);

// testing scenarios : // Call Andrews camera tips "are allowed to take pictures and record video App do?" (Here automatically click "Allow")

// my test result is ok, do not know your side of the situation, you can reference. `

my environment configuration:

`Shell macaca-doctor version: 2.0.18

Node.js checklist:

node env: C: \ Program Files \ nodejs \ node.exe node version: v12.15.0

Android checklist:

JAVA version is 1.8 JAVA_HOME is set to D: \ Java \ jdk8u252-b09 ANDROID_HOME is set to E: \ android-sdk-windows Platforms is set to E: \ android-sdk-windows \ platforms \ android-29 ADB tool is set to E: \ android-sdk-windows \ platform-tools \ adb.exe GRADLE_HOME is set to D: \ gradle-6.2.2

Installed driver list:

android: 2.2.1 location: C: \ Users \ Administrator \ AppData \ Roaming \ npm \ node_modules \ macaca-android

chrome: 1.1.1 location: C: \ Users \ Administrator \ AppData \ Roaming \ npm \ node_modules \ macaca-chrome `

tester version

android 9