似乎量角器被忽略了它中期望的承诺

时间:2019-06-11 10:19:27

标签: typescript asynchronous jasmine protractor

量角器不等待页面的全部加载。 expect被忽略。

我尝试将waitExpectedConditionsvisibilityOfpresenceOf一起使用。

describe('Test', () => {
  const page: Page = new Page();
  const ad: Ad = new Ad();

  beforeAll(async () => {
    const signIn = new SignIn();
    const dashboard = new Dashboard();
    const order = new Order();

    await new AppPage().navigateTo();
    await browser.executeScript('window.localStorage.clear();');
    await page.navigateTo();
    await expect(await page.getH1Text()).toEqual('Sign In');
    await browser.refresh(); // Added due to http://git.io/v4gXM
    await expect(await browser.getCurrentUrl()).toBe('${BaseUrl}login');
    await signIn.form.loginForm.loginAsCustomer();
    await expect(await dashboard.isDisplayedUsername()).toBeTruthy();
    await expect(await dashboard.getUsername()).toBe('BB');
    await browser.refresh(); // Added due to http://git.io/v4gXM
    await expect(await browser.getCurrentUrl()).toBe('{BaseUrl}dashboard');

    await browser.get('{BaseUrl}order');

    const name: string = await order.getPageName();
    await expect(name).toBe('Orders');
    await browser.wait(ExpectedConditions.visibilityOf(element(by.css('div.dx-headers.dx-datagrid'))), 20000);
  });

  it('should select order', async () => {
    const grid: Grid = new Grid();
    const order: string = await grid.gridOrder.getAttributeOrderFromGrid('Test');
    await grid.gridOrder.selectOrderFromGrid('Test');
    await expect(await browser.getCurrentUrl()).toContain(order);
    await expect(await ad.getOrderNameLabel()).toBe('Test');
  });
});

错误:

Failed: Wow, you try to apply find() on empty Array Error: Wow, you try to apply find() on empty Array

添加await browser.sleep(3000)

没有任何问题

问题出在代码的以下部分:

const name: string = await order.getPageName();
await expect(name).toBe('Orders');
await browser.wait(ExpectedConditions.visibilityOf(element(by.css('div.dx-headers.dx-datagrid'))), 20000);

0 个答案:

没有答案