From aa025d7c6d13eaabbe52e1ed9d206c638f2ed720 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 14 Jul 2024 13:41:49 +0000 Subject: [PATCH 1/2] Update dependency com.saucelabs:saucebindings-testng to v1.5.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 43cc48bb..528f1702 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ 1.5.0 1.0.0 1.5.0 - 1.0.0 + 1.5.0 3.0.0-M5 From 6ea7a2e7389dc4d95b0a0d9ec1be794b42dc85a1 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 15 Jul 2024 01:08:43 +0200 Subject: [PATCH 2/2] Removing headless tests and fixing others --- .github/workflows/testng.yml | 2 +- pom.xml | 2 +- selenium-testng-examples/pom.xml | 64 +++++------ .../testng/CrossBrowserPlatformTest.java | 79 ++++++------- .../testng/ParallelSingleBrowserTest.java | 105 +++++++++--------- .../testng/SampleHeadlessSauceTest.java | 43 ------- .../testng/demo/SauceBindingsTest.java | 38 +++---- .../testng/demo/SauceBindingsTestngTest.java | 15 ++- .../selenium/testng/demo/SeleniumTest.java | 61 +++++----- 9 files changed, 181 insertions(+), 228 deletions(-) delete mode 100644 selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/SampleHeadlessSauceTest.java diff --git a/.github/workflows/testng.yml b/.github/workflows/testng.yml index 5e14a6aa..a7f2095a 100644 --- a/.github/workflows/testng.yml +++ b/.github/workflows/testng.yml @@ -33,4 +33,4 @@ jobs: env: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} - run: mvn test -pl selenium-testng-examples -X + run: mvn test -pl selenium-testng-examples diff --git a/pom.xml b/pom.xml index 528f1702..0bc5ab8a 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 1.0.0 1.5.0 1.5.0 - 3.0.0-M5 + 3.3.1 diff --git a/selenium-testng-examples/pom.xml b/selenium-testng-examples/pom.xml index bf746b0b..770a631e 100644 --- a/selenium-testng-examples/pom.xml +++ b/selenium-testng-examples/pom.xml @@ -1,37 +1,37 @@ - - - demo-java - com.saucelabs - 1.0-SNAPSHOT - - 4.0.0 + + demo-java + com.saucelabs + 1.0-SNAPSHOT + + 4.0.0 - selenium-testng-examples + selenium-testng-examples - - - com.saucelabs - saucebindings-testng - ${sauce_testng.version} - test - - + + + com.saucelabs + saucebindings-testng + ${sauce_testng.version} + test + + - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.version} - - methods - 10 - false - - - - - \ No newline at end of file + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.version} + + methods + 10 + false + + + + + diff --git a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/CrossBrowserPlatformTest.java b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/CrossBrowserPlatformTest.java index feeac32a..baabc13d 100644 --- a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/CrossBrowserPlatformTest.java +++ b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/CrossBrowserPlatformTest.java @@ -2,54 +2,55 @@ import com.saucelabs.saucebindings.options.SauceOptions; import com.saucelabs.saucebindings.testng.SauceParameterizedBaseTest; +import java.lang.reflect.Method; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import java.lang.reflect.Method; - /** * Tests whoing how to run cross browser tests with TestNG Sauce Bindings jar when Parameterized. */ public class CrossBrowserPlatformTest extends SauceParameterizedBaseTest { - @DataProvider(name = "sauceBrowsers", parallel = true) - public static Object[][] sauceBrowserDataProvider() { - return new Object[][]{ - // Uncomment the other data providers ONLY if you have the relevant Sauce VM concurrency - new Object[]{"chrome", "latest", "macOS 11.00"}, - new Object[]{"firefox", "latest", "macOS 11.00"}, - new Object[]{"chrome", "latest", "Windows 10"}, - new Object[]{"firefox", "latest", "Windows 10"}, - new Object[]{"chrome", "latest-1", "Windows 10"} - /*new Object[]{"firefox", "latest-1", "Windows 10"}, - new Object[]{"safari", "12.0", "macOS 10.14"}, - new Object[]{"MicrosoftEdge", "latest", "Windows 10"}, - new Object[]{"firefox", "65.0", "Windows 10"}, - new Object[]{"firefox", "64.0", "macOS 10.14"}, - new Object[]{"firefox", "63.0", "macOS 10.13"}, - new Object[]{"firefox", "62.0", "macOS 10.12"}, - new Object[]{"firefox", "61.0", "macOS 10.13"},*/ - }; - } + @DataProvider(name = "sauceBrowsers", parallel = true) + public static Object[][] sauceBrowserDataProvider() { + return new Object[][] { + // Uncomment the other data providers ONLY if you have the relevant Sauce VM concurrency + new Object[] {"chrome", "latest", "macOS 13"}, + new Object[] {"firefox", "latest", "macOS 13"}, + new Object[] {"chrome", "latest", "Windows 10"}, + new Object[] {"firefox", "latest", "Windows 10"}, + new Object[] {"chrome", "latest-1", "Windows 10"} + /* + new Object[]{"firefox", "latest-1", "Windows 10"}, + new Object[]{"safari", "12.0", "macOS 10.14"}, + new Object[]{"MicrosoftEdge", "latest", "Windows 10"}, + new Object[]{"firefox", "65.0", "Windows 10"}, + new Object[]{"firefox", "64.0", "macOS 10.14"}, + new Object[]{"firefox", "63.0", "macOS 10.13"}, + new Object[]{"firefox", "62.0", "macOS 10.12"}, + new Object[]{"firefox", "61.0", "macOS 10.13"}, + */ + }; + } - @Override - protected SauceOptions createSauceOptions(Method method, Object[] parameters) { - SauceOptions sauceOptions = new SauceOptions(); - sauceOptions.setCapability("browserName", parameters[0]); - sauceOptions.setCapability("browserVersion", parameters[1]); - sauceOptions.setCapability("platformName", parameters[2]); - return sauceOptions; - } + @Override + protected SauceOptions createSauceOptions(Method method, Object[] parameters) { + SauceOptions sauceOptions = new SauceOptions(); + sauceOptions.setCapability("browserName", parameters[0]); + sauceOptions.setCapability("browserVersion", parameters[1]); + sauceOptions.setCapability("platformName", parameters[2]); + return sauceOptions; + } - @Test(dataProvider = "sauceBrowsers") - public void testCase1(String browser, String browserVersion, String platformName) { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test(dataProvider = "sauceBrowsers") + public void testCase1(String browser, String browserVersion, String platformName) { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test(dataProvider = "sauceBrowsers") - public void testCase2(String browser, String browserVersion, String platformName) { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test(dataProvider = "sauceBrowsers") + public void testCase2(String browser, String browserVersion, String platformName) { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } } diff --git a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/ParallelSingleBrowserTest.java b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/ParallelSingleBrowserTest.java index 3b815db4..281d2510 100644 --- a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/ParallelSingleBrowserTest.java +++ b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/ParallelSingleBrowserTest.java @@ -4,67 +4,66 @@ import org.testng.Assert; import org.testng.annotations.Test; -/** - * Tests for running a single browser in parallel. - */ +/** Tests for running a single browser in parallel. */ public class ParallelSingleBrowserTest extends SauceBaseTest { - @Test - public void testCase1() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase1() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test - public void testCase2() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase2() { - @Test - public void testCase3() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test - public void testCase4() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase3() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test - public void testCase5() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase4() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test - public void testCase6() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase5() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test - public void testCase7() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase6() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test - public void testCase8() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase7() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test - public void testCase9() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase8() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } - @Test - public void testCase10() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void testCase9() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } + + @Test + public void testCase10() { + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } } diff --git a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/SampleHeadlessSauceTest.java b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/SampleHeadlessSauceTest.java deleted file mode 100644 index dd220877..00000000 --- a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/SampleHeadlessSauceTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.saucedemo.selenium.testng; - -import com.saucelabs.saucebindings.DataCenter; -import com.saucelabs.saucebindings.SauceOptions; -import com.saucelabs.saucebindings.SaucePlatform; -import com.saucelabs.saucebindings.SauceSession; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.testng.Assert; -import org.testng.ITestResult; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; - -/** - * Tests for running Headless on Sauce. - */ -public class SampleHeadlessSauceTest { - private RemoteWebDriver driver; - private SauceSession sauceSession; - - @Test - public void main() { - - SauceOptions sauceOptions = new SauceOptions(); - sauceOptions.setPlatformName(SaucePlatform.LINUX); - sauceOptions.setName("headless-chrome-test-java"); - sauceOptions.setBuild("Sample Headless Test"); - - sauceSession = new SauceSession(sauceOptions); - sauceSession.setDataCenter(DataCenter.US_EAST); - driver = sauceSession.start(); - - driver.get("https://www.saucedemo.com"); - System.out.println("title of page is: " + driver.getTitle()); - Assert.assertEquals("Swag Labs", driver.getTitle()); - } - - /* Sends results to SauceLabs.com */ - @AfterMethod - public void cleanUpAfterTestMethod(ITestResult result) { - driver.executeScript("sauce:job-result=" + (result.isSuccess() ? "passed" : "failed")); - sauceSession.stop(true); - } -} diff --git a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SauceBindingsTest.java b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SauceBindingsTest.java index 8a985229..da1c33e3 100644 --- a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SauceBindingsTest.java +++ b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SauceBindingsTest.java @@ -11,28 +11,26 @@ import java.lang.reflect.Method; -/** - * Example Tests for running with Sauce Bindings diriectly without test runner jar. - */ +/** Example Tests for running with Sauce Bindings directly without test runner jar. */ public class SauceBindingsTest { - protected SauceSession session; - protected RemoteWebDriver driver; + protected SauceSession session; + protected RemoteWebDriver driver; - @BeforeMethod - public void setup(Method method) { - SauceOptions options = SauceOptions.chrome().setName(method.getName()).build(); - session = new SauceSession(options); - driver = session.start(); - } + @BeforeMethod + public void setup(Method method) { + SauceOptions options = SauceOptions.chrome().setName(method.getName()).build(); + session = new SauceSession(options); + driver = session.start(); + } - @Test - public void correctTitle() { - driver.navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", driver.getTitle()); - } + @Test + public void correctTitle() { + driver.navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", driver.getTitle()); + } - @AfterMethod - public void teardown(ITestResult result) { - session.stop(result.isSuccess()); - } + @AfterMethod + public void teardown(ITestResult result) { + session.stop(result.isSuccess()); + } } diff --git a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SauceBindingsTestngTest.java b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SauceBindingsTestngTest.java index 3d3dae6d..3f1812ae 100644 --- a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SauceBindingsTestngTest.java +++ b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SauceBindingsTestngTest.java @@ -4,13 +4,12 @@ import org.testng.Assert; import org.testng.annotations.Test; -/** - * Example Test for running with the TestNG Sauce Bindings library. - */ +/** Example Test for running with the TestNG Sauce Bindings library. */ public class SauceBindingsTestngTest extends SauceBaseTest { - @Test - public void correctTitle() { - getDriver().navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", getDriver().getTitle()); - } + @Test + public void correctTitle() { + + getDriver().navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", getDriver().getTitle()); + } } diff --git a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SeleniumTest.java b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SeleniumTest.java index 17ddd086..db1ce2e7 100644 --- a/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SeleniumTest.java +++ b/selenium-testng-examples/src/test/java/com/saucedemo/selenium/testng/demo/SeleniumTest.java @@ -13,36 +13,35 @@ import java.net.MalformedURLException; import java.net.URL; -/** - * Example of running a TestNG test without using Sauce Bindings. - */ +/** Example of running a TestNG test without using Sauce Bindings. */ public class SeleniumTest { - protected RemoteWebDriver driver; - - @BeforeMethod - public void setup(Method method) throws MalformedURLException { - MutableCapabilities sauceOptions = new MutableCapabilities(); - sauceOptions.setCapability("username", System.getenv("SAUCE_USERNAME")); - sauceOptions.setCapability("accessKey", System.getenv("SAUCE_ACCESS_KEY")); - sauceOptions.setCapability("name", method.getName()); - sauceOptions.setCapability("browserVersion", "latest"); - - ChromeOptions options = new ChromeOptions(); - options.setCapability("sauce:options", sauceOptions); - URL url = new URL("https://ondemand.us-west-1.saucelabs.com/wd/hub"); - - driver = new RemoteWebDriver(url, options); - } - - @Test - public void correctTitle() { - driver.navigate().to("https://www.saucedemo.com"); - Assert.assertEquals("Swag Labs", driver.getTitle()); - } - - @AfterMethod - public void teardown(ITestResult result) { - String status = result.isSuccess() ? "passed" : "failed"; - driver.executeScript("sauce:job-result=" + status); - } + + protected RemoteWebDriver driver; + + @BeforeMethod + public void setup(Method method) throws MalformedURLException { + MutableCapabilities sauceOptions = new MutableCapabilities(); + sauceOptions.setCapability("username", System.getenv("SAUCE_USERNAME")); + sauceOptions.setCapability("accessKey", System.getenv("SAUCE_ACCESS_KEY")); + sauceOptions.setCapability("name", method.getName()); + sauceOptions.setCapability("browserVersion", "latest"); + + ChromeOptions options = new ChromeOptions(); + options.setCapability("sauce:options", sauceOptions); + URL url = new URL("https://ondemand.us-west-1.saucelabs.com/wd/hub"); + + driver = new RemoteWebDriver(url, options); + } + + @Test + public void correctTitle() { + driver.navigate().to("https://www.saucedemo.com"); + Assert.assertEquals("Swag Labs", driver.getTitle()); + } + + @AfterMethod + public void teardown(ITestResult result) { + String status = result.isSuccess() ? "passed" : "failed"; + driver.executeScript("sauce:job-result=" + status); + } }