Unable to locate element in onPrepare of protractor.conf.js
<p>I'm writing e2e-tests for an AngularJS-App with <code>Jasmine</code> and <code>protractor</code>. I  have a problem with the <code>onPrepare</code>-function in the protractor.conf.js.
If I do following in a <code>beforeAll</code> it works fine:</p>

<pre><code>browser.get('/login');
element(by.id('username')).sendKeys('John');
</code></pre>

<p>but if I do this in <code>onPrepare</code></p>

<pre><code>browser.driver.get('https://localhost:9000/login');
browser.driver.findElement(by.id('username')).sendKeys('John');
</code></pre>

<p>I get this error:</p>

<pre><code>NoSuchElementError: no such element: Unable to locate element:    {"method":"css selector","selector":"*[id="username"]"}
</code></pre>

<p>Any hints?</p>

<p>P.S.: In the protractor docu there is link to this example that I used as pattern: <a href="https://github.com/angular/protractor/blob/master/spec/withLoginConf.js" rel="nofollow">https://github.com/angular/protractor/blob/master/spec/withLoginConf.js</a></p>