Grip It and Rip It
❔ Need help selecting a random element out of a list
Hey I'm very new to learning C# and I'm trying to figure out how I would select a random element from a list. I am working with Selenium browser automation and I have a list of potential elements that I want the browser to interact with. I essentially want one element from the list to be selected to be clicked on each time the program runs.
It seems like there should be a more elegant solution than creating an IF, ELSE IF list with 22 entries for the 22 potential variables that could be selected. Is there a way to simply choose an item from a list and append the .click command onto the variable that has been selected?
7 replies