2

I'm using protractor to do e2e testing on an angular web-app. We are splitting the specs from "pages files" describing the pages where action / DOM selction are described as functions (for example clickOnRedButton() {return element.(by.css('.redButton')).click(); }) We have to load these "page files" on our spec files with the require js of protractor, relativly to the position of the spec file, like this :

var LaunchFunnelPage = require('../../pages/launchFunnelPage');

describe('Add New Account Modal:', function () {
    var launchFunnelPage = new LaunchFunnelPage();

    beforeEach(function () {
        promise = launchFunnelPage.go();
});

it("Close popup", function () {
    promise
        .then(function () {
//...

Is there a way to load the files absolutly, which will gives something like : var LaunchFunnelPage = require('./pages/launchFunnelPage');

I was thinking of writing a require.config but I didn't manage to access it.

dekajoo
  • 2,024
  • 1
  • 25
  • 36
  • 2
    Correct me if I'm wrong - basically you don't like the directory traversal part `..` and want to have a base default path to be the root directory, so that in any spec you can just start the path with `./pages/`? – alecxe Feb 06 '15 at 17:21
  • 1
    possible duplicate of [Using require with relative paths](http://stackoverflow.com/questions/31491952/using-require-with-relative-paths) – alecxe Jul 25 '15 at 20:30
  • Just a small correction, in your question description above, you mention 'on our spec files with the require js of protractor' - the require method here is node's require and not the requirejs's require. – Praym Aug 23 '15 at 09:30

0 Answers0