Searching for HTML elements works only on first rootPage in E2E testing

未关闭
#73 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
testing

调研方向

在页面对象中重现 Protractor 的 E2E 流程:导航到根页面,点击 #start-game,然后在 NavController 更改根页面后查询 #goal-wrapper 和浏览器标题。首先检查 GameComponent 显示后浏览器命令会发生什么。完成标准是选择器、等待、getTitle() 和 getSize() 都能在游戏页面上完成。

由索引模型根据 Issue 内容生成。

描述

Hey guys!

I am facing one issue when I try to run E2E tests. I am using Protractor (5.1.2) for E2E tests.
So everything works fine when I try to search for elements on the rootPage. My tests look like this:

game.navigateToRoot();
game.startGame();
game.playTheGame();

Navigation to root works fine, I can normally find the START BUTTON and click on it, which leads me to the GameComponent (I actually change the root like this.nav.setRoot(GameComponent)).
When the game panel is shown, I can not do any HTML selector query, not even (browser.title), because neither one Promise callback is executed. I tried to wait the browser with:

const until = rotractor.ExpectedConditions;
browser.wait(until.presenceOf(game.getFinalResultWrapper()), 5000, 'Element taking too long to appear in the DOM');

Here is my game page object where I make HTML queries:

navigateToRoot() {
    return browser.get('');
}

startGame() {
    const startGameButton = this.getStartGameButton();
    this.getStartGameButton().click();
    // the NavController's root changes
}

getStartGameButton() {
    return $('#start-game');
}

getFinalResultWrapper() {
    return $('.level-complete-wrapper');
}

playTheGame() {
    // nothing works from now on
    const goalWrapper = $('#goal-wrapper');
    const until = protractor.ExpectedConditions;
    browser.wait(until.presenceOf(goalWrapper), 5000, 'Element taking too long to appear in the DOM');
    browser.getTitle().then((title) => {
        console.log('title = ', title);
    });
    $('#goal-wrapper').getSize().then((size) => {
        console.log(size);
    });
}
主要语言
TypeScript
星标
370
派生
144
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ionic-team/ionic-unit-testing-example 的其他 Issue

查看 ionic-team/ionic-unit-testing-example 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。