public final class BrowserstackCredential extends Object
See BrowserstackCredential.Mode
for supported credential
storage approaches:
BrowserstackCredential.Mode.LOCAL_FILE
(in local text file),BrowserstackCredential.Mode.SOURCE_CONSTANT
(embedded in source), andBrowserstackCredential.Mode.CONSOLE_PROMPT
(console prompt).Modifier and Type | Class and Description |
---|---|
static class |
BrowserstackCredential.Mode
Enumeration enumerates supported ways to retrieve credential.
|
static class |
BrowserstackCredential.UsingRecycledCredentialInstance
Problem of using a recycled credential.
|
Modifier and Type | Field and Description |
---|---|
private static String |
AUTOMATE_KEY_LABEL
Automate key label for credential on disk.
|
private static String |
AUTOMATE_KEY_PROMPT
Automate key prompt.
|
private static String |
AUTOMATE_KEY_REGEX
Java regular expression to validate automate key.
|
private String |
automateKey
Automate key for automated login to Browserstack.
|
private static BrowserstackCredential |
browserstackCredential
Singleton holder.
|
private static String |
CRED_PATH
Specifies location of file for LOCAL_FILE retreival mode.
|
private static String |
credentialPath
path from which to retrieve credential file on disk.
|
private static BrowserstackCredential.Mode |
DEFAULT_RETRIEVAL_MODE
Sets default retrieval mode.
|
private static String |
DUMMY_AUTOMATE_KEY
Default automate key test for automated login to Browserstack, used
for testing only if CONSTANT_USER_NAME is null.
|
private static String |
DUMMY_USER_NAME
Default User name test for automated login to Browserstack, used for
testing only if CONSTANT_AUTOMATE_KEY is null.
|
private static boolean |
isInitialized
Has a credential ever been initialized?
|
private boolean |
isMutable
Tracks whether credential contains information.
|
private static BrowserstackCredential.Mode |
retrievalMode
Defines from where credential is to be retrieved, from disk, console
prompt, etc.
|
private static String |
USER_NAME_LABEL
Username label for credential on disk.
|
private String |
userName
User name for automated login to Browserstack.
|
private static String |
USERNAME_PROMPT
User name prompt.
|
private org.openqa.selenium.WebDriver |
webDriver
Selenium web driver; direct interface to system under test.
|
Modifier | Constructor and Description |
---|---|
private |
BrowserstackCredential(String userNameParam,
String automateKeyParam)
Private constructor called by factory method newBrowserstackCredential.
|
Modifier and Type | Method and Description |
---|---|
String |
getAutomateKey()
Returns automate key for use with BrowserStack.
|
static String |
getAutomateKeyConstant()
Automate key prompt accessor.
|
static String |
getAutomateKeyFileKey()
Retrieves automate key label for credential in local disk file.
|
static String |
getAutomateKeyPrompt()
Automate key prompt accessor.
|
static String |
getAutomateKeyRegex()
Returns regular expression used to evalute automate key.
|
static UrlWrapper |
getBrowserstackAutomateUrl()
Accesses test infrastructure info - URL of testing system.
|
static BrowserstackCredential |
getBrowserstackCredential()
Returns credential.
|
static String |
getCredentialFilePath()
Retrieves location of credential file on local disk.
|
Boolean |
getIsMutable()
Is credential empty? Once setImmutable is run, then it is no longer
possible to make changes to the credential.
|
private static BrowserstackCredential.Mode |
getRetrievalMode()
Retrieves current retrieval mode.
|
String |
getUserName()
Returns user name for use with Browserstack.
|
static String |
getUsernameConstant()
Username default accessor.
|
static String |
getUsernameKeyFileKey()
Retrieves username label for credential on disk.
|
static String |
getUsernamePrompt()
Username prompt accessor.
|
static boolean |
isInitialized()
Returns whether a credential has ever been initialized?
|
static void |
killInstance()
Kills singleton for JUNIT testing purposes.
|
static BrowserstackCredential |
newBrowserstackCredential()
Instantiates credential based on current mode.
|
static BrowserstackCredential |
newBrowserstackCredential(String usernameParam,
String automateKeyParam)
Factory creates credential instance, using parameters.
|
private static BrowserstackCredential |
newBrowserstackCredential(String usernameParam,
String automateKeyParam,
BrowserstackCredential.Mode modeParam)
Private factory handles everyting using flags.
|
void |
promptCredential()
Uses console to prompt for credential; populates credential with data.
|
static void |
setCredentialFilePath(String pathParam)
Sets location of credential file on local disk.
|
void |
setImmutable()
Makes instance immutable.
|
static void |
setRetrievalMode(BrowserstackCredential.Mode modeParam)
Sets default retrieval mode.
|
static boolean |
validateAutomateKey(String candidateString)
Ensures automate key is correct length and contains correct characters.
|
private static final BrowserstackCredential.Mode DEFAULT_RETRIEVAL_MODE
private static final String DUMMY_AUTOMATE_KEY
private static final String DUMMY_USER_NAME
private static final String CRED_PATH
private static final String USER_NAME_LABEL
private static final String AUTOMATE_KEY_LABEL
private static String credentialPath
private static BrowserstackCredential.Mode retrievalMode
private static BrowserstackCredential browserstackCredential
private static final String USERNAME_PROMPT
private static final String AUTOMATE_KEY_PROMPT
private static final String AUTOMATE_KEY_REGEX
private static boolean isInitialized
private org.openqa.selenium.WebDriver webDriver
private String userName
private boolean isMutable
private String automateKey
private static BrowserstackCredential newBrowserstackCredential(String usernameParam, String automateKeyParam, BrowserstackCredential.Mode modeParam)
usernameParam
- Browserstack UsernameautomateKeyParam
- Browserstack automate keymodeParam
- Retrieval Mode or Mode.DEFAULT to use defaultIllegalArgumentException
- if either parameter is nullpublic static BrowserstackCredential newBrowserstackCredential(String usernameParam, String automateKeyParam)
usernameParam
- Browserstack UsernameautomateKeyParam
- Browserstack automate keyIllegalArgumentException
- if either parameter is nullpublic static BrowserstackCredential newBrowserstackCredential() throws BrowserstackAutomateKeyException
setRetrievalMode(us.johnmeyer.sitetest.credentials.BrowserstackCredential.Mode)
BrowserstackAutomateKeyException
- if the automate key is malformedpublic static String getUsernameKeyFileKey()
public static String getAutomateKeyFileKey()
public static void setCredentialFilePath(String pathParam)
pathParam
- Stores location of credential file.public static String getCredentialFilePath()
public static void setRetrievalMode(BrowserstackCredential.Mode modeParam)
modeParam
- retrieval mode requestedprivate static BrowserstackCredential.Mode getRetrievalMode()
public static boolean isInitialized()
public static UrlWrapper getBrowserstackAutomateUrl()
IllegalArgumentException
- if URL cannot be validatedpublic static void killInstance()
public static BrowserstackCredential getBrowserstackCredential()
IllegalStateException
- if credential was not yet initalized.public static String getAutomateKeyRegex()
public static String getUsernameConstant()
public static String getAutomateKeyConstant()
public static String getUsernamePrompt()
public static String getAutomateKeyPrompt()
public static boolean validateAutomateKey(String candidateString)
candidateString
- string to testpublic Boolean getIsMutable()
public void setImmutable()
public void promptCredential() throws BrowserstackAutomateKeyException
BrowserstackAutomateKeyException
- if invalid value entered at the
prompt.public String getUserName()
public String getAutomateKey()
Copyright © 2018. All rights reserved.