不太熟悉 js/node.js。使用 codeceptjs/puppeteer 进行一些自动化测试。现在正在尝试编辑测试中的描述。但有时没有描述——因此“编辑描述”按钮不存在——而是有一个“添加描述”按钮。所以我写了一个 if 语句,指定 . 但代码只是滚动它。语句是什么并不重要,它只是移动到下一行。当前if (desc)和if(!desc)两者都执行相同的功能 - 它转到 if 语句中的下一行。这会导致错误,因为已经有描述,因此“添加描述”按钮不可用。我不确定发生了什么。
Scenario('test something', (I, userLoginPage, FBPagePage) => {
userLoginPage.validate();
I.click('//*[@id="card_611"]');
// clicks the card
var desc = '//*[@id="show_card_description"]/section/button';
// add description button
// tried 'Add description' but the result was the same
if (desc){
// this is where the error happens. it simply looks for the add description button
// no matter what button is there it decides to click the 'add description' button
I.click('//*[@id="show_card_description"]/section/button');
// click add desc button
I.fillField('//*[@id="description_editor_container"]/div[2]/div[1]',
'not admin user created this description thanks to automated testing');
// types this stuff
I.click('//*[@id="description_editor_container"]/button[1]');
// saves it
I.wait(1);
}
I.click('//*[@id="show_card_description"]/section/h5/a');
// click edit desc button if a description already exists
I.fillField('//*[@id="description_editor_container"]/div[2]/div[1]', 'not admin user edited this description thanks to automated testing');
I.click('//*[@id="description_editor_container"]/button[1]');
I.say('success!')
});
Cats萌萌
喵喔喔
相关分类