量角器不等待页面的全部加载。 expect
被忽略。
我尝试将wait
与ExpectedConditions
或visibilityOf
等presenceOf
一起使用。
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);