sudharsan-selvaraj / appium-dashboard-plugin

Appium plugin that provides complete test logs, video recording of test and device logs(logcat and syslogs) for easy debugging.
116 stars 28 forks source link

notNull Violation: Session.platform cannot be null #94

Closed ValzRon closed 1 year ago

ValzRon commented 1 year ago

Hello, ive wrongly posted this on the device farm plugin repo, but seems that if I run device farm without Appium Dashboard it works just fine.

Im running Appium 2.0.0-beta.44 (tried 43 and 46 aswell) with Device Farm and Espresso Driver (latest). The execution is running against an Android Device, as you will see in the logs.

Here is a snippet from the logs:

[debug] [EspressoDriver@65ce (182f1301)] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:59494/session/d4d95850-6137-4b77-9e25-a527f45e11c6/appium/device/info] with no body
[debug] [EspressoDriver@65ce (182f1301)] Got response with status 200: {"id":"5cc1f22b-1790-4f97-9edd-5cf26986fa44","sessionId":"d4d95850-6137-4b77-9e25-a527f45e11c6","value":{"platformVersion":"6.0.1","androidId":"55c85f3aca971d52","realDisplaySize":"720x1280","brand":"Zebra","locale":"de_DE","carrierName":"vodafone.de","apiVersion":"23","manufacturer":"Zebra Technologies","displayDensity":320,"timeZone":"Europe/Amsterdam","model":"TC75x"}}
[AppiumDriver@ce67] New EspressoDriver session created successfully, session 182f1301-cb7d-4a44-af3d-c71744ad758f added to master session list
[debug] [AppiumDriver@ce67] Event 'newSessionStarted' logged at 1670517824226 (17:43:44 GMT+0100 (Mitteleuropäische Normalzeit))
[appium-dashboard] Adb found. Creating device profiler
[appium-dashboard] Error initializing app profiler
[appium-dashboard] Error: Command 'C:\\Users\\BudovskiyVal\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s undefined shell cat /proc/cpuinfo' exited with code 1
[appium-dashboard]     at ChildProcess.<anonymous> (C:\Users\BudovskiyVal\node_modules\teen_process\lib\exec.js:129:19)
[appium-dashboard]     at ChildProcess.emit (node:events:513:28)
[appium-dashboard]     at maybeClose (node:internal/child_process:1098:16)
[appium-dashboard]     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
[HTTP] --> POST /wd/hub/wd-internal/session/182f1301-cb7d-4a44-af3d-c71744ad758f/appium/start_recording_screen
[HTTP] {"options":{"videoType":"libx264","videoFps":10,"timeLimit":1800}}
[debug] [EspressoDriver@65ce (182f1301)] Calling AppiumDriver.startRecordingScreen() with args: [{"videoType":"libx264","videoFps":10,"timeLimit":1800},"182f1301-cb7d-4a44-af3d-c71744ad758f"]
[AppiumDriver@ce67] Plugins which can handle cmd 'startRecordingScreen': appium-dashboard,device-farm
[AppiumDriver@ce67] Plugin device-farm is now handling cmd 'startRecordingScreen'
[device-farm] Received startRecordingScreen request on driver - [object Object]
[AppiumDriver@ce67] Plugin appium-dashboard is now handling cmd 'startRecordingScreen'
[AppiumDriver@ce67] Executing default handling behavior for command 'startRecordingScreen'
[debug] [ADB] Getting IDs of all 'screenrecord' processes
[debug] [ADB] Running 'C:\Users\BudovskiyVal\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 18123522502223 shell 'pgrep --help; echo $?''
[debug] [ADB] Running 'C:\Users\BudovskiyVal\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 18123522502223 shell pgrep -f \(\[\[:blank:\]\]\|\^\)screenrecord\(\[\[:blank:\]\]\|\$\)'
[EspressoDriver@65ce (182f1301)] Screen recording has not been previously started by Appium. There is nothing to stop
[debug] [ADB] Getting IDs of all 'screenrecord' processes
[debug] [ADB] Running 'C:\Users\BudovskiyVal\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 18123522502223 shell pgrep -f \(\[\[:blank:\]\]\|\^\)screenrecord\(\[\[:blank:\]\]\|\$\)'
[debug] [ADB] Building screenrecord process with the command line: adb -P 5037 -s 18123522502223 shell screenrecord --time-limit 180 /sdcard/8f0eabba.mp4
[debug] [ADB] Running 'C:\Users\BudovskiyVal\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 18123522502223 shell "[ -e '/sdcard/8f0eabba.mp4' ] && echo __PASS__"'
[debug] [ADB] Running 'C:\Users\BudovskiyVal\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 18123522502223 shell "[ -e '/sdcard/8f0eabba.mp4' ] && echo __PASS__"'
[debug] [EspressoDriver@65ce (182f1301)] Responding to client with driver.startRecordingScreen() result: ""
[HTTP] <-- POST /wd/hub/session/182f1301-cb7d-4a44-af3d-c71744ad758f/appium/start_recording_screen 200 614 ms - 12
[HTTP]
[debug] [AppiumDriver@ce67] Encountered internal error running command: SequelizeValidationError: notNull Violation: Session.platform cannot be null,
[debug] [AppiumDriver@ce67] notNull Violation: Session.udid cannot be null
[debug] [AppiumDriver@ce67]     at InstanceValidator._validate (C:\Users\BudovskiyVal\node_modules\sequelize\src\instance-validator.js:78:13)
[debug] [AppiumDriver@ce67]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[debug] [AppiumDriver@ce67]     at InstanceValidator._validateAndRunHooks (C:\Users\BudovskiyVal\node_modules\sequelize\src\instance-validator.js:111:7)
[debug] [AppiumDriver@ce67]     at InstanceValidator.validate (C:\Users\BudovskiyVal\node_modules\sequelize\src\instance-validator.js:93:12)
[debug] [AppiumDriver@ce67]     at Session.save (C:\Users\BudovskiyVal\node_modules\sequelize\src\model.js:3996:7)
[debug] [AppiumDriver@ce67]     at Function.create (C:\Users\BudovskiyVal\node_modules\sequelize\src\model.js:2280:12)
[HTTP] <-- POST /wd/hub/session 500 64508 ms - 852
[HTTP]
[debug] [HTTP] Request idempotency key: d31e82f0-2295-41a6-82d3-ec047778e907
[HTTP] --> POST /wd/hub/session

Im a bit confused, why the session udid is lost. The session started running fine with an ID. Maybe its the error with cat on cpuinfo that caused this? Can i disable device profiling or screenrecord features to test it? Thank you in advance!

ValzRon commented 1 year ago

Ok so I ran this with some changed parameters and got an idea now what the problem is: [debug] [EspressoDriver@d495 (143aa0aa)] Encountered internal error running command: Error: Screen recording does not work on emulators running Android API level less than 27 Indeed I am running it with an emulator with a fairly old API level 23. Is there a way to turn off screenrecord in the appium startup (an arg flag or inside --config file for example) ?

Edit: Tried API 27 so screenrecord works. However the topic issue is still there. So the Issue seems to be with cat on cpuinfo. If I do adb shell cat /proc/cpuinfo from my host machine it works and ive also enabled the relaxed-security flag for adb shell in appium

sudharsan-selvaraj commented 1 year ago

The issue is not related to screen recording. There are few logics specific to EspressoDriver is not handled in the dashboard. Will take a look into it.