【发布时间】:2019-04-30 21:29:06
【问题描述】:
我有一些按顺序运行的简单规范。第一个具有网页标题的expect 断言 - 第二个也是如此。
但是,当我运行序列时,第一个断言通过但第二个断言失败,并且 console.log 显示第一个规范的 expect 的部分已与第二个规范的 expect 合并。
我觉得这与 promise 有关...请有人证实这一点(或否认它!!)并建议如何完成承诺?
谢谢
第一个规范
describe('JL Homepage', function() {
//browser.waitForAngularEnabled(false);
browser.get('https://mwac-johnlewis-dev.digitalbridge.eu/landing');
browser.sleep(10000);
it('should have a title', function(){
expect (browser.getTitle()).toBe('John Lewis Wallpaper Visualiser:
Welcome');
});
});
第二规范
describe('Demo photo', function() {
browser.waitForAngularEnabled(false);
browser.sleep(3000);
element(by.xpath('html/body/webapp-app/div/div/webapp-johnlewis-landing/div/div/ul/li[2]/a/span')).click();
it('should load a demo room', function(){
expect (browser.getTitle()).toEqual('John Lewis Wallpaper Visualiser: Design your room');
browser.sleep(3000);
});
});
控制台
2 specs, 1 failure
Finished in 19.409 seconds
**************************************************
* Failures *
**************************************************
1) Demo photo should load a demo room
- Expected 'John Lewis Wallpaper Visualiser: Welcome' to equal 'John
Lewis Wallpaper Visualiser: Design your room'.
Executed 2 of 2 specs (1 FAILED) in 19 secs.
[12:08:21] I/launcher - 0 instance(s) of WebDriver still running
[12:08:21] I/launcher - chrome #01 failed 1 test(s)
[12:08:21] I/launcher - overall: 1 failed spec(s)
[12:08:21] E/launcher - Process exited with error code 1
Admins-MacBook:jl_autotests davidredmayne$
【问题讨论】:
-
您的所有操作都需要在
it块内。这样browser.get和您的click方法不在正确的位置。将它们移动到块内,就在expect之前 -
嗨 - 试过这个但得到异步错误。我可以确认订单吗? 1。描述............ 2。行动....3。 4. 期待
标签: protractor jasmine2.0