AppiumTestDistribution / appium-reporter-plugin

Appium2 plugin to generate html report with screenshots.
Apache License 2.0
30 stars 12 forks source link

TypeError: driver.getScreenshot is not a function #142

Closed elviofreitas closed 8 months ago

elviofreitas commented 11 months ago

Found some issues using this plugin.

[Appium] Attempting to load plugin images... [debug] [Appium] Requiring plugin at C:\Users\admin.appium\node_modules\@appium\images-plugin [Appium] Attempting to load plugin appium-reporter-plugin... [debug] [Appium] Requiring plugin at C:\Users\admin.appium\node_modules\appium-reporter-plugin [appium-reporter-plugin] C:\Users\admin.appium\node_modules\appium-reporter-plugin\lib/data is deleted. [Appium] Welcome to Appium v2.0.1 [Appium] Non-default server args: [Appium] { [Appium] address: '127.0.0.1', [Appium] sessionOverride: true, [Appium] useDrivers: [ [Appium] 'windows' [Appium] ], [Appium] usePlugins: [ [Appium] 'images', [Appium] 'appium-reporter-plugin' [Appium] ] [Appium] } [Appium] Attempting to load driver windows... [debug] [Appium] Requiring driver at C:\Users\admin.appium\node_modules\appium-windows-driver [Appium] Appium REST http interface listener started on http://127.0.0.1:4723 [Appium] Available drivers: [Appium] - xcuitest@5.8.1 (automationName 'XCUITest') [Appium] - uiautomator2@2.34.0 (automationName 'UiAutomator2') [Appium] - gecko@1.2.7 (automationName 'Gecko') [Appium] - chromium@1.2.32 (automationName 'Chromium') [Appium] - windows@2.12.10 (automationName 'Windows') [Appium] Available plugins: [Appium] - images@2.1.6 (ACTIVE) [Appium] - appium-reporter-plugin@1.1.0-beta.04 (ACTIVE) [HTTP] --> GET /status [HTTP] {} [debug] [AppiumDriver@b3ae] Calling AppiumDriver.getStatus() with args: [] [AppiumDriver@b3ae] Plugins which can handle cmd 'getStatus': images,appium-reporter-plugin [AppiumDriver@b3ae] Plugin appium-reporter-plugin is now handling cmd 'getStatus' [appium-reporter-plugin] session: null; cmd getStatus; processing command: getStatus [AppiumDriver@b3ae] Plugin images is now handling cmd 'getStatus' [AppiumDriver@b3ae] Executing default handling behavior for command 'getStatus' [appium-reporter-plugin] session: null; cmd getStatus; time taken by appium for cmd execution: 452 μs [appium-reporter-plugin] session: null; cmd getStatus; Command not in exlusion list for screenshot [appium-reporter-plugin] session: null; cmd getStatus; Failed to take screenshot [appium-reporter-plugin] TypeError: driver.getScreenshot is not a function [appium-reporter-plugin] at ReportPlugin. (C:\Users\admin.appium\node_modules\appium-reporter-plugin\lib\plugin.js:103:53) [appium-reporter-plugin] at Generator.next () [appium-reporter-plugin] at fulfilled (C:\Users\admin.appium\node_modules\appium-reporter-plugin\lib\plugin.js:5:58) [appium-reporter-plugin] at processTicksAndRejections (node:internal/process/task_queues:95:5) [appium-reporter-plugin] session: null; cmd getStatus; time appium took for screenshot: 1.84 ms [debug] [AppiumDriver@b3ae] Encountered internal error running command: TypeError: Cannot read properties of undefined (reading 'split') [debug] [AppiumDriver@b3ae] at ReportPlugin. (C:\Users\admin.appium\node_modules\appium-reporter-plugin\lib\plugin.js:112:49) [debug] [AppiumDriver@b3ae] at Generator.next () [debug] [AppiumDriver@b3ae] at fulfilled (C:\Users\admin.appium\node_modules\appium-reporter-plugin\lib\plugin.js:5:58) [debug] [AppiumDriver@b3ae] at processTicksAndRejections (node:internal/process/task_queues:95:5) [HTTP] <-- GET /status 500 23 ms - 747

