【问题标题】:google Autocomplete not selecting the first element in protractor谷歌自动完成没有选择量角器中的第一个元素
【发布时间】:2017-04-16 03:58:18
【问题描述】:

将位置传递给模型自动完成后应该选择第一个元素。这是 HTML 代码

<input type="text" class="textareanoborder col-xs-12 col-md-12 m-t ng-pristine ng-valid ng-isolate-scope ng-touched" placeholder="Enter Location" ng-autocomplete="result1" details="details1" options="options1" rows="1" ng-model="location" autocomplete="off" aria-invalid="false">

这是量角器代码:

browser.actions().mouseMove(element(by.model("location")).sendKeys("hyderabad,Telangana,India",protractor.Key.ARROW_DOWN)).click();

以下错误抛出:

Failed: unknown error: Element is not clickable at point (736, 231). Other element would receive the click: <div class="pac-item">...</div>
      (Session info: chrome=54.0.2840.99)
      (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64)

【问题讨论】:

    标签: google-maps google-maps-api-3 autocomplete protractor


    【解决方案1】:

    我猜这是一个嵌入式谷歌搜索?我不知道这是否会有所帮助,但我做了一个功能来搜索谷歌搜索中弹出的自动完成选项。您可以选择要搜索的自动完成项目的编号。

    function autoCompleteSearch(text, index) {
          browser.actions()
          .mouseMove(element(by.name('q'))
          .sendKeys(text))
          .perform().then(function(){
            browser.sleep(500);
            // press the down arrow for the autocomplete item we want to choose
            for(i = 0; i < index ; i++){
    
                browser.actions().sendKeys(protractor.Key.ARROW_DOWN).perform();
            }
            browser.sleep(500);
            browser.actions().sendKeys(protractor.Key.ENTER).perform();
          });
    }
    
    describe('google homepage', function() {
    browser.ignoreSynchronization = true;
      beforeEach(function() {
        browser.get('http://www.google.com');
      });
    
      it('should search google via autocomplete', function() {
    
          autoCompleteSearch("awesome", 3);
    
          // added this sleep so I can see the results afterwards
          browser.sleep(2000);
    
      });
    });
    

    【讨论】:

      猜你喜欢
      • 2021-04-23
      • 2019-01-16
      • 2015-03-10
      • 2012-07-08
      • 2013-03-20
      • 2013-07-14
      • 2018-04-21
      • 1970-01-01
      • 2022-01-23
      相关资源
      最近更新 更多