Step (1)
Define all these values which are in your dropdown in an array for example.👇
var Reference = ["LinkedIn", "Facebook", "Twitter", "Other", "Instagram", "Email", "Friends"];
Step (2)
Then define a random function for example👇
var randreferences = Reference[Math.floor(Math.random() * Reference.length)];
Step (3)
Call this random function in Select() method. for example 👇
cy.get('#aboutUs').select(randreferences)
Important Note:This code should be in same test case where you are trying to do this one
Enjoy✌
Full Code ==>👇👇👇
var Reference = ["LinkedIn", "Facebook", "Twitter", "Other", "Instagram", "Email", "Friends"];
Comments
Post a Comment