【问题标题】:A Jasmine spec timed out. Resetting the WebDriver Control FlowJasmine 规范超时。重置 WebDriver 控制流
【发布时间】:2019-10-31 09:35:00
【问题描述】:

我来了

Jasmine 规范超时。重置WebDriver 控制流。

我之前也使用过fakesyn,但收到与上述相同的错误消息。 请帮帮我

这是我的规格:

describe('CW Login Page',   function() {
    var username;   
    var password;
    var login;
    beforeEach(() => {
    browser.waitForAngularEnabled(false);
    browser.get('http://www.testing.com/');
    console.log('after link await');
  });

    it('should find the element and send the parameters',  fakeAsync(() => {
      setTimeout(function() {
      value=0;
      console.log('Inside it function');
      username = element(by.id('userIDInput'));
      password= element(by.id('passwordInput'));
      login= element(by.id('login'));
      console.log('After await');
      username.sendKeys('abc');
      password.sendKeys('abc');
      login.click();
      console.log("After it function");
      },5000);
      tick(5000);
    }));

    `beforeEach`(() => {
      console.log('\r\n ---=== TESTS FINISHED!!! ===--- \r\n');
   });
    });

这是我的配置:

exports.config = {
  allScriptsTimeout: 50000,
  getPageTimeout:40000,
  framework:'jasmine2',
  /*seleniumAddress: 'http://localhost:4723/wd/hub', // Ignored if directConnect is true
  specs: ['loginpage.js'],*/
  seleniumAddress: 'https://hub.testingbot.com/wd/hub',
  specs: ['./src/loginpage_fakeasync.e2e-specs.js'],
  seleniumArgs: ['--dev-server-target'], // '--dev-server-target' ],
  directConnect: false, //Change this to true for your local testing
  multiCapabilities: [{ // in 1 chrome run the 10 specs sequentially
    browserName: 'chrome',
    platform: 'Android',  
    version: '7.1',  
    platformName: 'Android',  
    deviceName: 'Pixel 2',
    client_key: "abc",
    client_secret: "xyz"
  }],

jasmineNodeOpts: {  
  onComplete: null,                 //jasmine framework details
  isVerbose: false,
  showColors: true,
  includeStackTrace: true,
  defaultTimeoutInterval: 40000,
  print: function() {}

我希望使用自动化脚本打开网页并登录。如果有人能找出错误,那将是一个很大的帮助

我来了

Jasmine 规范超时。重置WebDriver 控制流。

我之前也使用过fakesyn,但收到与上述相同的错误消息。 请帮帮我

【问题讨论】:

  • 我有一些问题,你在测试非 Angular 应用吗?你为什么要使用fakeAsync?设置超时的目的仅仅是为了稍微延迟规范的执行吗?
  • 是的,我正在测试非 Angular Web 应用程序。我正在使用 fakeAsync 以便命令等待上一个命令完成。当我运行该应用程序时,它没有打开网页,它会尝试 2 分钟,然后给出超时错误。因此我提到了设置超时。但我仍然收到相同的错误消息。请帮忙,因为我认为我缺少一些语法。
  • 您感兴趣的测试套件有多大?可能值得转向 async/await 承诺处理,因为它更容易调试异步问题。

标签: javascript angularjs typescript protractor


【解决方案1】:

控制流应该保持一切同步运行,因此不需要 fakeAsync 和 setTimeout。如果您的框架不是太大,那么您应该考虑禁用控制流并使用async/await 处理承诺的样式。

我怀疑这会解决您的问题,但您可以尝试以下代码并发布结果。

describe('CW Login Page', function () {
    var username;
    var password;
    var login;

    beforeEach(() => {
        browser.waitForAngularEnabled(false);
        browser.get('http://www.testing.com/');
        console.log('after link await');
    });

    it('should find the element and send the parameters', () => {
        value = 0;
        console.log('Inside it function');
        username = element(by.id('userIDInput'));
        password = element(by.id('passwordInput'));
        login = element(by.id('login'));
        console.log('After await');
        username.sendKeys('abc');
        password.sendKeys('abc');
        login.click();
        console.log("After it function");
    })

    afterEach(() => {
        console.log('\r\n ---=== TESTS FINISHED!!! ===--- \r\n');
    }
});

【讨论】:

  • 感谢您的回复,在等待 async 之后,我仍然面临同样的问题:Jasmine 规范超时。重置 WebDriver 控制流。 [09:48:16] I/launcher - 0 个 WebDriver 实例仍在运行 [09:48:16] I/launcher - chrome7.1 #01 失败 1 个测试 [09:48:16] I /launcher - 总体:1 个失败的规范 [09:48:16] E/launcher - 进程退出,错误代码为 1
  • 我的问题得到了解决,我的问题是在配置文件中使用了不正确的 selenium 地址,我的错,谢谢你的帮助:)
猜你喜欢
  • 1970-01-01
  • 2015-05-14
  • 1970-01-01
  • 1970-01-01
  • 2015-08-27
  • 1970-01-01
  • 1970-01-01
  • 2018-08-17
  • 2014-09-09
相关资源
最近更新 更多