Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 量角器测试失败,角度咆哮-v2_Javascript_Testing_Protractor_End To End - Fatal编程技术网

Javascript 量角器测试失败,角度咆哮-v2

Javascript 量角器测试失败,角度咆哮-v2,javascript,testing,protractor,end-to-end,Javascript,Testing,Protractor,End To End,我正在应用程序中使用通知 他们工作正常,问题来自我的量角器测试。我必须使用TTL(大约6秒),因为这是一个要求。然后我有以下测试: it('should send a request and notify the user about the result',function(){ detailPage.verifyEmailtButton.click().then(function(){ var expectedDiv = element(by.css('.alert-su

我正在应用程序中使用通知

他们工作正常,问题来自我的量角器测试。我必须使用TTL(大约6秒),因为这是一个要求。然后我有以下测试:

it('should send a request and notify the user about the result',function(){
    detailPage.verifyEmailtButton.click().then(function(){
      var expectedDiv = element(by.css('.alert-success'));
      expect(expectedDiv).toBeDefined();
    });
  });
但它总是抛出一个错误:

NoSuchElementError:使用定位器By.cssSelector(“警报成功”)未找到任何元素

当TLL为-1时,不会发生这种情况

有人能帮忙吗?提前感谢。

单击按钮后:

detailPage.verifyEmailtButton.click();

var EC = protractor.ExpectedConditions;

var expectedDiv = element(by.css('.alert-success'));
browser.wait(EC.presenceOf(expectedDiv), 10000, "No alert present");

angular-growl-2使用了
$timeout
,这与量角器不兼容:量角器在完成与angular进程的同步之前等待超时结束

因此,当它到达您的
expect
调用时,超时时间已经过去,警报不再存在。查看本文档的等待页面同步部分:

(此页面与超时有关,您似乎没有遇到超时,但由于默认超时为11秒,因此整个过程(包括您的6秒TTL)很可能在超时发生之前发生)

angular-growl-v2的PR使用
$interval
而不是
$timeout
,但当前正在等待测试:


该解决方案也不起作用。问题是,当TTL有一个值时,量角器会等待角度咆哮信息消失。那么,当人们做出预期时,就没有这样的div了。@Santi这是你正在测试的公共站点吗?换句话说,我能自己重现问题,而不是猜测吗?