I am trying to print test data used in webdriver test inside print string in Java
I need to print several variables used in a class inside the system.out.print function (printf / println / whatever).
Can you guys help me?
public String firstname; public String lastname; firstname = "First " + genData.generateRandomAlphaNumeric(10); driver.findElement(By.id("firstname")).sendKeys(firstname); lastname = "Last " + genData.generateRandomAlphaNumeric(10); driver.findElement(By.id("lastname")).sendKeys(lastname);
I need these printouts in a print statement as:
Name: (the value of the variable that I used)
Surname: (the value of the variable that I used)
Using what follows gives an accurate result.
But I need to reduce the number of printf lines and use a more efficient way.
System.out.printf("First Name: ", firstname); System.out.printf("Last Name: ", lastname);
Thanks!
java println
Harshini
source share