首页 > 解决方案 > 量角器没有得到元素

问题描述

我有一个 Angular 6 应用程序,我正在尝试进行 e2e 测试。在这个测试中,我首先登录,然后尝试获取所有菜单项并单击它们,但是我什至无法获得menu. 我的测试结果超时

应该可以通过菜单轻松导航 - 失败:脚本超时:11 秒内未收到结果(会话信息:chrome=70.0.3538.77)

和下面的第一个字符串(无论如何都没有多大意义)

来自:任务:Protractor.waitForAngular() - 定位器:Driver.schedule 处的 [object Object]

describe('Walking through', () => {

    let page: AppPage;

    beforeEach(() => {
        page = new AppPage();
    });

    it('should be at proper url', () => {
        page.navigateTo();
        page.logIn(
            'test',
            'password'
        );
        expect(
            browser.wait(browser.ExpectedConditions.urlContains('dashboard'), 5000)
                .catch(() => false)
        ).toBeTruthy();
    });

    // Not working
    it('should easily navigate by menu', () => {
        const menu = element(by.css('.menu'));

        expect(menu).toBeTruthy();

        const menuItems = element(menu).all(by.tagName('li'));

        expect(menuItems).toBeTruthy();

        menuItems.each(e => {
            browser.sleep(500);
            e.click();
            expect(e).toBeTruthy();
        });
    });
});

标签: angularprotractorangular-e2e

解决方案


推荐阅读