小编Den*_*ner的帖子

无法断言H1文字

我正在尝试写一些东西来检查以下页面上是否存在“关于我们”:https : //www.aggrowth.com/zh-cn/about-us,而我刚刚碰壁。这应该不难,但是我花了太多时间在这上面。

我们正在使用Gherking-testcafe:https ://www.npmjs.com/package/gherkin-testcafe

NPM: 6.9.0

TestCafe: 1.0.1

Gherking-Testcafe: 2.0.0

我尝试过(以下所有内容均经过测试隔离,也就是所有不同的t.expect均由他们自己运行):

  const h1AboutUs = await Selector('h1');

  await t.expect(h1AboutUs.innerText).eql('About Us');
  await t.expect(h1AboutUs.innerText).contains('About Us');
  await t.expect(h1AboutUs.value).eql('About Us');
  await t.expect(Selector('html').textContent).contains('About Us');
Run Code Online (Sandbox Code Playgroud)

并尝试删除等待:

  const h1AboutUs = Selector('h1'); 

  await t.expect(h1AboutUs.innerText).eql('About Us');
  await t.expect(h1AboutUs.innerText).contains('About Us');
  await t.expect(h1AboutUs.value).eql('About Us');
  await t.expect(Selector('html').textContent).contains('About Us');
Run Code Online (Sandbox Code Playgroud)

如果我这样做,它将起作用:

这是我的测试:

When("I see the page load", async t => {
  const h1AboutUs = await Selector('h1');

  await t.expect(h1AboutUs.visible).eql(true);
  await t.hover(h1AboutUs);
  await t.expect(h1AboutUs.value).contains('about');
  console.log(h1AboutUs.value);
});
Run Code Online (Sandbox Code Playgroud)

我的testCafe赛跑者:

const createTestCafe = require('gherkin-testcafe');
const fs …
Run Code Online (Sandbox Code Playgroud)

automated-tests web-testing ui-automation e2e-testing testcafe

3
推荐指数
1
解决办法
144
查看次数