【问题标题】:Protractor test not working with IE but it does with FF/Chrome/Safari量角器测试不适用于 IE,但适用于 FF/Chrome/Safari
【发布时间】:2015-08-11 03:35:02
【问题描述】:

我目前正在处理针对 IE 的量角器测试的问题。

我正在使用 Protractor + Jasmine + Node.js

我正在测试的页面部分如下:

<h2 collapser="" class="title text-center text-uppercase active">Tech Specs <i class="plus-icon"></i></h2>

我有以下测试:

it('User should be able to see module 11 Tech Specs collapsing and uncolapsing', function () {
    basePage.techSpecCollapser.click();
    browser.sleep(1000);
    expect(basePage.techSpecContainer.isDisplayed()).toBeTruthy();

});

这是控制台输出:

 Landing page module verification -->
  User should be able to see module 11 Tech Specs collapsing and uncollapsing - fail


  1) New Landing page module verification --> User should be able to see module 11 Tech Specs collapsing and uncolapsing
  at 15.446s [Thu, 28 May 2015 14:23:08 GMT]
   Message:
     Expected false to be truthy.
   Stacktrace:
     Error: Failed expectation
    at [object Object].<anonymous> (/Users/test/Documents/Dev/test/sandBox/specs/landing_page_spec.js:44:58)

Finished in 15.448 seconds
1 test, 1 assertion, 1 failure

通过观察测试运行,我看到网页的一部分没有显示出来。我试过了:

  • 强制滚动到页面的该部分:无效。
  • 聚焦页面的该部分:不起作用。

有人遇到过同样的问题吗?可以让它工作而且很简单的测试!

【问题讨论】:

    标签: javascript internet-explorer selenium jasmine protractor


    【解决方案1】:

    您可以尝试解决多种问题:

    • 在运行测试之前最大化浏览器窗口。将此添加到onPrepare()

      browser.driver.manage().window().maximize();
      
    • 删除不可靠的browser.sleep() 并显式等待元素变为可见visibilityOf expected condition

      var EC = protractor.ExpectedConditions;
      basePage.techSpecCollapser.click();
      browser.wait(EC.visibilityOf(basePage.techSpecContainer), 10000);
      
    • 移动到元素:

      browser.executeScript("arguments[0].scrollIntoView();", basePage.techSpecContainer.getWebElement());
      

    【讨论】:

    • 感谢@alecxe,但我仍然得到相同的输出。你建议的我都加了,你建议的都一一添加了!但似乎仍然没有显示页面的那部分,我在想可能没有正确单击前一个元素。您还有什么建议?
    • @BrunoSoko 很好,如果不能调试问题就很难说。在黑暗中再次拍摄,尝试按以下方式执行点击:browser.executeScript("arguments[0].click();", basePage.techSpecCollapser.getWebElement());
    • 你是对的。你被蒙住了眼睛,我遇到了不同的错误,但通过在 config.js 文件中添加这个 browser.manage().timeouts().implicitlyWait(100000); 解决了一些错误,并在我的测试中:basePage.subscribe.click().then(function () { browser.wait(EC.visibilityOf(thxPage.thankYou), 90000); expect(thxPage.thankYou.isPresent()).toBeTruthy(); });
    • 但是,我实际上遇到了另一个问题......同样的逻辑不适用于另一个不愉快的场景......很奇怪......这就是失败的 browser.executeScript("window.滚动(0,10000)“); basePage.email.sendKeys('bruno@test.com'); basePage.subscribe.click().then(function () { browser.sleep(7000); basePage.confirmMessage('联系人已添加到目标广告系列');});
    • @BrunoSoko 感谢分享帮助解决问题的方法。也可以尝试滚动查看:browser.executeScript("arguments[0].scrollToView()", basePage.email.getWebElement());.
    猜你喜欢
    • 1970-01-01
    • 2023-04-05
    • 2013-07-09
    • 1970-01-01
    • 1970-01-01
    • 2014-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多