小编Fis*_*sio的帖子

量角器 - $ http调用后在转发器中选择元素

我开始对我的sails.js/AngularJS app进行量角器测试.简化,我的HTML中有以下类型的ng-repeat:

<div ng-repeat="book in books">
  book.name
</div>
Run Code Online (Sandbox Code Playgroud)

我的测试单击了一个按钮,该按钮向服务器发送$ http POST调用,创建另一本书,并在成功时将另一本书添加到$ scope.books.问题是测试失败,因为当测试检查它的存在时,还没有创建该书.我知道我的定位器/过滤器工作,因为再次运行测试(=在发送呼叫之前存在该书)测试成功.

测试:

    element.all(by.buttonText('Save')).
        filter(function(elem) {return elem.isDisplayed();}).
        first().
        click();

    browser.sleep(500); // even this doesn't work :(

    element.all(by.repeater('book in books')).filter(function(elem, index) {
        return elem.getText().then(function(text) {
            return text === "nameOfBook";
        });
    })
    .then(function(books) {
        expect(books[0].isPresent()).toEqual(true);
    });
Run Code Online (Sandbox Code Playgroud)

到目前为止,我遇到的答案似乎表明量角器应该在继续之前自动等待$ http调用完成,但在我的情况下它似乎并非如此.

我甚至尝试4000ms左右,我已经可以看到新的元素在转发的睡眠时间,但测试仍看到books[0]undefined.再次运行测试时的工作原因所以问题不应该在过滤器中,而应该在其他地方.

有关此事的任何见解?

ajax selenium angularjs protractor sails.js

4
推荐指数
1
解决办法
594
查看次数

(Android) / Chrome getUserMedia() 约束应该如何格式化?

我一直在尝试访问运行 Chrome 的 LG G4 Android 手机上的后置摄像头。我可以从 中过滤掉视频源MediaStreamTrack.getSources(),但是当我尝试设置约束以偏爱后置摄像头时,出现错误TypeError: Failed to execute 'webkitGetUserMedia' on 'Navigator': Malformed constraints object.下面我有我用来过滤视频源的代码:

if (navigator.getUserMedia) {
  if (MediaStreamTrack.getSources) {
    MediaStreamTrack.getSources(function(sourceInfos) {
      var sources = [];
      _.forEach(sourceInfos, function(info) {
        if (info.kind === 'video') {
          sources.push(info);
        }              
      })
      handleSources(sources);
    })
  }
}
Run Code Online (Sandbox Code Playgroud)

然后我试图在handleSources上面提到的函数中选择一个源:

function handleSources(sources) {
  var constraints = {
    video: {
      facingMode: 'environment' // Yeah, this definitely doesn't work.
    }
  }
  getMedia(constraints); // This calls getUserMedia with the selected contraints
} …
Run Code Online (Sandbox Code Playgroud)

html android google-chrome html5-video getusermedia

4
推荐指数
1
解决办法
7656
查看次数