量角器测试不适用于 IE,但适用于 FF/Chrome/Safari

Protractor test not working with IE but it does with FF/Chrome/Safari

我目前正在处理针对 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

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

有人 运行 遇到同样的问题吗?可以让它工作,而且非常简单的测试!

您可以尝试多种方法来解决它:

  • 在 运行 测试之前最大化浏览器 window。将此添加到 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());