How to create a dynamic email id in selenium cucumber java in automation testing
public static final DateFormat EMAIL_ DATE_FORMAT = new SimpleDateFormat("HHmmss-dd-MMM-yyyy”);
This method you can create in superclass that class name is Utils
public static String getUniqueEmailName() {
return EMAIL_ DATE_FORMAT.format(new Date()) + “@hotmail.com";
}
And then in sub class you can call like this…
public void Click(String Value, Utils utils) throws Exception {
public static String genEmailEdited;
genEmailEdited = superclass or utils.getUniqueEmailName();
System.out.println("the new edited email is --------->" + genEmailEdited);
driver.findElement(By.xpath(xpathcomehere )).sendKeys(genEmailEdited);
}
OR
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
public static void main(String[] argv) throws Exception {
Format formatter = new SimpleDateFormat("EEE, dd/MM/yyyy");
String today = formatter.format(new Date());
System.out.println("Today : " + today);
}
}
No comments:
Post a Comment