Angular 角2 e2e测试
我刚开始进行Angular 2和e2e测试,我正在尝试通过使用量角器单击空白区域来关闭Bootstrap 4模式。我试过:Angular 角2 e2e测试,angular,protractor,bootstrap-modal,e2e-testing,Angular,Protractor,Bootstrap Modal,E2e Testing,我刚开始进行Angular 2和e2e测试,我正在尝试通过使用量角器单击空白区域来关闭Bootstrap 4模式。我试过: it('should close the login modal when the blank space outside of the modal is clicked', () => { element(by.tagName('body')).click().then(function() { browser.sleep(250); expec
it('should close the login modal when the blank space outside of the modal is clicked', () => {
element(by.tagName('body')).click().then(function() {
browser.sleep(250);
expect(element(by.id('myModal')).isDisplayed()).toBeFalsy();
});
});
…我甚至试过:
it('should close the login modal when the blank space outside of the modal is clicked', () => {
browser.actions()
.mouseMove(element(by.id('login_modal')), -20, -20)
.click().then(function() {
browser.sleep(250);
expect(element(by.id('login_modal')).isDisplayed()).toBeFalsy();
});
});
我是角度2世界的新手,所以答案可能很明显。提前感谢您的帮助。我还没有看到您的HTML,但我想这会发生的。
单击
-对图元的操作将在图元的中心执行单击,请参见
这取决于模态在页面上的位置,但在常见情况下,模态位于页面的中心。如果我们将其作为一个给定值,并执行上面描述的第一个click命令,我们将得到以下结果
- 单击
,主体将进入全屏,主体中心将单击模态=>模态将不会关闭主体
browser.actions()
.mouseMove(元素(by.id('login_modal')){
x:toRight,
y:托伯顿
})
.单击()。然后(函数()){
浏览器。睡眠(250);
expect(元素(by.id('login_modal')).isDisplayed()).toBeFalsy();
});代码>感谢您的反馈,这让我找到了答案。我应该发布这是一个引导模式,这是相关的。当被调用时,模态覆盖整个页面,而不仅仅是中间的矩形。通过将坐标设置为x:0,y:0,我处于模态的“空白”区域。问题是什么/问题是什么。是不是快关门了?没错。我无法在空白区域单击并关闭模式。