Dileep17 commented 11 months ago

@elviofreitas Thank you for reporting the issue.

I found the problem that's causing

 Encountered internal error running command: TypeError: Cannot read properties of undefined (reading 'split')

It's a minor fix, but I would take some time to fix this. Will update once fixed and new release is made. Please do report any other issues you face.

hithisistushar commented 9 months ago

Hi @Dileep17, I'm facing the same issue. Any updates on the fix?

Dileep17 commented 9 months ago

Ah! My bad. Missed this. Will fix this ASAP.

Dileep17 commented 9 months ago

@hithisistushar fixed and released 1.1.0-beta.05. Please install 1.1.0-beta.05 and let me know it fixed the issue.

hithisistushar commented 9 months ago

@Dileep17 Still getting the same error

TypeError: driver.getScreenshot is not a function at ReportPlugin.<anonymous> (/Users/username/.appium/node_modules/appium-reporter-plugin/lib/plugin.js:103:53) at Generator.next (<anonymous>) at fulfilled (/Users/username/.appium/node_modules/appium-reporter-plugin/lib/plugin.js:5:58) at processTicksAndRejections (node:internal/process/task_queues:95:5)

Dileep17 commented 9 months ago

@hithisistushar could you

  1. Confirm you are on 1.1.0-beta.5
  2. Share the code to reproduce the error

Thanks!

hithisistushar commented 9 months ago

@Dileep17

  1. image

  2. I just followed the sample Java implementation from the plugin readme. I get the error as soon as I start the execution.

Dileep17 commented 9 months ago

@hithisistushar Java implementation is running fine on my machine! I had to bump up appium java client to latest version, but that shouldn't be the reason for the issue you are facing!

Could you write a test to take a screenshot and run it without reporter plugin to verify if screenshots are working fine on your machine? We will take our investigation forward from there.

Unrelated to the issue you mentioned, based on the screenshot you provided, I see Unable to create /Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/data >> this is error from plugin. data will be used by plugin to store test execution data. Check the permissions.

hithisistushar commented 9 months ago

@Dileep17 I am already on the latest appium version.

image

Wrote a simple method to capture screenshots and save it to a folder and I'm able to save them. (Did not use the reporter plugin)

image

Also, thanks for pointing the issue out, I gave permissions and now I see Requiring plugin at /Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/index.js [appium-reporter-plugin] /Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/data is deleted. which I guess what I should see.

Dileep17 commented 9 months ago

@hithisistushar Yeah.. There is a lot missing when data folder is created. Will add it in next release.

Reg. the error you are getting, I couldn't reproduce it in any manner!! Could you share the whole server log?? My only guess is that driver object is null and hence the not a method error!

hithisistushar commented 9 months ago

