私は2つのページを持つアプリを持っています...最初のページはログインボタンがあるランディングページです...ユーザーがこのログインボタンをクリックすると、login.htmlにリダイレクトされます....2つの入力があります。1 つはユーザー名用、もう 1 つはパスワード用です。
関連するコードは次のようになります。
index.html
<a ui-sref="login" class="fa fa-sign-in" href="/login"> Login</a>
と
login.html
<input type="text" id="username" name="username" placeholder="Username" ng-model="user.username" required="" autocomplete="off" class="ng-pristine ng-invalid ng-invalid-required">
<input type="password" name="password" placeholder="Password" ng-model="user.password" required="" autocomplete="off" class="ng-pristine ng-invalid ng-invalid-required">
私のテストでは、最初にログイン ボタンをクリックし、新しいページに正しくリダイレクトされていることを確認します。このテストはパスしますが、これらの入力ボックスに入力しようとすると、ボックスが存在しないかのようにエラーが発生します。ブラウザをスリープさせようとしましたが、それもうまくいきませんでした。
// in test/e2e/main.spec.js
describe('E2E: main page', function(){
'use strict';
var ptor;
// keep track of the protractor instance
beforeEach(function(){
browser.get('http://127.0.0.1:9000/');
ptor = protractor.getInstance();
});
it('it should load the login page once the login button is clicked', function(){
var link = element(by.css('.fa.fa-sign-in'))
link.click();
browser.sleep(4000);
expect(ptor.getCurrentUrl()).toMatch(/\/login/);
element(by.input('user.username')).sendKeys('test');
element(by.input('user.password')).sendKeys('test');
});
});
何かアドバイス?
アップデート:
by.input の代わりに by.model を使用すると動作しますが、私が読んでいた本には、最初のものも動作するはずだと書かれていました..奇妙です。