I want to select a random value from a dropdown, with the restriction that a specific value should not be selected.
const initialOrderReason = cy.xpath("//tbody/tr[1]/td[4]");
tkm
.dropdownOptions()
.should("be.visible")
.then((options) => {
cy.get(Cypress._.sample(options))
.not.contain(initialOrderReason)
});
how is it possible?
There's a lot relevant code that you have not shown, including the HTML but here's my solution based on what you've given
cy.xpath("//tbody/tr[1]/td[4]")should be accessed it via.then()instead of the returned value.And for all elements extract the text of the elements.