Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Unable to access variable page #22

Closed
binarykitchen opened this issue Nov 28, 2013 · 5 comments
Closed

Unable to access variable page #22

binarykitchen opened this issue Nov 28, 2013 · 5 comments

Comments

@binarykitchen
Copy link

For my e2e tests I want to be able to open pages, query for DOM and stuff like that:

var expect = chai.expect;

describe('Home page', function() {

    beforeEach(function(done) {
      page.open('/', function() {
        done();
      });
    });

    it('has canvas', function() {
        expect(element('body').html()).to.contain('canvas');
    });

    it('has more than zero links', function() {
        expect(repeater('a').count()).to.have.length.above(0);
    });
});

But grunt-karma crashes with:

Running "karma:e2e" (karma) task
INFO [karma]: Karma v0.10.6 server started at http://localhost:9012/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.2 (Mac OS X)]: Connected on socket F8cIn0t5vwZ2OeHkbbLb
PhantomJS 1.9.2 (Mac OS X) Home page "before each" hook FAILED
    ReferenceError: Can't find variable: page
        at /xxx/client/test/e2e/home.js:6
        at /xxx/node_modules/mocha/mocha.js:4250
        at next (/xxx/node_modules/mocha/mocha.js:4534)
        at /xxx/node_modules/mocha/mocha.js:4538
        at timeslice (/xxx/node_modules/mocha/mocha.js:5531)
PhantomJS 1.9.2 (Mac OS X): Executed 1 of 4 (1 FAILED) ERROR (0.101 secs / 0 secs)

So, variable page is missing. How can I get it without using require?

Been looking for examples but found none. Thanks for any clues!

@vojtajina
Copy link
Contributor

You can't access page variable - the Angular scenario runner tests run IN THE BROWSER and there is no page variable.

The page variable is available in the phantomjs script (that you write to control the phantomjs browser). If you wanna use PhantomJS and its DSL for writing high level tests, just use PhantomJS without Angular scenario runner.

@binarykitchen
Copy link
Author

@vojtajina I never mentioned that I am using Angular's scenario runner.

Do you have a working example of PhantomJS with Karma for e2e tests? Not unit tests. In the e2e tests I want to be able to fill out forms, to perform actions on DOM etc. I've been searching for a long time but found nothing useful.

@vojtajina
Copy link
Contributor

Nope, just use PhantomJS without Karma. Karma is for unit testing.

On Sun, Dec 1, 2013 at 3:03 PM, Michael Heuberger
notifications@github.comwrote:

@vojtajina https://github.com/vojtajina I never mentioned that I am
using Angular's scenario runner.

Do you have a working example of PhantomJS with Karma for e2e tests? Not
unit tests. In the e2e tests I want to be able to fill out forms, to
perform actions on DOM etc. I've been searching for a long time but found
nothing useful.


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-29586027
.

@binarykitchen
Copy link
Author

Ah, I see!! Thanks. I think this should be mentioned somewhere ...

@Siltaar
Copy link

Siltaar commented Feb 18, 2014

@binarykitchen, you may look at https://github.com/winsonwq/karma-e2e-dsl works fine for me.

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

No branches or pull requests

3 participants