これは単純な解決策を持つかもしれませんが、私はそれを見ていません。私は、分度器のテストを書き込み、ページオブジェクトファイルを設定してい取得 "未定義の[メソッド] 'プロパティを読み取ることができません
newstate.js(ページオブジェクトファイル)
'use strict';
var newstate = function (url) {
browser.get(url);
};
newstate.prototype = Object.create({}, {
dd: { select: function(state) { $('select option[value="'+state+'"]').click(); } }
});
module.exports = newstate;
spec.jsファイル:
'use strict';
var newstate = require('newstate.js');
describe('Testing newstate', function() {
var statePage;
beforeAll(function() {
statePage = new newstate('http://localhost:8080');
});
it('should select a state', function() {
statePage.dd.select('AK');
})
})
conf.jsファイル:
exports.config = {
framework: 'jasmine',
specs: ['test-spec.js'],
useAllAngular2AppRoots: true,
jasmineNodeOpts: {
showColors: true
}
};
私は分度器を実行すると、私が手:
$ protractor conf.js
Failures:
1) Testing newstate should select a state
Message:
Failed: Cannot read property 'select' of undefined
私はnew newstate('...')
を呼び出したときと同じように、ブラウザを起動してウェブページを開きますが、何らかの理由で自分のdd.select機能が表示されないようにしています。何が欠けているのか、間違っているのですか?ありがとう。
コンストラクタを 'function Newstate(...) 'として宣言する方が良いでしょう – OrangeDog