how to generate random alpha numeric with special symbols in Java selenium WD

By : Mahadev
Source: Stackoverflow.com
Question!

I am looking for a random alpha-numeric with special symbols password generator for automating a web application where i need to create new password every time the scenario is executed. For example, a generated string of length 9 might look something like "ZgFd123$#"

By : Mahadev


Answers

You can see here. Or you can user Java Random() and Character from 33 to 126. Example:

Random random = new Random();
String str="";
for (int i=0; i<9;i++){
    str += Character.toString(random(93)+33);
}
By : Sah4ez32


You could use Convert.ChangeType for that:

public void Add(object value)
{
    var t = Convert.ChangeType(value, typeof(T));
}

See the fiddle: https://dotnetfiddle.net/0Tfgyz



If you need object insead of T you can use dynamic in your Add method.

 public void Add(object value)
 {
      //When T is decimal, then I get 
      // System.InvalidCastException
      dynamic t1 = value;
      var t = (T)t1;
 }
By : steryd


This video can help you solving your question :)
By: admin