【发布时间】:2019-05-24 06:20:04
【问题描述】:
我使用 TestCafe 进行了我的第一个基本自动化测试。
import { Selector } from 'testcafe';
fixture `Ordner erstellen`
.page `https://ifoerster.com/`;
test('New Test', async t => {
await t
.typeText(Selector('#email'), 'xxx', {
caretPos: 0
})
.typeText(Selector('#password'), 'xxx', {
caretPos: 0
})
.click(Selector('span').withText('Login'))
//Find testref here
.click(Selector('.np-top-section-tab.folder'))
.click(Selector('.np-folder.new-category'))
.typeText(Selector('[class^="ReactModal__Content ReactModal__Content--after-ope"]').find('.cl-input.cl-input-header'), 'testref')
.click(Selector('.cl-button.cl-button.cl-button-animated'))
.click(Selector('.np-folder-name[title="testref"]'))
.click(Selector('.np-bottom-path-section').find('span').withText('Home'))
.click(Selector('div').withText('testref').nth(9).find('.np-folder-fave'))
.click(Selector('span').withText('testref'))
.click(Selector('.cl-folder-delete'))
.click(Selector('.cl-button.cl-button.cl-button-animated'))
.click(Selector('.cl-popup-close'));
});
现在我尝试找到元素
.click(Selector('.np-folder-name[title="testref"]'))
在//Find testref here 的位置。如果/一旦找到,我不想在//Find testref here 之后执行新的类别步骤。
我的问题是,我如何在网页上找到一个元素,我可以添加一个 if 函数作为一个步骤以在找到一个元素时忽略步骤?像 if 函数或类似函数?
【问题讨论】:
-
您是只想找到这个元素,还是找到并点击?
标签: javascript automated-tests e2e-testing web-testing testcafe