• 试过,一样的
    Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.

  • 我用的逍遥,android7

    {
    "platformName": "Android",
    "deviceName": "samsung SM-G9550",
    "appPackage": "com.p1.mobile.aaa",
    "appActivity": "com.p1.mobile.xxx",
    "platformVersion": "7.1.2",
    "automationName": "UiAutomator1"
    }
    在配置里我加了句"automationName": "UiAutomator1"
    如果不加的话,就这样:
    An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.

  • 百度找了找,发现都是 用苹果电脑 +iphone 的。

    我用 windows+ipad 可以吗?

  • 数字是变化的,所以要用 XX 查找

    driver.find_element_by_android_uiautomator('new UiSelector().text("XX"")')
    
    selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
    
  • 命令行下取 dump .xml 没问题,播放和暂停都可以。
    虽然有时也会取不到。

    但在我在 python 里执行命令行,就永远取不到了。

    我看了你说的暂停那个,但在代码里总是不行。搜了几天也没有提到解决办法的,哎

  • 用你图里的工具和 uiautomatorviewer 是都能找到元素的。
    但是写在代码 里跑就找不到了。。

    我试你说的暂停那个先。

    =============================================
    暂停视频也是不行

    我试过命令行下用 adb 里用命令取 xml
    不管视频播放停止都可以。。

    而且还能找到我要的那个元素

  • 模拟器不息,
    延迟几秒都没用

  • time.sleep(70)

  • [HTTP] 
    [HTTP] --> GET /wd/hub/session/b9847749-158b-4de8-9dd6-67017f1e1a70/source
    [HTTP] {}
    [MJSONWP] Calling AppiumDriver.getPageSource() with args: ["b9847749-158b-4de8-9dd6-67017f1e1a70"]
    [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"source","params":{}}
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"source","params":{}}
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: source
    [AndroidBootstrap] [UIAUTO STDOUT] [APPIUM-UIAUTO] [debug] Returning result: {"status":0,"value":"
    [AndroidBootstrap] [UIAUTO STDOUT] crollable=\"false\" long-clickable=\"false\" password=\"false\" selected=\"false\" bounds=\"[0,1208][720,1280]\" resource-id=\"com.ss.android.ugc.aweme:id\/na\" instance=\"2\"><\/android.widget.LinearLayout><\/android.widget.LinearLayout><\/android.widget.LinearLayout><\/android.widget.LinearLayout><\/android.widget.FrameLayout><\/android.wid
    [AndroidBootstrap] Received command result from bootstrap
    [AndroidBootstrap] Stream still not complete, waiting up to 60000ms for the data to arrive
    [AndroidBootstrap] [UIAUTO STDOUT] get.LinearLayout><\/android.widget.FrameLayout><\/hierarchy>"}[/APPIUM-UIAUTO]
    
    [AndroidBootstrap] Received command result from bootstrap
    [MJSONWP] Responding to client with driver.getPageSource() result: "
    [HTTP] <-- GET /wd/hub/session/b9847749-158b-4de8-9dd6-67017f1e1a70/source 200 58 ms - 4151
    [HTTP] 
    

    page_source 的日志,你说的是这一段吗?


    就是红框里面那句

  • [HTTP] --> GET /wd/hub/session/2a83c17d-a7bf-4fe6-affa-4e84468f0ceb/appium/device/system_time
    [HTTP] {}
    [MJSONWP] Calling AppiumDriver.getDeviceTime() with args: [null,"2a83c17d-a7bf-4fe6-affa-4e84468f0ceb"]
    [AndroidDriver] Attempting to capture android device date and time
    [ADB] Running 'E:\SDk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:62027 shell date +%Y-%m-%dT%T%z'
    [MJSONWP] Responding to client with driver.getDeviceTime() result: "2019-02-12T23:05:40+08:00"
    [HTTP] <-- GET /wd/hub/session/2a83c17d-a7bf-4fe6-affa-4e84468f0ceb/appium/device/system_time 200 109 ms - 99
    [HTTP] 
    [HTTP] --> POST /wd/hub/session/2a83c17d-a7bf-4fe6-affa-4e84468f0ceb/element
    [HTTP] {"using":"id","value":"com.ss.android.ugc.aweme:id/l7","sessionId":"2a83c17d-a7bf-4fe6-affa-4e84468f0ceb"}
    [MJSONWP] Calling AppiumDriver.findElement() with args: ["id","com.ss.android.ugc.aweme:id/l7","2a83c17d-a7bf-4fe6-affa-4e84468f0ceb"]
    [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
    [BaseDriver] Waiting up to 0 ms for condition
    [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.ss.android.ugc.aweme:id/l7","context":"","multiple":false}}
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.ss.android.ugc.aweme:id/l7","context":"","multiple":false}}
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.ss.android.ugc.aweme:id/l7' using 'ID' with the contextId: '' multiple: false
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.ss.android.ugc.aweme:id/l7]
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.ss.android.ugc.aweme:id/l7' using 'ID' with the contextId: '' multiple: false
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.ss.android.ugc.aweme:id/l7]
    [AndroidBootstrap] Received command result from bootstrap
    [MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
    [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"No element found"}
    [MJSONWP] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
    [MJSONWP]     at AndroidDriver.callee$0$0$ (C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
    [MJSONWP]     at tryCatch (C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    [MJSONWP]     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    [MJSONWP]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    [MJSONWP]     at GeneratorFunctionPrototype.invoke (C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
    [MJSONWP]     at run (C:\Program Files (x86)\Appium\resources\app\webpack:\~\babel-polyfill\~\core-js\modules\es6.promise.js:75:1)
    [MJSONWP]     at C:\Program Files (x86)\Appium\resources\app\webpack:\~\babel-polyfill\~\core-js\modules\es6.promise.js:92:1
    [MJSONWP]     at flush (C:\Program Files (x86)\Appium\resources\app\webpack:\~\babel-polyfill\~\core-js\modules\_microtask.js:18:1)
    [MJSONWP]     at process._tickCallback (internal/process/next_tick.js:61:11)
    [HTTP] <-- POST /wd/hub/session/2a83c17d-a7bf-4fe6-affa-4e84468f0ceb/element 500 962 ms - 164
    [HTTP] 
    [HTTP] --> GET /wd/hub/session/2a83c17d-a7bf-4fe6-affa-4e84468f0ceb/appium/device/system_time
    [HTTP] {}
    [MJSONWP] Calling AppiumDriver.getDeviceTime() with args: [null,"2a83c17d-a7bf-4fe6-affa-4e84468f0ceb"]
    [AndroidDriver] Attempting to capture android device date and time
    [ADB] Running 'E:\SDk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:62027 shell date +%Y-%m-%dT%T%z'
    [MJSONWP] Responding to client with driver.getDeviceTime() result: "2019-02-12T23:07:35+08:00"
    [HTTP] <-- GET /wd/hub/session/2a83c17d-a7bf-4fe6-affa-4e84468f0ceb/appium/device/system_time 200 102 ms - 99
    [HTTP] 
    [HTTP] --> GET /wd/hub/session/2a83c17d-a7bf-4fe6-affa-4e84468f0ceb/appium/device/system_time
    [HTTP] {}
    [MJSONWP] Calling AppiumDriver.getDeviceTime() with args: [null,"2a83c17d-a7bf-4fe6-affa-4e84468f0ceb"]
    [AndroidDriver] Attempting to capture android device date and time
    [ADB] Running 'E:\SDk\platform-tools\adb.exe -P 5037 -s 127.0.0.1\:62027 shell date +%Y-%m-%dT%T%z'
    [MJSONWP] Responding to client with driver.getDeviceTime() result: "2019-02-12T23:07:35+08:00"
    [HTTP] <-- GET /wd/hub/session/2a83c17d-a7bf-4fe6-affa-4e84468f0ceb/appium/device/system_time 200 103 ms - 99
    [HTTP] 
    

    这好像也只是提示没找到元素。。。
    我没太看出别的异常。我的分析对吗?

  • 试过等待,昨晚发现 page_source 没有这个元素。
    找别的元素的时候,page_source 里面都有。到这个就没了。
    不明白怎么回事?

  • 嗯。昨天晚上试过,page_source 也没有这个元素
    然后搜了半天,也没找到什么办法

  • 就是 douyin,刚好学习,就用这个挺火的练习

    你说的内嵌 js 或 动态获取,要用什么方法确定?


  • 就是这个(刚好截时是个美女图,涂掉吧)
    红框那个

  • 这上打错了。试了,找到了

  • 好的

  • selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.ss.android.ugc.aweme' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Cannot start the 'com.ss.android.ugc.aweme' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Activity name '.android.hardware.screen.portrait' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity

    不是这个。。。

  • 开梯子都没下来。

  • 呃。。activity 写错了。
    我没找到安卓 桌面的 activity 叫什么。这个要怎么查

  • 这跟使用方式有什么关系

    你使用的在熟练,也有出错又有明白的时候。

  • 阅......