我工作的一個UI自動化項目,我想從另一個頁面對象擴展一個頁面對象。我搜索的方式來實現這一點,但無法找到我正在尋找什麼。 基本上我有這樣的代碼設置。擴展(繼承)類(或對象)在Javascript
BasePage.js
define([],
function() {
function BasePage(remote) {
this.remote = remote;
}
BasePage.prototype = {
constructor: BasePage,
// common methods to interact with page
commonMethodToIntreactWithPage : function{
return doSomething;
}
};
return BasePage;
});
LoginPage.js
define([],
function() {
function LoginPage(remote) {
this.remote = remote;
}
LoginPage.prototype = {
constructor: BasePage,
// Login Page related Methods
loginPageRelatedMethod: function{
return doSomething;
}
};
return LoginPage;
});
我想只是這樣做是爲了繼承BasePage
的方法LoginPage
:
var loginPage = new LoginPage(remote);
loginPage.commonMethodToIntreactWithPage();
只是爲了我的信息使用Intern.js
進行測試。
你可以試試'LoginPage.prototype =新的BasePage()' – amenadiel