【问题标题】:Jasmine spec timed out. Resetting the WebDriver Control Flow. angular 9 testingJasmine 规范超时。重置 WebDriver 控制流。角度 9 测试
【发布时间】:2020-07-29 05:53:26
【问题描述】:

我在 E2E 测试用例时遇到问题(之前它正在工作..)

A Jasmine spec timed out. Resetting the WebDriver Control Flow.
    × when login is successful — user object should be set in storage
      - ScriptTimeoutError: script timeout
        (Session info: chrome=84.0.4147.89)
        (Driver info: chromedriver=84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310}),platform=Windows NT 6.3.9600 x86_64)

这是测试用例

it("when login is successful — user object should be set in storage", async () => {
    await loginPage.fillCredentials(loginPage.credentials.correct);

    // wait until redirected to new page
    const EC = protractor.ExpectedConditions;
    const elm = await element(by.css(LOGIN_CSS.LOGO_TEXT));
    browser.wait(EC.presenceOf(elm), 40000);

    const _currentUser = await helperService.getLocalStorageObject("currentUser");
    console.log("_currentUser", _currentUser);

    expect(_currentUser).toBeDefined();

    const currentUser = JSON.parse(_currentUser);
    console.log("currentUser", currentUser);
    expect(currentUser.Id).toBeDefined();
    expect(currentUser.Name).toBeDefined();
});

在应用程序中,登录后重定向到页面并将用户设置为本地存储。

// wait till `LOGIN_CSS.LOGO_TEXT` is available on next page after login
const EC = protractor.ExpectedConditions;
const elm = await element(by.css(LOGIN_CSS.LOGO_TEXT));
browser.wait(EC.presenceOf(elm), 40000);

可能是什么问题?

【问题讨论】:

    标签: angular testing karma-jasmine


    【解决方案1】:

    browser.wait 等待元素的存在或等待多秒。

    browser.wait(EC.presenceOf(elm), 40000);
    

    在我的例子中,元素

    const elm = await element(by.css(LOGIN_CSS.LOGO_TEXT));
    

    不可用,因为媒体查询它被隐藏了,所以它等待了给定的毫秒数。

    我更改了元素并且它起作用了。所以问题是元素的可用性

    【讨论】:

      猜你喜欢
      • 2019-10-31
      • 1970-01-01
      • 2018-08-17
      • 1970-01-01
      • 2015-05-14
      • 1970-01-01
      • 2015-08-27
      • 1970-01-01
      • 2014-09-09
      相关资源
      最近更新 更多