Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #96 from saucelabs/quick-clean
Browse files Browse the repository at this point in the history
Delete the old start() method that used concrete RemoteDriver, change…
  • Loading branch information
nadvolod authored Jun 13, 2019
2 parents 436a54a + 5a4c71d commit f1e88de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 42 deletions.
16 changes: 3 additions & 13 deletions common/src/main/java/com/saucelabs/remotedriver/SauceSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.ie.InternetExplorerOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.safari.SafariOptions;

import java.net.MalformedURLException;
import java.net.URL;

public class SauceSession {
static String sauceSeleniumServer = "https://ondemand.saucelabs.com/wd/hub";
Expand Down Expand Up @@ -50,21 +48,13 @@ public SauceSession(RemoteDriverInterface remoteManager) {
capabilities = new MutableCapabilities();
}

public WebDriver getInstanceOld() throws MalformedURLException
public SauceSession start() throws MalformedURLException
{

seleniumServer = getSeleniumServer();
capabilities = getCapabilities();

return remoteDriverManager.getRemoteWebDriver(seleniumServer, capabilities);
webDriver = remoteDriverManager.getRemoteWebDriver(seleniumServer, capabilities);
return this;
}

public SauceSession start() throws MalformedURLException {
seleniumServer = getSeleniumServer();
capabilities = getCapabilities();
webDriver = new RemoteWebDriver(new URL(seleniumServer), capabilities);
return this;
}
public String getSeleniumServer() {
if (seleniumServer == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
package com.saucelabs.common.unit;

<<<<<<< HEAD:common/src/test/java/com/saucelabs/common/unit/SauceJavaScriptStringsTest.java
import com.saucelabs.common.SauceApi;
import com.saucelabs.common.SauceJavaScriptStrings;
import org.junit.Assert;
=======
>>>>>>> b3926482d56790d2c587b3a965d3c63a2222669a:common/src/test/java/com.saucelabs.common/SauceJavaScriptStringsTest.java
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class SauceJavaScriptStringsTest {

<<<<<<< HEAD:common/src/test/java/com/saucelabs/common/unit/SauceJavaScriptStringsTest.java
=======
@Test
public void shouldReturnCorrectCommandForTrueResult()
{
sauceHelper = new SauceHelper();
Boolean testStatus = true;
String actualTestResultCommand = sauceHelper.getTestResultString(testStatus);

assertEquals("sauce:job-result=true", actualTestResultCommand);
}

@Test
public void shouldReturnCorrectCommandForFalseResult()
{
sauceHelper = new SauceHelper();
Boolean testStatus = false;

String actualTestResultCommand = sauceHelper.getTestResultString(testStatus);
assertEquals("sauce:job-result=false", actualTestResultCommand);
}
>>>>>>> b3926482d56790d2c587b3a965d3c63a2222669a:common/src/test/java/com.saucelabs.common/SauceJavaScriptStringsTest.java
@Test
public void shouldBeCorrectTestNamePrefix()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void defaultConstructor_instantiated_setsConcreteDriverManager()
public void getInstance_serverNotSet_setsSauceSeleniumServer() throws MalformedURLException {
RemoteDriverInterface fakeRemoteDriver = mock(RemoteDriverInterface.class);
sauceSession = new SauceSession(fakeRemoteDriver);
sauceSession.getInstanceOld();
sauceSession.start();
String expectedServer = "https://ondemand.saucelabs.com/wd/hub";
assertEquals(expectedServer, sauceSession.seleniumServer);
}
Expand All @@ -51,7 +51,7 @@ public void getInstance_serverNotSet_setsSauceSeleniumServer() throws MalformedU
public void browserNameCapability_isSetToCorrectKey() throws MalformedURLException {
RemoteDriverInterface fakeRemoteDriver = mock(RemoteDriverInterface.class);
sauceSession = new SauceSession(fakeRemoteDriver);
sauceSession.getInstanceOld();
sauceSession.start();
String expectedBrowserCapabilityKey = "browserName";
String actualBrowser = sauceSession.capabilities.getCapability(expectedBrowserCapabilityKey).toString();
assertThat(actualBrowser, CoreMatchers.not(isEmptyOrNullString()));
Expand All @@ -71,7 +71,7 @@ public void getCapabilities_browserNameCapSet_validKeyExists2() {
public void setCapability_platformName_returnsCorrectOs() throws MalformedURLException {
RemoteDriverInterface fakeRemoteDriver = mock(RemoteDriverInterface.class);
sauceSession = new SauceSession(fakeRemoteDriver);
sauceSession.getInstanceOld();
sauceSession.start();
String correctPlatformKey = "platformName";
String actualBrowser = sauceSession.capabilities.getCapability(correctPlatformKey).toString();
assertThat(actualBrowser, IsEqualIgnoringCase.equalToIgnoringCase("Windows 10"));
Expand All @@ -80,7 +80,7 @@ public void setCapability_platformName_returnsCorrectOs() throws MalformedURLExc
public void setCapability_browserVersion_returnsCorrectVersion() throws MalformedURLException {
RemoteDriverInterface fakeRemoteDriver = mock(RemoteDriverInterface.class);
sauceSession = new SauceSession(fakeRemoteDriver);
sauceSession.getInstanceOld();
sauceSession.start();
String correctKey = "browserVersion";
String actualBrowser = sauceSession.capabilities.getCapability(correctKey).toString();
assertThat(actualBrowser, IsEqualIgnoringCase.equalToIgnoringCase("latest"));
Expand Down

0 comments on commit f1e88de

Please sign in to comment.