How to Encrypt password for Selenium Webdriver

To secure our passwords we can use Base64 encoding scheme in Selenium WebDriver. We will import this Bas64 class in our script to get the decode password.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
import java.util.Base64;

public class passwordEncryption(){

public static WebDriver driver;

String password = “simpletesters123”;

String encryptedPassword = Base64.getDecoder().decode(decodepassword.getBytes());

driver = new FirefoxDriver();
driver.get(“http://facebook.com”);
driver.findElement(By.id(“email”)).sendKeys(“Hello”);
driver.findElement(By.id(“pass”)).sendKeys(“encryptedPassword “);
driver.findElement(By.id(“u_o_q”)).click();
driver.close();

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s