[英]If statement in Cypress
How can i write correctly this code, in such a way that it is a valid if syntax, and if it is not respected, should I have someone else with it?我怎样才能正确地编写这段代码,使其成为一种有效的 if 语法,如果它不被尊重,我应该让其他人使用它吗?
Basically I want to search for a text in a popup window. If it does not exist, enter the code in else statement.基本上我想在弹出窗口中搜索文本 window。如果它不存在,请在 else 语句中输入代码。
cy.get(".ibxudA").find('.WildnessText-kRKTej').should('have.text',"Wildness")
You can yield the subject returned by find
and evaluate the text using JQuery commands.您可以使用 JQuery 命令生成find
返回的主题并评估文本。
cy.get('.ibxudA').find('.WildnessText-kRKTejj').then(($el) => {
if ($el.text() !== "Wildness") {
// code to execute if it does not have the text
} else {
// code to execute if it does have the text
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.