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

Protractor sendKeys() not working Element not visible

本文关键字:元素 工作 量角器 sendKeys      更新时间:2023-09-26

嘿,我是使用protractorJS测试在angularJS中完成的主页的自动化测试的新手。到目前为止我写的代码已经工作的问题是我不能发送密钥到搜索字段运行代码后,我得到消息:失败:超时等待量子器与页面同步后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');

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

在browser.get()语句之后使用browser.ignoreSynchronization =true。似乎你的网页没有角在它。