TestCafe 为未在测试中使用的页面元素抛出引用错误
TestCafe throws an References error for a page element that is not being used in tests
我刚开始研究这个名为 "testCafe" 的测试自动化工具。这是工具的详细信息:https://devexpress.github.io/testcafe/
在我的第一个测试中,我使用深度 URLs 浏览了 2 个页面。这是一个场景
1)点击首页URL
2) 使用另一个 URL 导航到另一个页面
3) 在第 2 页执行断言
我收到以下错误:
1) 页面“https://page2url.com”上的错误:
ReferenceError: initFooterSiteSwitcher 未定义
这是我的代码- firsttest.js
import { Selector } from 'testcafe';
import Page from './homepage-model';
import finAdv from './finAdvisorpage-model';
const page = new Page();
const page_finAdv = new finAdv();
fixture `Getting Started`
.page `https://homepageurl.com`;
test('My first test', async t =>{
await t
.navigateTo('page2url.com')
.click(page_finAdv.gottoLink)
.expect(page_finAdv.linktext).eql('Sample text');
});
我在 DOM 中查找了 page2url.com,我在 DOM 中找到了这个函数:initFooterSiteSwitcher()。但正如您所见,我在测试中没有与此交互,但我收到错误,并且测试不会继续进行测试用例中的后续步骤。有人可以分享一些见解吗?这是 HTML 应用本身或我的测试的问题吗?
这似乎是应用程序的问题。要检查它,请在浏览器中打开 DevTools,导航到没有 TestCafe 的页面,然后检查控制台选项卡中的输出。
如果您可以在没有 TestCafe 的情况下在“控制台”选项卡中看到错误,并且网站仍然正常运行,则可以在 运行 测试时使用 -e
开关忽略此错误:https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#-e---skip-js-errors
如果在没有使用TestCafe的情况下没有出现该错误,则可能是TestCafe中的错误导致的。在这种情况下,您可以向 TestCafe 存储库提交错误报告:https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md
我刚开始研究这个名为 "testCafe" 的测试自动化工具。这是工具的详细信息:https://devexpress.github.io/testcafe/
在我的第一个测试中,我使用深度 URLs 浏览了 2 个页面。这是一个场景 1)点击首页URL 2) 使用另一个 URL 导航到另一个页面 3) 在第 2 页执行断言
我收到以下错误:
1) 页面“https://page2url.com”上的错误:
ReferenceError: initFooterSiteSwitcher 未定义
这是我的代码- firsttest.js
import { Selector } from 'testcafe';
import Page from './homepage-model';
import finAdv from './finAdvisorpage-model';
const page = new Page();
const page_finAdv = new finAdv();
fixture `Getting Started`
.page `https://homepageurl.com`;
test('My first test', async t =>{
await t
.navigateTo('page2url.com')
.click(page_finAdv.gottoLink)
.expect(page_finAdv.linktext).eql('Sample text');
});
我在 DOM 中查找了 page2url.com,我在 DOM 中找到了这个函数:initFooterSiteSwitcher()。但正如您所见,我在测试中没有与此交互,但我收到错误,并且测试不会继续进行测试用例中的后续步骤。有人可以分享一些见解吗?这是 HTML 应用本身或我的测试的问题吗?
这似乎是应用程序的问题。要检查它,请在浏览器中打开 DevTools,导航到没有 TestCafe 的页面,然后检查控制台选项卡中的输出。
如果您可以在没有 TestCafe 的情况下在“控制台”选项卡中看到错误,并且网站仍然正常运行,则可以在 运行 测试时使用 -e
开关忽略此错误:https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#-e---skip-js-errors
如果在没有使用TestCafe的情况下没有出现该错误,则可能是TestCafe中的错误导致的。在这种情况下,您可以向 TestCafe 存储库提交错误报告:https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md