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

Use SAUCE_REST_ENDPOINT TO configure OnDemand endpoint #19

Open
wants to merge 5 commits into
base: master
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
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
<version>3.141.59</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.saucelabs</groupId>
<artifactId>sauce_junit</artifactId>
<version>2.1.20</version>
<version>2.1.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
30 changes: 23 additions & 7 deletions src/test/java/com/yourcompany/Tests/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.saucelabs.junit.SauceOnDemandTestWatcher;

import java.net.URL;
import java.util.HashMap;
import java.util.LinkedList;

import com.saucelabs.common.SauceOnDemandSessionIdProvider;
Expand All @@ -36,6 +37,7 @@ public class TestBase implements SauceOnDemandSessionIdProvider {
public static String accesskey = System.getenv("SAUCE_ACCESS_KEY");
public static String seleniumURI;
public static String buildTag;
public static HashMap<String, String> endpoints = new HashMap<>();
/**
* Constructs a {@link SauceOnDemandAuthentication} instance using the supplied user name/access key. To use the authentication
* supplied by environment variables or from an external file, use the no-arg {@link SauceOnDemandAuthentication} constructor.
Expand Down Expand Up @@ -91,11 +93,11 @@ public TestBase(String os, String version, String browser, String deviceName, St
public static LinkedList browsersStrings() {
LinkedList browsers = new LinkedList();

browsers.add(new String[]{"Windows 10", "14.14393", "MicrosoftEdge", null, null});
browsers.add(new String[]{"Windows 10", "49.0", "firefox", null, null});
browsers.add(new String[]{"Windows 7", "11.0", "internet explorer", null, null});
browsers.add(new String[]{"OS X 10.11", "10.0", "safari", null, null});
browsers.add(new String[]{"OS X 10.10", "54.0", "chrome", null, null});
browsers.add(new String[]{"Windows 10", "latest", "MicrosoftEdge", null, null});
browsers.add(new String[]{"Windows 10", "latest", "firefox", null, null});
browsers.add(new String[]{"Windows 7", "latest", "internet explorer", null, null});
browsers.add(new String[]{"macOS 10.13", "latest", "safari", null, null});
browsers.add(new String[]{"macOS 10.14", "latest", "chrome", null, null});
return browsers;
}

Expand Down Expand Up @@ -146,8 +148,22 @@ public String getSessionId() {

@BeforeClass
public static void setupClass() {
//get the uri to send the commands to.
seleniumURI = "@ondemand.saucelabs.com:443";
endpoints.put("https://saucelabs.com/", "@ondemand.saucelabs.com:443");
endpoints.put("https://eu-central-1.saucelabs.com/", "@ondemand.eu-central-1.saucelabs.com:443");
endpoints.put("https://us-east-1.saucelabs.com/", "@ondemand.us-east-1.saucelabs.com:443");

String sauceRestEndpoint = System.getenv("SAUCE_REST_ENDPOINT");
System.out.printf("SAUCE_REST_ENDPOINT: %s %n", sauceRestEndpoint);

if (endpoints.containsKey(sauceRestEndpoint)) {
System.out.printf("Setting OnDemand endpoint to: %s %n", endpoints.get(sauceRestEndpoint));
seleniumURI = endpoints.get(sauceRestEndpoint);
}
else { // set us-west-1 as default
System.out.println("Setting OnDemand endpoint to default.");
seleniumURI = "@ondemand.saucelabs.com:443";
}

//If available add build tag. When running under Jenkins BUILD_TAG is automatically set.
//You can set this manually on manual runs.
buildTag = System.getenv("BUILD_TAG");
Expand Down