量角器sendKeys()不工作元素不可见

时间:2016-08-25 20:10:25

标签: javascript angularjs protractor automated-tests

嘿,我是使用protractorJS测试在angularJS中完成的主页的自动化测试的新手。我到目前为止编写的代码已经解决了问题是我无法将密钥发送到搜索字段运行代码后我得到消息:失败:超时等待Protractor与页面同步11秒后

我觉得我的元素语法有问题:

 element(by.css("input[name='search_query']")).sendKeys('Virginia Beach VA');


--- HTML code block ----
<div ng-transclude>
<input parse-search-query="" type="text" tabindex="1" name="search_query" autocomplete="off" placeholder="Search by City ST, Zip, or Address" data-ng-model="searchQueryFieldCtrl.searchFormController.searchParams.search_query" data-ng-change="searchQueryFieldCtrl.searchFormController.clearErrors()" data-focus-on="focusQuery || form.search_query.$error" data-uib-typeahead="suggestion as suggestion.label for suggestion insearchQueryFieldCtrl.getSuggestions($viewValue)" data-typeahead-focus-first="false" data-typeahead-min-length="0" data-typeahead-wait-ms="300" data-typeahead-on-select="searchQueryFieldCtrl.setSearch($item)" class="ng-pristine ng-untouched ng-valid ng-scope" aria-autocomplete="list" aria-expanded="false" aria-owns="typeahead-69-6255">
</div>   



---homeshptest.js file ----

    describe('New stack hompage test', function() {
  it('should test search form', function() {

    browser.ignoreSynchronization = true;

        browser.get('http://localhost:3000/');
        browser.sleep(5000); 
        element(by.css("input[name='search_query']")).sendKeys('Virginia Beach VA');
        browser.sleep(5000);



     VA');

}); });     ---------------

1 个答案:

答案 0 :(得分:0)

在browser.get()语句后使用browser.ignoreSynchronization =true。看来你的网页没有角度。