我在Angular 6项目中使用Protractor进行e2e测试。目前我正在使用两个浏览器执行>>> x = MyObject()
>>> x.update_var(10)
>>> x.var_1
10
>>> x.current_var = x.var_2
>>> x.update_var(5)
>>> x.var_2
5
来测试WebRTC应用程序。
问题是量角器失败,Time out等待带定位器的元素
我的测试
browser.forkNewDriverInstance(true);
错误是:
describe('Two browsers: ', () => {
const OVC = new MyObject();
const EC = protractor.ExpectedConditions;
beforeEach(() => {
browser.get('#/page1');
});
it('both users should can type messages and reveive its', () => {
const browser2 = OVC.openNewBrowserInTheSameRoom(browser);
browser2.ignoreSynchronization = true;
browser.wait(EC.visibilityOf(browser.element(by.css('#navChatButton'))), 5000);
browser.element(by.css('#navChatButton')).click();
browser.wait(EC.visibilityOf(browser.element(by.css('#messageInput input'))), 5000);
browser.element(by.css('#messageInput input')).click();
browser.element(by.css('#messageInput input')).sendKeys('New Message User 1');
OVC.pressEnter(browser);
browser2.wait(EC.presenceOf(browser2.element(by.css('#navChatButton'))), 5000);
browser2.element(by.css('#navChatButton')).click();
expect(OVC.getMessageList(browser2).count()).toEqual(1);
browser2.wait(EC.visibilityOf(OVC.getChatInput(browser2)), 5000);
OVC.getChatInput(browser2).click();
OVC.getChatInput(browser2).sendKeys('Message User 2');
OVC.pressEnter(browser2);
expect(OVC.getMessageList(browser).count()).toEqual(2);
OVC.closeSession(browser2);
});
});
但我的元素(#navChatButton)存在于DOM中。 我错了什么?
修改:如果我删除- Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an
> Angular application. Please see the FAQ for more details:
> https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
> While waiting for an element with locator - Locator: By(CSS selector,
> #navChatButton)
测试有效。那么为什么browser.wait
不适用于角色?