我正在使用量角器来测试非 Angular 应用程序,当我使用browser.forkNewDriverInstance()
then 时,它似乎browser.forkNewDriverInstance()
不再正常工作,因为我在执行时收到此错误:
Failed: Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either beca use this is a
非角度页面或因为您的测试涉及客户端导航,这可能会干扰量角器的 boo tstrapping。有关详细信息,请参阅http://git.io/v4gXM ”
这里的代码:
配置文件
exports.config = {
framework: 'jasmine',
specs: ['test.js','chat_featuresx.js'],
multiCapabilities: [{
browserName: 'chrome'
}],
directConnect: 'true'
}
测试.js
describe('First interaction customer-agent', () => {
beforeEach(function() {
global.agent = browser;
global.customer = browser.forkNewDriverInstance();
agent.ignoreSynchronization = true;
customer.ignoreSynchronization = true;
agent.get('http://engager-stage.brandembassy.com/');
customer.get('https://vps-web-utils.awsbrandembassy.com/livechat-window-gherkin/');
agent.driver.manage().window().maximize();
customer.driver.manage().window().maximize();
});
it('should be seen offline when agent is offline and viceversa', () => {
// check that default status is minimized
browser.sleep(2000);
expect(customer.isElementPresent(by.css('.be-chat.be-chat--minimize'))).toBe(true);
});
});
检查代码后。我看到的几件事是:
1. 如果您将变量声明为global
,我认为您需要在使用它们时包含它。
例如 global.agent.ignoreSynchronization
2.isElementPresent
似乎用于角度页面。
在你的情况下,我用isPresent
请参阅下面的示例代码:
describe('First interaction customer-agent', () => {
var agent = browser;
var customer = browser.forkNewDriverInstance();
beforeEach(function() {
agent.ignoreSynchronization = true;
customer.ignoreSynchronization = true;
agent.get('http://engager-stage.brandembassy.com/');
customer.get('https://vps-web-utils.awsbrandembassy.com/livechat-window-gherkin/');
agent.driver.manage().window().maximize();
customer.driver.manage().window().maximize();
});
it('should be seen offline when agent is offline and viceversa', () => {
// check that default status is minimized
browser.sleep(2000);
var elm = customer.element(by.css('[class="be-chat-wrap be-chat-wrap--minimize"]'));
expect(elm.isPresent()).toBe(true);
});
});
注意:我没有使用 global,因为我们可以在it
函数外部声明变量。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句