Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#323] Improvement: Enable passing credentials for Browserstack via environmental variables for better use in CI/CD #324

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ else if (Neodymium.configuration().useProxy())
var remoteDebuggingPort = PortProber.findFreePort();
Neodymium.setRemoteDebuggingPort(remoteDebuggingPort);
options.addArguments("--remote-debugging-port=" + remoteDebuggingPort);

if (config.getArguments() != null && config.getArguments().size() > 0)
{
options.addArguments(config.getArguments());
Expand Down Expand Up @@ -361,18 +361,18 @@ else if (edgeBrowsers.contains(browserName))

final String driverInPathPath = new ExecutableFinder().find("msedgedriver");
final EdgeOptions options = new EdgeOptions().merge(capabilities);

if (config.getArguments() != null && config.getArguments().size() > 0)
{
options.addArguments(config.getArguments());
}

EdgeBuilder edgeBuilder = new EdgeBuilder(config.getDriverArguments());
if (StringUtils.isNotBlank(driverInPathPath))
{
edgeBuilder.usingDriverExecutable(new File(driverInPathPath));
}

wDSC.setWebDriver(new EdgeDriver(edgeBuilder.build(), options));
}
else if (safariBrowsers.contains(browserName))
Expand Down Expand Up @@ -404,7 +404,7 @@ else if (safariBrowsers.contains(browserName))
config.getGridProperties().put("userName", testEnvironmentProperties.getUsername());
config.getGridProperties().put("accessKey", testEnvironmentProperties.getPassword());
final String buildId = StringUtils.isBlank(System.getenv("BUILD_NUMBER")) ? "local run" : System.getenv("BUILD_NUMBER");
config.getGridProperties().put("sessionName", testClassInstance.getClass().toString());
config.getGridProperties().put("sessionName", testClassInstance instanceof String ? testClassInstance : testClassInstance.getClass().toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question @oomelianchuk this line has nothing to do with the ticket, but seems to be a bugfix? Or even more general, what is the testClassInstance? I checked and it is only called in one place where we hand over the test name.
So basically:

  1. would it make sense to just pass the testName as a string?
  2. the parameter is not part of the javaDoc, we need to change that.

config.getGridProperties().put("buildName", "Test Automation");
config.getGridProperties().put("buildIdentifier", buildId);
if (testEnvironmentUrl.contains("browserstack"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ protected TestEnvironment(Properties properties, String baseKey)
{
url = properties.getProperty(baseKey + ".url");
username = properties.getProperty(baseKey + ".username");
if (StringUtils.isBlank(username))
{
username = System.getenv("BROWSERSTACK_USERNAME");
}
password = properties.getProperty(baseKey + ".password");
if (StringUtils.isBlank(password))
{
password = System.getenv("BROWSERSTACK_PASSWORD");
}
optionsTag = properties.getProperty(baseKey + ".optionsTag");
useProxy = Boolean.valueOf(properties.getProperty(baseKey + ".proxy"));
if (useProxy)
Expand Down