我正在使用基于JavaScript的测试工具,使用Protractor和Chai as Promised。在检查URL时,我遇到了以下错误:
我希望能够捕获这个错误以便使用另一个回调函数,我该如何做?我尝试使用 try-catch 块来处理,但好像不起作用。我甚至无法确定 Protractor 是否生成了 AssertionErrors,请您给我一个解释。
谢谢。
AssertionError: expected 'http://localhost:8888/test/homepage.php' to equal 'http://localhost:8888/test/my_homepage.php'
。
以下是我的步骤定义:
this.Then(/^The url of the page should be "([^"]*)"$/, function(myUrl, callback){
expect(browser.getCurrentUrl()).to.eventually.equal(myUrl);
callback();
});
我希望能够捕获这个错误以便使用另一个回调函数,我该如何做?我尝试使用 try-catch 块来处理,但好像不起作用。我甚至无法确定 Protractor 是否生成了 AssertionErrors,请您给我一个解释。
谢谢。
notify
会有帮助吗:expect(browser.getCurrentUrl()).to.eventually.equal(myUrl).notify(yourcallback)
? - alecxe