Mik*_*gin 14 javascript testing end-to-end angularjs protractor
我有一个指令,产生以下html结构:
<div class="popover ng-isolate-scope" ng-mouseover="toggle(true)" ng-mouseleave="toggle(false)" popover="" label="hover time!" trigger-class="button" content-class="specialContentClass">
<span id="thing" class="popover-trigger button">hover time!</span>
<div ng-transclude="" ng-show="show" class="popover-content ng-hide">
<div class="ng-scope">Popover content </div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
代码工作正常,当您使用浏览器手动鼠标悬停时,正确显示弹出窗口内容.
我正在尝试使用以下量角器测试来测试鼠标悬停功能:
it('should display the popover-content on mouseover', function() {
browser.get('http://localhost:9000/');
browser.actions()
.mouseMove(element(by.css('.popover')).find()).perform();
expect(element(by.css('.popover-content'))
.isDisplayed().toBeTruthy());
});
Run Code Online (Sandbox Code Playgroud)
测试似乎运行,浏览器打开但我没有看到弹出内容显示在浏览器然后关闭之前所以我很确定mousemove位由于某种原因不起作用.然后在终端输出以下内容:
launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
ycompu:angular ycompu$
Run Code Online (Sandbox Code Playgroud)
我已阅读文档,使用浏览器绝对是接近此测试的正确方法.我不知道,因为语法对我来说是正确的.
ale*_*cxe 28
一个可能的问题是你需要让它等待加载角度:
it('should display the popover-content on mouseover', function() {
browser.get('http://localhost:9000/');
browser.waitForAngular();
browser.actions().mouseMove(element(by.css('.popover'))).perform();
expect(element(by.css('.popover-content')).isDisplayed()).toBeTruthy();
});
Run Code Online (Sandbox Code Playgroud)
我也删除了find()调用(不确定你是否真的需要它)并修改了最后一行的括号结束顺序.
| 归档时间: |
|
| 查看次数: |
19752 次 |
| 最近记录: |