wswebcreation / protractor-image-comparison

npm-module to compare images with protractor
86 stars 38 forks source link

android/chrome (android studio emulator): Error: Timeout - Async callback was not invoked #108

Closed roperezp closed 4 years ago

roperezp commented 5 years ago

NOTE: Be aware of the fact that this module is only a plugin that provides all functionality from webdriver-image-comparison. So please check if this is an issue with this plugin or with webdriver-image-comparison.

Environment (please complete the following information):

protractor:

capabilities = {
  browserName: 'chrome',
  platformName: 'Android',
  automationName: 'UiAutomator2',
  clearSystemFiles: true,
  platformVersion: '10',
  deviceName: 'emulator-5554'
};

protractor-image-comparison:

package: 'protractor-image-comparison',
      options: {
        baselineFolder: join(process.cwd(), './e2e/baseline/'),
        formatImageName: `{tag}-{logName}-{width}x{height}`,
        screenshotPath: join(process.cwd(), './e2e/.tmp/'),
        savePerInstance: true,
        returnAllCompareData: true,
        debug: true,
        autoSaveBaseline: true
      },

jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },

Test:

  it('Empty Test', async (done) => {
    await browser.imageComparison.saveScreen('examplePaged', { /* some options*/ });
    expect(await browser.imageComparison.checkScreen('examplePaged', { /* some options*/ })).toEqual(0);
    done();
  });

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Multiple asynchronous test are completing successfully with same configuration, the issue was introduced once calling await browser.imageComparison.saveScreen(). Please note same configuration is working as expected (running same sample test) on desktop chrome/safari.

- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
          at listOnTimeout (internal/timers.js:531:17)
          at processTimers (internal/timers.js:475:7)
      - Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
          at listOnTimeout (internal/timers.js:531:17)
          at processTimers (internal/timers.js:475:7)
(node:82301) UnhandledPromiseRejectionWarning: CancellationError: ControlFlow was reset
    at Function.wrap (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/promise.js:749:14)
    at ManagedPromise.cancel (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/promise.js:1265:38)
    at TaskQueue.abort_ (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/promise.js:3013:34)
    at ControlFlow.cancelQueues_ (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/promise.js:2643:11)
    at ControlFlow.reset (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/promise.js:2377:10)
    at OnTimeoutReporter.callback (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/jasminewd2/index.js:236:17)
    at OnTimeoutReporter.specDone (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/jasminewd2/index.js:348:14)
    at dispatch (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4366:28)
    at ReportDispatcher.specDone (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:4337:11)
    at Spec.specResultCallback [as resultCallback] (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1175:18)
From: Task: WebDriver.takeScreenshot()
    at thenableWebDriverProxy.schedule (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
    at thenableWebDriverProxy.takeScreenshot (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/webdriver.js:1085:17)
    at run (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/protractor/built/browser.js:59:33)
    at to.<computed> (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/protractor/built/browser.js:67:16)
    at Object.<anonymous> (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/lib/methods/screenshots.ts:327:10)
    at step (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/build/methods/screenshots.js:43:23)
    at Object.next (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/build/methods/screenshots.js:24:53)
    at /Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/build/methods/screenshots.js:18:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/build/methods/screenshots.js:14:12)
(node:82301) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:82301) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

2019-09-25T19_59_29_641Z-debug.log

roperezp commented 5 years ago

Hello, after added nativeWebScreenshot: true both baseline and actual screenshots were created. However, still getting an error from webdriver-image-comparison:

Jasmine started
(node:40723) UnhandledPromiseRejectionWarning: JavascriptError: javascript error: Cannot read property '1' of null
  (Session info: chrome=74.0.3729.186)
  (Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.6 x86_64)
    at Object.checkLegacyResponse (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/http.js:509:13)
    at /Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/http.js:441:30
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.executeScript()
    at thenableWebDriverProxy.schedule (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
    at thenableWebDriverProxy.executeScript (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/selenium-webdriver/lib/webdriver.js:878:16)
    at run (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/protractor/built/browser.js:59:33)
    at to.<computed> (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/protractor/built/browser.js:67:16)
    at Object.<anonymous> (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/lib/methods/rectangles.ts:96:7)
    at step (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/build/methods/rectangles.js:32:23)
    at Object.next (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/build/methods/rectangles.js:13:53)
    at /Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/build/methods/rectangles.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/roperez/github/ncl-consumer-booking-engine/ui/node_modules/webdriver-image-comparison/build/methods/rectangles.js:3:12)
(node:40723) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:40723) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
wswebcreation commented 5 years ago

@roperezp

Sorry for my late response. Regarding your test, this is not needed

  it('Empty Test', async (done) => {
    // This can be removed, because `checkScreen` will already do the magic
    await browser.imageComparison.saveScreen('examplePaged', { /* some options*/ });
    expect(await browser.imageComparison.checkScreen('examplePaged', { /* some options*/ })).toEqual(0);
    done();
  });

See also https://github.com/wswebcreation/protractor-image-comparison#do-i-need-to-use-a-savescreenelementfullpagescreen-methods-when-i-want-to-run-checkscreenelementfullpagescreen

I looks like the ChromeDriver screenshot is timing out. This is something in Appium / ChromeDriver, not in this module. The reason why nativeWebScreenshot: true is failing has to do with the fact that the core module, https://github.com/wswebcreation/webdriver-image-comparison, doesn't support Android 10 yet, I've created a bug, see here to fix that

wswebcreation commented 4 years ago

@roperezp

I've added Android 10, in the latest release. Can you check it again?

roperezp commented 4 years ago

Hi, I just tried and it worked fine! This is my capabilities setup:


    browserName: 'chrome',
    platformName: 'Android',
    automationName: 'UiAutomator2',
    clearSystemFiles: true,
    platformVersion: '10',
    nativeWebScreenshot: true,
    norReset: true,
    chromeOpts: {
      args: [ '--no-first-run' ]
    }
wswebcreation commented 4 years ago

Awesome, thanks for getting back