Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Worked in 2.1, but exception in 2.2 #2456

Closed
Delagen opened this issue Aug 27, 2015 · 11 comments
Closed

Worked in 2.1, but exception in 2.2 #2456

Delagen opened this issue Aug 27, 2015 · 11 comments

Comments

@Delagen
Copy link

Delagen commented Aug 27, 2015

TypeError: Cannot read property 'onPageLoad' of undefined
  From: Task: <anonymous>
      at Context.initFn (..\index.js:18:12)
  From: Task: "before all" hook
var initFn = function() {
            browser.manage().deleteAllCookies();
            browser.get("/");
        };

        describe("task1", function() {
            before(initFn);
...
        });
@alanstott
Copy link

+1

Fatal error: Cannot call method 'onPageLoad' of undefined

@cletusw
Copy link

cletusw commented Aug 28, 2015

+1 I'm also getting this. Works on 2.1.0 but fails with 2.2.0. With more explicit promise handling I get a fuller stacktrace:

Cannot read property 'onPageLoad' of undefined
TypeError: Cannot read property 'onPageLoad' of undefined
    at --OMITTED ROOT--/node_modules/protractor/lib/protractor.js:606:25
    at [object Object].promise.ControlFlow.runInFrame_ (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
    at [object Object].promise.ControlFlow.runEventLoop_ (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1755:8)
    at [object Object].<anonymous> (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2056:12)
    at goog.async.run.processWorkQueue (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21)
    at runMicrotasksCallback (node.js:337:7)
    at process._tickCallback (node.js:355:11)
From: Task: <anonymous>
    at [object Object].Protractor.get (--OMITTED ROOT--/node_modules/protractor/lib/protractor.js:605:29)
    at --OMITTED ROOT--/jstest/ui/bootstrap.js:49:20
    at [object Object].promise.ControlFlow.runInFrame_ (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
    at [object Object].promise.Callback_.goog.defineClass.notify (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
    at [object Object].promise.Promise.notify_ (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)
    at Array.forEach (native)
    at Object.goog.array.forEach (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/array/array.js:203:43)
    at [object Object].promise.Promise.notifyAll_ (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:552:16)
    at goog.async.run.processWorkQueue (--OMITTED ROOT--/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21)
    at runMicrotasksCallback (node.js:337:7)
  1) "before all" hook

where --OMITTED--/jstest/ui/bootstrap.js:49:20 is:

return browser.get('/noop');

@lyttlegy
Copy link

lyttlegy commented Sep 4, 2015

+1

@philokev
Copy link

Getting this error as well:

  TypeError: Cannot read property 'onPageLoad' of undefined
    at /home/kev/node_modules/protractor-cucumber/node_modules/protractor/lib/protractor.js:608:25
    at [object Object].promise.ControlFlow.runInFrame_ (/home/kev/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
    at [object Object].promise.ControlFlow.runEventLoop_ (/home/kev/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1729:8)
    at [object Object].eval (/home/kev/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2043:12)
    at goog.async.run.processWorkQueue (/home/kev/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21)
    at process._tickDomainCallback (node.js:399:9)

  From: Task: <anonymous>
    at [object Object].Protractor.get (/home/kev/node_modules/protractor-cucumber/node_modules/protractor/lib/protractor.js:605:29)
    at [object Object].Wanderlust.go (/home/kev/WebstormProjects/TestsForIreland/features/step_definitions/lib/Wanderlust.js:13:31)
    at World.<anonymous> (/home/kev/WebstormProjects/TestsForIreland/features/step_definitions/my_steps.js:29:27)
    at World.<anonymous> (/home/kev/WebstormProjects/TestsForIreland/features/step_definitions/my_steps.js:21:9)
    at doNTCallback0 (node.js:407:9)
    at process._tickDomainCallback (node.js:377:13)
    at Function.Module.runMain (module.js:477:11)
    at startup (node.js:117:18)
    at node.js:951:3

@ghost
Copy link

ghost commented Sep 16, 2015

+1

@philokev
Copy link

I get this error when trying to return a promise to CucumberJS:

this.Given(/^I am on the Wanderlust website$/, function() {
    return this.browser.get("http://mywanderlust.co/");
});

which is supposed to support this feature:

https://github.com/cucumber/cucumber-js#promises

philokev pushed a commit to philokev/ProtCuke that referenced this issue Sep 18, 2015
Tests aren't running yet due to a bug with Protractor (see angular/protractor#2456 (comment))
@juliemr
Copy link
Member

juliemr commented Sep 25, 2015

This looks like it was due to changes in the plugins. We've started assuming that instances of Protractor have a plugins_ property. This is a bug, and the fix will just be checking that it actually exists. See https://github.com/angular/protractor/blob/master/lib/protractor.js#L570

@juliemr juliemr added this to the 2.3 milestone Sep 25, 2015
@juliemr juliemr self-assigned this Sep 25, 2015
@juliemr
Copy link
Member

juliemr commented Sep 25, 2015

FYI - @sjelin we should make sure that the Protractor class does not rely on the setup done in runner.js.

sjelin added a commit to sjelin/protractor that referenced this issue Sep 25, 2015
sjelin added a commit to sjelin/protractor that referenced this issue Sep 25, 2015
@sjelin sjelin closed this as completed in 1487e5a Sep 28, 2015
@cletusw
Copy link

cletusw commented Sep 28, 2015

@sjelin 1487e5a didn't actually fix my problem. I was creating an instance of Runner, then calling .createBrowser() on it with no arguments, which was blindly replacing this.plugins_ with undefined. Turns out I just needed to call .createBrowser(Plugins({})). Would it maybe be better to allow createBrowser() to be called with no arguments?

@juliemr
Copy link
Member

juliemr commented Sep 28, 2015

@cletusw the Runner is not guaranteed as a public API, so we may make breaking changes to it between versions without specifically noting them as breaking changes.

That said - it looks like the internal documentation for the Runner did not get updated along with the plugins change, so we should at least fix that. https://github.com/angular/protractor/blob/master/lib/runner.js#L174 I also think it does make more sense for createBrowser to treat that parameter as optional.

@cletusw
Copy link

cletusw commented Sep 28, 2015

@juliemr I agree, what we're doing is pretty hacky. We'll start looking for a more official way to do it. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants