Ayu*_*nia 2 javascript testing automated-tests e2e-testing testcafe
这是我尝试在testcafe v1.0.1中运行的一种测试,对此我是新手。
这是我的test.js文件,其中有三个不同的测试用例R03,R05,R06,并且都使用withText()函数在网页中搜索元素。
无论如何,我是否有一个配置文件(json / js),可以在其中保存Year_1,Year_2,Year_3和Location_1,Location_2,Location_3的输入,并在当前的.js文件中使用它。
`import { Selector } from 'testcafe';
fixture `First Fixture`
.page `http://devexpress.github.io/testcafe/example`;
test('R03', async t => {
await t
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Year_1'))
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Location_1'))
});
test('R05', async t => {
await t
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Year_2'))
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Location_2'))
});
test('R06', async t => {
await t
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Year_3'))
.click(Selector('[data-bind^="css:{ \\\'dx-state-disabled\\\'].find('div').withText('Location_3'))
});
Run Code Online (Sandbox Code Playgroud)
您不能将输入存储在某些.js文件中。但是,您可以保存输入的选择器并在测试中使用它们。参见示例:
element-selectors.json
{
"developerNameInput": "#developer-name",
"populateBtn": "#populate"
}
Run Code Online (Sandbox Code Playgroud)
test.js
{
"developerNameInput": "#developer-name",
"populateBtn": "#populate"
}
Run Code Online (Sandbox Code Playgroud)