...
To help anonymize our testing accounts and not expose these in our code base, we set our gmail username and password as environment variables on local machines. In a terminal window run: sudo nano /etc/profile. Add the following lines to the bottom of the file:
Code Block | ||
---|---|---|
| ||
export Selenium_User1="example@gmail.com" export Selenium_Pass1="examplePa$$word" |
- Save your changes and log out of your computer and log back in.
- Run the command: env | grep Selenium
- You should get back the variable names and values. If not try running the command
- source
/etc
/profile
- In the selenium java code, now create a string variable that you will reference as your password with it value equal to:
- System.getenv("<environment variable>");
Opening a Web Browser
System.setProperty("webdriver.chrome.driver", "/home/<username>/file/path/to/chromedriver");
...