4

好吧,我正在使用铬。当我运行量角器时,页面开始加载并且永远不会完成加载,直到我手动刷新页面然后一切正常。我的页面使用 Angular2,是用 MEAN 堆栈构建的。

这是我的配置文件:

// @datatype_void
require('ts-node/register');

exports.config = {
  baseUrl: 'https://localhost:3000',

  // use `npm run e2e`
  specs: [
    '../test/*.e2e.*.js'
  ],
  suites: {
    dashboard: '../test/Dashboard.e2e.testcase.js'
  },

  exclude: [],

  framework: 'jasmine2',

  allScriptsTimeout: 40000,

  jasmineNodeOpts: {
    showTiming: true,
    showColors: true,
    isVerbose: false,
    includeStackTrace: false,
    defaultTimeoutInterval: 40000
  },
  directConnect: true,

  capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
      'args': ['show-fps-counter=true']
    }
  },

  onPrepare: function() {
    browser.ignoreSynchronization = true;
  },

  /**
   * Angular 2 configuration
   *
   * useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
   * `rootEl`
   *
   */
   useAllAngular2AppRoots: true
};

这是我的测试中第一个运行的:

describe('This is Dashboard.', () => {

    email = 'alexis.gonzalez@agilezip.mx';
    pass = 'laslos157';
    browser.get('/');
    browser.wait(protractor.ExpectedConditions.visibilityOf($('.abcRioButton.abcRioButtonBlue')), 10000);
    element(by.css('.abcRioButton.abcRioButtonBlue')).click();
    browser.getAllWindowHandles().then(function (handles) {
        browser.switchTo().window(handles[1]).then(function () {
            enterkeys(element(by.css('#Email')), email);
            element(by.css('#next')).click();
            browser.wait(protractor.ExpectedConditions.visibilityOf($('#Passwd')), 5000);
            enterkeys(element(by.css('#Passwd')), pass);
            element(by.css('#signIn')).click();
        });
    });
    browser.getAllWindowHandles().then(function (handles) {
        browser.switchTo().window(handles[0]);
    });
    browser.wait(protractor.ExpectedConditions.visibilityOf($$('.al-sidebar-list-link').get(0)), 10000);

4

2 回答 2

4

好吧,我可以通过添加以下行来“修复”:

browser.waitForAngular();
browser.navigate().refresh();

但我不明白为什么我必须刷新页面。:(

于 2017-01-05T17:08:56.573 回答
0

根据我的说法,您不必使用 browser.waitForAngular(),因为 Protractor 会在每个 Web 驱动程序操作之前自动应用此命令。简单地使用 browser.navigate.refresh() 也应该有效。

于 2020-07-06T05:44:58.700 回答