Protractor 如何等待从返回另一个页面对象的页面对象解析承诺?
我的页面对象文件:Protractor 如何等待从返回另一个页面对象的页面对象解析承诺?,protractor,pageobjects,Protractor,Pageobjects,我的页面对象文件: this.clickTheProvidedValueInCompanyInformation = function (item) { this.innerMenu = this.companyInformation.all(by.className('innermenu')).first(); this.selectedItem = this.innerMenu.all(by.tagName('li')).filter(function (el
this.clickTheProvidedValueInCompanyInformation = function (item) {
this.innerMenu = this.companyInformation.all(by.className('innermenu')).first();
this.selectedItem = this.innerMenu.all(by.tagName('li')).filter(function (elem, index) {
return elem.getText().then(function (text) {
return text.toUpperCase().replace(/ |-/g, '') === item.toUpperCase().replace(/ |-/g, '');
});
});
this.selectedItem.click();
this.selectedItem.getText().then(function (text) {
var option = text.toString();
var pageObject = option.replace(/ /g, '_').toLowerCase();
*******return require('./' + pageObject + '.page.js');**********
})
};
这是我的等级库文件中的一行:
var generalInfo = pageObject.clickTheProvidedValueInCompanyInformation('generalInformation');
如您所见,调用pageObject.clicktheprovidedvaluecompanyinformation('generalInformation')
返回另一个pageObject
当我试图访问规范中的generalInfo变量时,它会抛出错误
generalInfo未定义
。如何通过generalInfo变量访问返回的pageobject
如果我将我的
return require('./anotherPageObject.js')
放在getText()之外,那么它可以正常工作。但是我必须对文本执行一些操作来修改命名约定,以便它返回正确的页面对象文件。(我想返回一个名为“general_information.page.js”的pageobject文件)方法如下。单击提供的值CompanyInformation
不会返回任何内容。添加return
语句以返回最后一个承诺:
this.clicktheprovidedvaluecompanyinformation=函数(项){
this.innerMenu=this.companyInformation.all(by.className('innerMenu')).first();
this.selectedItem=this.innerMenu.all(按.tagName('li')).filter(函数(元素,索引){
返回elem.getText().then(函数(文本){
返回文本.toUpperCase().replace(/|-/g',)==item.toUpperCase().replace(/|-/g',);
});
});
此选项。选择编辑项。单击();
返回这个。selectedItem.getText()。然后(函数(文本){
var option=text.toString();
var pageObject=option.replace(//g,'.').toLowerCase();
返回require('./'+pageObject+'.page.js');
});
};
pageObject。单击提供的值CompanyInformation('generalInformation')。然后(函数(第页){
控制台日志(第页);
});
此方法将执行此操作。单击提供的值CompanyInformation不会返回任何内容。添加return
语句以返回最后一个承诺:
this.clicktheprovidedvaluecompanyinformation=函数(项){
this.innerMenu=this.companyInformation.all(by.className('innerMenu')).first();
this.selectedItem=this.innerMenu.all(按.tagName('li')).filter(函数(元素,索引){
返回elem.getText().then(函数(文本){
返回文本.toUpperCase().replace(/|-/g',)==item.toUpperCase().replace(/|-/g',);
});
});
此选项。选择编辑项。单击();
返回这个。selectedItem.getText()。然后(函数(文本){
var option=text.toString();
var pageObject=option.replace(//g,'.').toLowerCase();
返回require('./'+pageObject+'.page.js');
});
};
pageObject。单击提供的值CompanyInformation('generalInformation')。然后(函数(第页){
控制台日志(第页);
});
请联系您当地的技术支持:键入标题时,您的键盘显然与capslock接合…@MarcB paging convertcase.net请联系您当地的技术支持:键入标题时,您的键盘显然与capslock接合…@MarcB paging convertcase.net