0

running into a road block and for the life of me, cant find anything on google

I am using serenity-js, currently does not have refresh interaction, therefore created one locally.

here is my class :

import {browser, protractor} from 'protractor';
import {Interaction} from '@serenity-js/core/lib/screenplay';
import {BrowseTheWeb, UsesAbilities} from 'serenity-js/lib/screenplay-protractor';

export class Refresh implements Interaction {

  static browser(): Refresh {
    return new Refresh();
  }

  performAs(actor: UsesAbilities): PromiseLike<void> {
    return protractor.browser.refresh().then(console.log(protractor.browser));
  }
}

here is the task where I am calling it, this works flawlessly when --headless mode is off inside my protractor.conf.js however blows up when --headless mode on after the refresh spits out into console.log stating it was hit. The error that occurs is just a timeout error from the steps file.

export class OpenPdf implements Task {
  constructor(private columnHeader: string, private invNumLinkToPDF: string) {
  }

  static insideDocuments(columnHeader: string, invNumLinkToPDF: string): OpenPdf {
    return new OpenPdf(columnHeader, invNumLinkToPDF);
  }

  performAs(actor: PerformsTasks): PromiseLike<void> {
    return actor.attemptsTo(
      Click.on(AccountInfoUI.pdf.link(this.columnHeader, this.invNumLinkToPDF)),
      Wait.for(Duration.ofMillis(3000)),
      Switch.toPopupWindow(),
      UseAngular.disableSynchronisation(),
      Refresh.browser(),
    );
  }
}

heres the output after the test:

    Cucumber test run has failed.
[09:34:58] E/launcher - Error: TimeoutError: timeout
  (Session info: headless chrome=67.0.3396.87)
  (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)
    at Object.checkLegacyResponse (C:\dev\account-frontend\node_modules\selenium-webdriver\lib\error.js:546:15)
    at parseHttpResponse (C:\dev\account-frontend\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (C:\dev\account-frontend\node_modules\selenium-webdriver\lib\http.js:441:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
From: Task: WebDriver.takeScreenshot()
    at Driver.schedule (C:\dev\account-frontend\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
    at Driver.takeScreenshot (C:\dev\account-frontend\node_modules\selenium-webdriver\lib\webdriver.js:1085:17)
    at run (C:\dev\account-frontend\node_modules\protractor\built\browser.js:59:33)
    at ProtractorBrowser.to.(anonymous function) [as takeScreenshot] (C:\dev\account-frontend\node_modules\protractor\built\browser.js:67:16)
    at C:\dev\account-frontend\node_modules\serenity-js\src\serenity-protractor\screenplay\abilities\browse_the_web.ts:42:41
    at C:\dev\account-frontend\node_modules\@serenity-js\core\src\recording\async.ts:4:8
    at new Promise (<anonymous>)
    at Object.defer (C:\dev\account-frontend\node_modules\@serenity-js\core\src\recording\async.ts:3:12)
    at BrowseTheWeb.takeScreenshot (C:\dev\account-frontend\node_modules\serenity-js\src\serenity-protractor\screenplay\abilities\browse_the_web.ts:42:16)
    at Photographer.photographWorkOf (C:\dev\account-frontend\node_modules\serenity-js\src\serenity-protractor\stage\photographer.ts:136:36)
    at Photographer.photograph (C:\dev\account-frontend\node_modules\serenity-js\src\serenity-protractor\stage\photographer.ts:114:38)
    at TakeAPhoto.takeAPhoto (C:\dev\account-frontend\node_modules\serenity-js\src\serenity-protractor\stage\photographer-timing.ts:25:22)
    at TimingBehaviour.takeAnAfterPhoto (C:\dev\account-frontend\node_modules\serenity-js\src\serenity-protractor\stage\photographer-timing.ts:15:20)
    at PhotoTakingStrategy.activityFinished (C:\dev\account-frontend\node_modules\serenity-js\src\serenity-protractor\stage\photographer.ts:176:25)
    at Photographer.notifyOf (C:\dev\account-frontend\node_modules\serenity-js\src\serenity-protractor\stage\photographer.ts:104:55)
    at C:\dev\account-frontend\node_modules\@serenity-js\core\src\stage\stage_manager.ts:112:53
    at Array.forEach (<anonymous>)
    at CrewMembersCommunicationChannel.notify (C:\dev\account-frontend\node_modules\@serenity-js\core\src\stage\stage_manager.ts:112:24)
    at StageManager.notifyOf (C:\dev\account-frontend\node_modules\@serenity-js\core\src\stage\stage_manager.ts:24:52)
    at Serenity.notify (C:\dev\account-frontend\node_modules\@serenity-js\core\src\serenity.ts:19:28)
    at handleStepResultEvent (C:\dev\account-frontend\node_modules\serenity-js\src\serenity-cucumber\cucumber_serenity_notifier.ts:56:18)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
kapperkp
  • 199
  • 1
  • 3
  • 14

1 Answers1

0

Your implementation seems correct at the first glance. I wonder if that's a problem with WebDriver ControlFlow and native Node Promise incompatibility... Could you try to wrap the call to protractor.browser.refresh() into a Node Promise object?

Have a look at the implementation of the BrowseTheWeb ability for reference. You'll see how I use the defer function to wrap other WebDriver-specific promises:

import { defer } from '@serenity-js/core/lib/recording/async';  // <- import `defer`

import {browser, protractor} from 'protractor';
import {Interaction} from '@serenity-js/core/lib/screenplay';
import {BrowseTheWeb, UsesAbilities} from 'serenity-js/lib/screenplay-protractor';

export class Refresh implements Interaction {

  static browser(): Refresh {
    return new Refresh();
  }

  performAs(actor: UsesAbilities): PromiseLike<void> {
    return defer(() => protractor.browser.refresh()).then(console.log(protractor.browser));
  }
}

Hope this helps!

Jan Molak
  • 4,426
  • 2
  • 36
  • 32