hiding your password in java class file for a test case

user3792255 picture user3792255 · Oct 9, 2014 · Viewed 8.7k times · Source

I am trying to write a selenium test case which will be put on company jenkins server where all the employee will have access to every java files I create.

public static void main(String[] args) {


    WebDriver driver = new FirefoxDriver();

    driver.get("http://somesite.com");

    driver.manage().window().maximize();

    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 



    WebElement userName=driver.findElement(By.xpath(".//*[@id='username']"));
    userName.clear();
    userName.sendKeys("[email protected]");

    WebElement password=driver.findElement(By.xpath(".//*[@id='password']"));
    passwordclear();
    password.sendKeys("password");
    password.submit();

   driver.quit();

What I want to do is not show the "password" there, I don't want other employees to see my password. Is there any way I can do that?

Answer

Zachary Craig picture Zachary Craig · Oct 9, 2014

You could always encrypt it or base64 it or something so it isn't at least in plain text, but to be honest any sort of hardcoded password encryption can be reversed if they have / can see the source code.