title: How do I navigate from an included file in Protractor?
body: <p>I have done what is mentioned in this SO question to include a file into my protractor test: <a href="https://stackoverflow.com/questions/24782783/how-to-reuse-code-in-protractor-angularjs-testing">How to reuse code in Protractor / AngularJS Testing</a>. The problem is that methods called from inside this included code have no effect on the browser window that I see.</p>
  
  <p>I created a login method in a separate file and included it, but when I call the method from my protractor test the open browser just sits there for a few seconds then continues on as if I had not called anything. I can verify that the method is getting called with a console.log. Below are my code files.</p>
  
  <p>login.js, the included login function:</p>
  
  <pre><code>exports.login = function ()
  {
      console.log("Login method called");
      it('logs in', function () {
          browser.get('http://my-url.com/login/');
  
          // log in to continue with checkout
          element(by.xpath('//*[@id="login-form"]/div[1]/input')).sendKeys("username");
          element(by.xpath('//*[@id="login-form"]/div[2]/input')).sendKeys("password");
          element(by.xpath('//*[@id="login-form"]/div[3]/button')).click();
  
          // login functions on timeout
          browser.driver.sleep(1000);
      });
  }
  </code></pre>
  
  <p>conf.js, the protractor config file:</p>
  
  <pre><code>exports.config = {
      seleniumAddress: 'http://localhost:4444/wd/hub',
      specs: [/*'specs/overview.js',*/ 'specs/shopping-cart-state.js', 'specs/checkout-state.js', 'specs/buy-item.js'],
      onPrepare: function () {
          var SpecReporter = require('jasmine-spec-reporter');
          // add jasmine spec reporter
          jasmine.getEnv().addReporter(new SpecReporter({ displayStacktrace: 'all' }));
          protractor.login = require('./login.js');
      },
      jasmineNodeOpts: {
          print: function () { },
          defaultTimeoutInterval: 5000000
      }
  };
  </code></pre>
  
  <p>spec.js, the test spec:</p>
  
  <pre><code>describe('Log in with an included function', function () {
  
      it('logs in', function () {    
  
          protractor.login.login();
  
          browser.driver.sleep(5000);
      });
  });
  </code></pre>
  
  <p>Even if I pass the browser object as a parameter to the login function, still nothing happens and I get no error messages. Can anybody tell me what I'm doing wrong?</p>