2024-01-22 12:25:29:009 [AppiumDriver@d97a] Calling AppiumDriver.getStatus() with args: [] 2024-01-22 12:25:29:011 [AppiumDriver@d97a] Plugins which can handle cmd 'getStatus': images,appium-reporter-plugin 2024-01-22 12:25:29:011 [AppiumDriver@d97a] Plugin appium-reporter-plugin is now handling cmd 'getStatus' 2024-01-22 12:25:29:011 [appium-reporter-plugin] session: null; cmd getStatus; processing command: getStatus 2024-01-22 12:25:29:011 [AppiumDriver@d97a] Plugin images is now handling cmd 'getStatus' 2024-01-22 12:25:29:011 [AppiumDriver@d97a] Executing default handling behavior for command 'getStatus' 2024-01-22 12:25:29:012 [appium-reporter-plugin] session: null; cmd getStatus; time taken by appium for cmd execution: 409 μs 2024-01-22 12:25:29:012 [appium-reporter-plugin] session: null; cmd getStatus; Command not in exlusion list for screenshot 2024-01-22 12:25:29:012 [appium-reporter-plugin] session: null; cmd getStatus; Failed to take screenshot 2024-01-22 12:25:29:014 [appium-reporter-plugin] TypeError: driver.getScreenshot is not a function 2024-01-22 12:25:29:014 [appium-reporter-plugin] at ReportPlugin. (/Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/plugin.js:103:53) 2024-01-22 12:25:29:014 [appium-reporter-plugin] at Generator.next () 2024-01-22 12:25:29:014 [appium-reporter-plugin] at fulfilled (/Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/plugin.js:5:58) 2024-01-22 12:25:29:014 [appium-reporter-plugin] at processTicksAndRejections (node:internal/process/task_queues:96:5) 2024-01-22 12:25:29:014 [appium-reporter-plugin] session: null; cmd getStatus; time appium took for screenshot: 2.44 ms 2024-01-22 12:25:29:014 [appium-reporter-plugin] session: null; cmd getStatus; time took to process image: 1.25 μs 2024-01-22 12:25:29:016 [appium-reporter-plugin] TypeError: driver.getSession is not a function 2024-01-22 12:25:29:016 [appium-reporter-plugin] at /Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/reporter.js:33:39 2024-01-22 12:25:29:016 [appium-reporter-plugin] at Generator.next () 2024-01-22 12:25:29:016 [appium-reporter-plugin] at /Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/reporter.js:8:71 2024-01-22 12:25:29:016 [appium-reporter-plugin] at new Promise () 2024-01-22 12:25:29:016 [appium-reporter-plugin] at __awaiter (/Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/reporter.js:4:12) 2024-01-22 12:25:29:016 [appium-reporter-plugin] at initReport (/Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/reporter.js:28:12) 2024-01-22 12:25:29:016 [appium-reporter-plugin] at Object. (/Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/reporter.js:129:19) 2024-01-22 12:25:29:016 [appium-reporter-plugin] at Generator.next () 2024-01-22 12:25:29:016 [appium-reporter-plugin] at fulfilled (/Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/reporter.js:5:58) 2024-01-22 12:25:29:016 [appium-reporter-plugin] at processTicksAndRejections (node:internal/process/task_queues:96:5) 2024-01-22 12:25:29:016 [appium-reporter-plugin] Failed to extract sessionId & capabilities from driver Object: 2024-01-22 12:25:29:016 [appium-reporter-plugin] {"_log":{"levels":["silly","verbose","debug","info","http","warn","error"],"prefix":"AppiumDriver@d97a","level":"silent"},"opts":{"subcommand":"server","address":"0.0.0.0","allowInsecure":["chromedriver_autodownload"],"basePath":"/wd/hub/","logFile":"/Users/tushar.raj/Documents/PPSN/Code/hellott/test/hello-plus-tt-auto/appium.log","loglevel":"debug","port":34829,"sessionOverride":true,"usePlugins":["ocr","images","appium-reporter-plugin"],"extraArgs":[],"allowCors":false,"callbackPort":4723,"debugLogSpacing":false,"denyInsecure":[],"keepAliveTimeout":600,"localTimezone":false,"logNoColors":false,"logTimestamp":false,"longStacktrace":false,"noPermsCheck":false,"relaxedSecurityEnabled":false,"strictCaps":false,"useDrivers":[],"driver":{"xcuitest":{"wdaLocalPort":8100}},"plugin":{"device-farm":{"androidDeviceType":"both","iosDeviceType":"both"}},"tmpDir":"/var/folders/5p/zjyqlyhd2596w6_28hbsnj1m0000gs/T"},"shouldValidateCaps":true,"initialOpts":{"subcommand":"server","address":"0.0.0.0","allowInsecure":["chromedriver_autodownload"],"basePath":"/wd/hub/","logFile":"/Users/tushar.raj/Documents/PPSN/Code/hellott/test/hello-plus-tt-auto/appium.log","loglevel":"debug","port":34829,"sessionOverride":true,"usePlugins":["ocr","images","appium-reporter-plugin"],"extraArgs":[],"allowCors":false,"callbackPort":4723,"debugLogSpacing":false,"denyInsecure":[],"keepAliveTimeout":600,"localTimezone":false,"logNoColors":false,"logTimestamp":false,"longStacktrace":false,"noPermsCheck":false,"relaxedSecurityEnabled":false,"strictCaps":false,"useDrivers":[],"driver":{"xcuitest":{"wdaLocalPort":8100}},"plugin":{"device-farm":{"androidDeviceType":"both","iosDeviceType":"both"}},"tmpDir":"/var/folders/5p/zjyqlyhd2596w6_28hbsnj1m0000gs/T"},"sessionId":null,"helpers":{},"basePath":"/wd/hub","relaxedSecurityEnabled":false,"allowInsecure":[],"denyInsecure":[],"newCommandTimeoutMs":0,"implicitWaitMs":0,"locatorStrategies":[],"webLocatorStrategies":[],"managedDrivers":[],"noCommandTimer":null,"_eventHistory":{"commands":[]},"eventEmitter":{"_events":{},"_eventsCount":0},"shutdownUnexpectedly":false,"commandsQueueGuard":{"queues":{},"domainReentrant":false,"timeout":0,"maxOccupationTime":0,"maxExecutionTime":0,"maxPending":1000},"settings":{"_settings":{}},"args":{"subcommand":"server","address":"0.0.0.0","allowInsecure":["chromedriver_autodownload"],"basePath":"/wd/hub/","logFile":"/Users/tushar.raj/Documents/PPSN/Code/hellott/test/hello-plus-tt-auto/appium.log","loglevel":"debug","port":34829,"sessionOverride":true,"usePlugins":["ocr","images","appium-reporter-plugin"],"extraArgs":[],"allowCors":false,"callbackPort":4723,"debugLogSpacing":false,"denyInsecure":[],"keepAliveTimeout":600,"localTimezone":false,"logNoColors":false,"logTimestamp":false,"longStacktrace":false,"noPermsCheck":false,"relaxedSecurityEnabled":false,"strictCaps":false,"useDrivers":[],"driver":{"xcuitest":{"wdaLocalPort":8100}},"plugin":{"device-farm":{"androidDeviceType":"both","iosDeviceType":"both"}},"tmpDir":"/var/folders/5p/zjyqlyhd2596w6_28hbsnj1m0000gs/T"},"sessions":{},"pendingDrivers":{},"pluginClasses":{},"sessionPlugins":{},"sessionlessPlugins":[{"name":"ocr","cliArgs":{},"logger":{"levels":["silly","verbose","debug","info","http","warn","error"],"prefix":"Plugin [ocr]","level":"silent"},"isInOcrContext":false,"isWorkerReady":false,"ocrElements":{}},{"name":"images","cliArgs":{},"logger":{"levels":["silly","verbose","debug","info","http","warn","error"],"prefix":"Plugin [images]","level":"silent"},"finder":{"_imgElCache":{"ttl":86400000,"ttlResolution":1,"ttlAutopurge":false,"updateAgeOnGet":true,"updateAgeOnHas":false,"allowStale":false,"noDisposeOnSet":false,"noUpdateTTL":false,"maxEntrySize":0,"noDeleteOnFetchRejection":false,"noDeleteOnStaleGet":false,"allowStaleOnFetchAbort":false,"allowStaleOnFetchRejection":false,"ignoreFetchAbort":false}}},{"name":"appium-reporter-plugin","cliArgs":{},"logger":{"levels":["silly","verbose","debug","info","http","warn","error"],"prefix":"Plugin [appium-reporter-plugin]","level":"silent"}}],"desiredCapConstraints":{"automationName":{"presence":true,"isString":true},"platformName":{"presence":true,"isString":true}},"driverConfig":{"extensionType":"driver","installedExtensions":{"uiautomator2":{"pkgName":"appium-uiautomator2-driver","version":"2.29.2","installType":"npm","installSpec":"uiautomator2","installPath":"/Users/tushar.raj/.appium/node_modules/appium-uiautomator2-driver","appiumVersion":"^2.0.0-beta.40","automationName":"UiAutomator2","platformNames":["Android"],"mainClass":"AndroidUiautomator2Driver","scripts":{"reset":"scripts/reset.js"}},"xcuitest":{"pkgName":"appium-xcuitest-driver","version":"4.32.23","installType":"npm","installSpec":"xcuitest","installPath":"/Users/tushar.raj/.appium/node_modules/appium-xcuitest-driver","appiumVersion":"^2.0.0-rc.2","automationName":"XCUITest","platformNames":["iOS","OS"],"mainClass":"XCUITestDriver","scripts":{"build-wda":"./scripts/build-wda.js","open-wda":"./scripts/open-wda.js"},"schema":{"$schema":"http://json-schema.org/draft-07/schema","type":"object","properties":{"webdriveragent-port":{"appiumCliDest":"wdaLocalPort","default":8100,"description":"Local port used for communication with WebDriverAgent","maximum":65535,"minimum":1,"type":"integer"}},"additionalProperties":false,"title":"XCUITest Driver Configuration","description":"Appium configuration schema for the XCUITest driver.","$id":"driver-xcuitest.json"}},"":{"pkgName":"appium--driver","version":"0.8.1","installType":"npm","installSpec":"appium---driver","installPath":"/Users/tushar.raj/.appium/node_modules/appium---driver","appiumVersion":"^2.0.0-beta.46","automationName":"","platformNames":[""],"mainClass":"Driver","scripts":{"pair-remote":"./build/lib/rc-pair.js"}},"":{"pkgName":"@headspinio/appium--driver","version":"2.2.0","installType":"npm","installSpec":"","installPath":"/Users/tushar.raj/.appium/node_modules/@headspinio/appium--driver","appiumVersion":"^2.0.0-beta.35","automationName":"","platformNames":[""],"mainClass":"Driver"},"":{"pkgName":"appium-lg--driver","version":"0.1.1","installType":"npm","installSpec":"appium-lg--driver","installPath":"/Users/tushar.raj/.appium/node_modules/appium-lg--driver","appiumVersion":"^2.0.0-beta.40","automationName":"","platformNames":["LG"],"mainClass":"Driver"}},"manifest":{},"knownAutomationNames":{}},"server":{"_events":{"request":[null,null],"connection":[null,null]},"_eventsCount":3,"_connections":1,"_handle":{"reading":false},"_usingWorkers":false,"_workers":[],"_unref":false,"allowHalfOpen":true,"pauseOnConnect":false,"noDelay":false,"keepAlive":false,"keepAliveInitialDelay":0,"httpAllowHalfOpen":false,"timeout":0,"keepAliveTimeout":600000,"maxHeadersCount":null,"maxRequestsPerSocket":0,"headersTimeout":605000,"requestTimeout":0,"_connectionKey":"4:0.0.0.0:34829"}} 2024-01-22 12:25:29:017 [AppiumDriver@d97a] Encountered internal error running command: TypeError: driver.getSession is not a function 2024-01-22 12:25:29:017 [AppiumDriver@d97a] at /Users/tushar.raj/.appium/node_modules/appium-reporter-plugin/lib/reporter.js:33:39

Dileep17 commented 8 months ago

@hithisistushar for some reason even after session is created, when getStatus comes to plugin, driver/session is null! I have bypassed screenshot flow when driver/session is null. Please try latest version!

occupied with other things, Sorry for delay! hope this resolves the error you are facing.

hithisistushar commented 8 months ago

@Dileep17 Working with the latest version, thanks for the fix.