代码之家  ›  专栏  ›  技术社区  ›  Michael Durrant

量角器-如何让[enter]在firefox上工作(在chrome中正常工作)

  •  0
  • Michael Durrant  · 技术社区  · 5 年前

    input.sendKeys('123\n');
    

    提交表单并将我发送到结果页面,就像这样

    input.sendKeys('123');
    input.sendKeys(protractor.Key.ENTER); // or .RETURN
    

    进入 这样我就一直呆在原来的页面上,测试失败了。

    失败:元素 <input class="gNO89b" name="btnK" type="submit">

    browser.actions().sendKeys(protractor.Key.ENTER).perform();  //invalid (older?) syntax.
    

    input.sendKeys(protractor.Key.TAB);
    input.sendKeys(protractor.Key.TAB);
    input.sendKeys(protractor.Key.ENTER);
    

    另外,起诉页面上的提交按钮

    $('input[value="Google Search"]').click();
    

    $('input[name="btnK"]').click();
    

    input.sendKeys('123');
    input.sendKeys(protractor.Key.TAB);
    $('input[value="Google Search"][name="btnK"]').click();
    

    它们大多在chrome中工作,只是在firefox中没有,或者最坏的情况下,两者都不支持。

    失败(显示我仍在原来的页面上)是

    [firefox #01] Failures:                                                                                                                   
    [firefox #01] 1) Google search field should have a result page                                                                            
    [firefox #01]   Message:                                                                                                                  
    [firefox #01]     Expected 'About Store                                                                                                   
    [firefox #01]     Gmail                                                                                                                   
    [firefox #01]     Images                                                                                                                  
    [firefox #01]     Sign in                                                                                                                 
    [firefox #01]     PrivacyTermsSettings                                                                                                    
    [firefox #01]     AdvertisingBusiness How Search works' to contain '123'.                                                                 
    [firefox #01]   Stack:                                                                                                                    
    [firefox #01]     Error: Failed expectation  
    

    chrome测试通过,其他(10)个firefox测试通过ok,打开firefox浏览器并使用浏览器ok,但他们不会像这次一样提交表单。

    --safe-mode --headless 但他们没帮上忙。

    我试着用 browser.sleep(2000)

    我试着用

    input.sendKeys(protractor.Key.TAB);
    browser.sleep(1000).then(function() {
      $$('input[value="Google Search"].first').click();
    });
    browser.sleep(2000).then(function() {     
    expect($('body').getText()).toContain('123');
    });
    

    0 回复  |  直到 5 年前