1
テストワゴンに飛び乗ってウェブサイトのE2Eテストを実装しましたが、面倒な小さな問題に遭遇しました。分度器、失敗:不明なエラー:カスタム入力フィールドに要素をフォーカスできません
フィールドを選択してその入力フィールドにキーを送信して値を変更しようとしていますが、唯一の問題は「失敗:不明なエラー:要素をフォーカスできません」というエラーです。私は他のフィールドで作業していますが、この設定のものではありません。
pageObjectファイル。
var profilePage = function() {
this.firstName = element(by.id('firstname'));
this.lastName = element(by.id('lastname'));
this.saveBtn = element(by.css('ng-click="saveLocalAccount()"'));
this.cancelBtn = element(by.css('ng-click="cancelChanges()"'));
this.changeName = function(firstname, lastname) {
this.firstName.click();
var input = firstName.element(by.css('input'));
input.click();
this.input.sendKeys(firstname);
this.lastName.click();
this.lastName.sendKeys(lastname);
browser.waitForAngular();
}
};
module.exports = new profilePage();
仕様です。
var profilePage = require('TestProtractor/E2E/PageObjects/profile.pageObject.js');
describe('Testing the profile page functionality', function() {
var firstNameTest = "firstTest";
var lastNameTest = "lastTest";
it('Navigate to profile page.' ,function() {
browser.get('xxx');
expect(browser.getCurrentUrl())
.toContain('xxx');
});
it('Should change the firstname and lastname successfully', function() {
profilePage.changeName(firstNameTest, lastNameTest);
expect(element(by.id('firstname')).getText()).toContain(firstNameTest);
expect(element(by.id('lastname')).getText()).toContain(firstNameTest);
});
});
HTML