Reputation: 659
getUsertextbox4()
{
cy.get('#multiselect-field-label-1')
}
getsubmitButton()
{
cy.get('.security--button');
}
this is the code im using and when the first element is not found , tests stop there it self , how to make the test continue further and verify others things in the test suite ?
Upvotes: 0
Views: 323
Reputation: 26
You can do in this way:
getUsertextbox4()
{
cy.get('body').then(($body) => {
if ($body.find('#multiselect-field-label-1').length) {
// continue the test
} else {
// you can throw error here, or just print out a warning message
// and keep testing other parts of your code, eg:
Cypress.log({ warning: 'unable to find the element' });
getsubmitButton()
...
}
});
}
This works because <body>
is always there, and you can customize the action by checking the existence of target element on body.
Upvotes: 1