Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.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 用Phantomjs测试AngularJS_Javascript_Angularjs_Phantomjs - Fatal编程技术网

Javascript 用Phantomjs测试AngularJS

Javascript 用Phantomjs测试AngularJS,javascript,angularjs,phantomjs,Javascript,Angularjs,Phantomjs,我试图用PhantomJS测试AngularJS教程()。我无法让键入的搜索实际运行 以下是我目前的情况: var page = new WebPage(); page.open('http://angular.github.io/angular-phonecat/step-7/app', function() { page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", functio

我试图用PhantomJS测试AngularJS教程()。我无法让键入的搜索实际运行

以下是我目前的情况:

var page = new WebPage();
page.open('http://angular.github.io/angular-phonecat/step-7/app', function() {
  page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
    page.evaluate(function() {
        $("[ng-model=query]").click();
        $("[ng-model=query]").focus();
        $("[ng-model=query]").val("xoom");
        console.log($('ul.phones').text());
    });
    phantom.exit()
  });
});

直接更改输入值时,绑定似乎不起作用。您需要使用PhantomJS的本机输入法


当函数被执行时,我不得不做一些工作来分离,但是page.sendEvent(“keypress”,“xoom”);我成功了!当要与之交互的元素为select时,如何继续?不幸的是,这种方法不起作用…@Puce关注
select
元素和
page.sendEvent(“按键”,page.event.key.Down)您需要的数量。我想Fanch在去年的选择中提到了这个方法。谢谢!我使它能够工作:
$(“.select.selectId”).val(selectedValue.trigger('change')
page.open('http://angular.github.io/angular-phonecat/step-7/app', function() {
    page.evaluate(function() {
        document.querySelector('[ng-model=query]').focus();
    });
    page.sendEvent("keypress", "xoom");
    page.evaluate(function() {
        console.log(document.querySelectorAll('ul.phones li').length + " products");
    });
    phantom.exit();
});