Optional input fields based on different environme...
# i-need-help
f
I have a portal which has difference in fields based on different environment to input text , is there a way i can input field value if those field is present if not just ignore and go to next step. Please share some example or references which can be used to implement the above
f
Got you this is a case of conditional testing. I mean it is obviously not the ideal case it would be better to set a env. flag for which environment and then in case of the flag you check. But if you want to do it conditionally it can be done using
Copy code
cy.get('body').then((body) => if( body.find(selector-to-potential-input).length > 0) {
cy.get(selector-to-potential-input
})}
Like i mentioned it would be better to just ensure it in the beginning because this could theoretically flake on the find and say its not there but the field exists and so on ^^. More info on conditionals https://docs.cypress.io/guides/core-concepts/conditional-testing
f
thank you i implemented as suggested above, can you check on https://discord.com/channels/755913899261296641/1110970850720632862 this query if this is something you can assist too
f
Awesome glad i could help!