How to encode password in Selenium.

Selenium does not have any inbuilt function to encode password unlike other tools i..e QTP etc.
So in order to hide password or encode password we have to use base64 java encoding/decoding & create a reusable funtion which can be used to encode/ decode a given string.

Code for encoing / decoding is -

// encode data using BASE64
byte[]   bytesEncoded = Base64.encodeBase64("Password".getBytes());
System.out.println("ecncoded value is " + new String(bytesEncoded ));

// Decode data by processing encoded data
byte[] valueDecoded= Base64.decodeBase64(bytesEncoded );
System.out.println("Decoded value is " + new String(valueDecoded));

WebDriver Code - 


Comments

Popular posts from this blog

ISTQB Mocktest 1

Cloud Byte 2 - Common AWS Services for Cloud Practitioner Certification (CCP)

Equivalence Class Partitioning