我有一个与以下链接相关的问题
PageObjects + non-angular page - how to join them?
然而,我使用量角器 - 黄瓜 - 框架而不是茉莉花。登录过程如下
由于列出的四个步骤是登录过程的一部分,理想情况下我想存储角度和角度的字段。单页对象模式中的非角度元素
我的步骤如下:
this.Given(/^A User Navigates To The (.+)$/, {timeout: 60 * 1000}, function (AcaExternalLoginPage)
{
//1. Navigate To Webpage
return Page = new Page();
});
this.When(/^Employer Code (.+) Is Entered And User Logs On$/, {timeout: 20 * 1000}, function (EmployerCode)
{
//1. Enter <EmployerCode> & Press Login In Button
return Page.EmployerEnterCodeAndLogin(EmployerCode);
});
this.Then(/^The Browser Title Should Equal (.+) And The Popup Frame Should Display (.+)$/, {timeout: 20 * 1000}, function (BrowserTitle, PopupFrameGreeting)
{
var World = this;
//1. Expect Browser Title To Equal Passed In Value
expect(browser.getTitle()).to.eventually.equal(BrowserTitle);
return this.RunNonAngular(function()
{
expect(browser.isElementPresent(Page.EmployerSssiFrame)).to.eventually.equal(true);
Page.SwitchToEmployerSssiFrame;
expect(Page.EmployerSssDynamicPromptLabel).to.eventually.equal(true);
//2. Pop up Frame To Equal Passed In Value
/expect(Page.TextEmployerSssDynamicPromptLabel).to.eventually.equal(PopupFrameGreeting);
})
});
我的页面对象模式是
'use strict';
var Page = function ()
{
var baseUrl = 'http://172.16.87.185:54810/';
browser.get(baseUrl + 'login');
};
Page.prototype = Object.create({},
{
//1: Element Locators
EmployerNameCodeTextBox:
{
get: function ()
{
return element(by.id('employee-code'));
}
},
EmployerLoginButton:
{
get: function ()
{
return element(by.buttonText('Login'));
}
},
EmployerSssiFrame:
{
get: function ()
{
return element(by.id('fbContent'));
}
},
EmployerSssDynamicPromptLabel:
{
get: function ()
{
return element(by.id('lblRequestActionText'));
}
},
//2. Actions|Events
EmployerEnterCodeAndLogin:
{
value: function (EmployerNameCode)
{
this.EmployerNameCodeTextBox.sendKeys(EmployerNameCode);
this.EmployerLoginButton.click();
}
},
SwitchToEmployerSssiFrame:
{
value: function ()
{
//Need to switch this way because of issue https://github.com/angular/protractor/issues/1846
browser.switchTo().frame(this.EmployerSssiFrame.getWebElement());
}
},
//3. Static Text Retrieval
TextEmployerSssDynamicPromptLabel:
{
get: function ()
{
return this.EmployerSssDynamicPromptLabel.getText();
}
}
});
module.exports = Page;
理想情况下,我希望将页面对象保留在一个页面上,因为它们都是登录过程的一部分。什么时候阻止
return this.RunNonAngular(function()
它超时,因为它无法找到iframe。关于如何绕过这个的任何建议?也许将iFrame元素存储在另一个页面中(虽然这不是理想的)&amp;稍后初始化?提前谢谢。