diff --git a/pom.xml b/pom.xml index a8b0503..9e2d807 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.seleniumhq.selenium selenium-java - 2.53.1 + 3.11.0 test diff --git a/src/test/java/com/yourcompany/Tests/W3CTest.java b/src/test/java/com/yourcompany/Tests/W3CTest.java new file mode 100644 index 0000000..82526ce --- /dev/null +++ b/src/test/java/com/yourcompany/Tests/W3CTest.java @@ -0,0 +1,94 @@ +package com.yourcompany.Tests; + +import com.saucelabs.junit.Parallelized; +import com.yourcompany.Pages.GuineaPigPage; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; +import org.openqa.selenium.By; +import org.openqa.selenium.MutableCapabilities; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.edge.EdgeOptions; +import org.openqa.selenium.firefox.FirefoxOptions; +import org.openqa.selenium.ie.InternetExplorerOptions; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.safari.SafariOptions; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Arrays; +import java.util.Collection; + +import static org.junit.Assert.assertFalse; + +@RunWith(Parallelized.class) +public class W3CTest { + + private WebDriver driver; + + /** + * Collection of data parametrizes tests, in this case + * using W3C compliant browsers (does not include Chrome here) + * @return + */ + @Parameters + public static Collection data() { + return Arrays.asList(new Object[][] { + {new FirefoxOptions(), "latest", "Windows 10"}, + {new FirefoxOptions(), "58.0", "OS X 10.12"}, + {new EdgeOptions(), "latest", "Windows 10"}, + {new SafariOptions(), "latest", "OS X 10.12"}, + {new InternetExplorerOptions(), "latest", "Windows 7"}, + }); + } + + @Parameter + public MutableCapabilities options; + + @Parameter(1) + public String browserVersion; + + @Parameter(2) + public String platformName; + + @Before + public void setup() throws MalformedURLException { + String username = System.getenv("SAUCE_USERNAME"); + String accesskey = System.getenv("SAUCE_ACCESS_KEY"); + + // condition particular capabilities as needed + options.setCapability("browserVersion", browserVersion); + options.setCapability("platformName", platformName); + + MutableCapabilities sauceOptions = new MutableCapabilities(); + sauceOptions.setCapability("seleniumVersion", "3.11.0"); + sauceOptions.setCapability("name", "W3C"); + sauceOptions.setCapability("build", "JUnit Case - Follow Link Test"); + + options.setCapability("sauce:options", sauceOptions); + + driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + "@ondemand.saucelabs.com/wd/hub"), options); + + } + + @After + public void teardown(){ + driver.quit(); + } + + @Test + public void followLinkTest(){ + GuineaPigPage page = GuineaPigPage.visitPage(driver); + + page.followLink(); + + assertFalse(page.isOnPage()); + } +}