From d5dc0b0652b797a4f23fda2ada949703efc5fcdc Mon Sep 17 00:00:00 2001 From: Mohammad Faisal Khatri Date: Mon, 25 Mar 2024 16:31:05 +0530 Subject: [PATCH] minor changes made (#136) * minor changes related to retry listener and tests made * updated drivermanager class back to use getProperty method for lambdatest credentials --- .../mfaisalkhatri/drivers/DriverManager.java | 34 +++++++++---------- .../tests/retrytests/RetryFailedTests.java | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/io/github/mfaisalkhatri/drivers/DriverManager.java b/src/main/java/io/github/mfaisalkhatri/drivers/DriverManager.java index 032023f..9f5ac72 100644 --- a/src/main/java/io/github/mfaisalkhatri/drivers/DriverManager.java +++ b/src/main/java/io/github/mfaisalkhatri/drivers/DriverManager.java @@ -1,14 +1,5 @@ package io.github.mfaisalkhatri.drivers; -import static java.text.MessageFormat.format; - -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Paths; -import java.time.Duration; -import java.util.HashMap; -import java.util.Objects; - import io.github.bonigarcia.wdm.WebDriverManager; import io.github.mfaisalkhatri.enums.Browsers; import org.apache.logging.log4j.LogManager; @@ -19,6 +10,15 @@ import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.remote.RemoteWebDriver; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Paths; +import java.time.Duration; +import java.util.HashMap; +import java.util.Objects; + +import static java.text.MessageFormat.format; + /** * @author Faisal Khatri * @since 24/07/2022 @@ -28,8 +28,8 @@ public final class DriverManager { private static final String GRID_URL = "@hub.lambdatest.com/wd/hub"; private static final String HUB_URL = "http://localhost:4444/wd/hub"; private static final Logger LOG = LogManager.getLogger ("DriverManager.class"); - private static final String LT_ACCESS_TOKEN = System.getProperty ("LT_ACCESS_KEY"); - private static final String LT_USERNAME = System.getProperty ("LT_USERNAME"); + private static final String LT_ACCESS_KEY = System.getProperty("LT_ACCESS_KEY"); + private static final String LT_USERNAME = System.getProperty("LT_USERNAME"); private static final String NO_SANDBOX = "--no-sandbox"; private static final String DISABLE_DEV_SHM = "--disable-dev-shm-usage"; private static final String CUSTOM_WINDOW_SIZE = "--window-size=1050,600"; @@ -64,8 +64,6 @@ public static void quitDriver () { private static HashMap ltOptions () { final var ltOptions = new HashMap (); - ltOptions.put ("username", LT_USERNAME); - ltOptions.put ("accessKey", LT_ACCESS_TOKEN); ltOptions.put ("resolution", "2560x1440"); ltOptions.put ("selenium_version", "4.0.0"); ltOptions.put ("build", "LambdaTest Playground Build"); @@ -122,13 +120,14 @@ private static void setupChromeDriver () { private static void setupChromeInLambdaTest () { final var browserOptions = new ChromeOptions (); browserOptions.setPlatformName ("Windows 10"); + browserOptions.setBrowserVersion("latest"); browserOptions.setCapability ("LT:Options", ltOptions ()); try { setDriver ( - new RemoteWebDriver (new URL (format ("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_TOKEN, GRID_URL)), + new RemoteWebDriver (new URL (format ("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)), browserOptions)); } catch (final MalformedURLException e) { - LOG.error ("Error setting up cloud browser in LambdaTest", e); + LOG.error ("Error setting up Chrome browser in LambdaTest", e); } } @@ -156,13 +155,14 @@ private static void setupFirefoxDriver () { private static void setupFirefoxInLambdaTest () { final var browserOptions = new FirefoxOptions (); browserOptions.setPlatformName ("Windows 10"); + browserOptions.setBrowserVersion("latest"); browserOptions.setCapability ("LT:Options", ltOptions ()); try { setDriver ( - new RemoteWebDriver (new URL (format ("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_TOKEN, GRID_URL)), + new RemoteWebDriver (new URL (format ("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)), browserOptions)); } catch (final MalformedURLException e) { - LOG.error ("Error setting up firefox browser in LambdaTest", e); + LOG.error ("Error setting up firefox browser in LambdaTest", e); } } diff --git a/src/test/java/io/github/mfaisalkhatri/tests/retrytests/RetryFailedTests.java b/src/test/java/io/github/mfaisalkhatri/tests/retrytests/RetryFailedTests.java index 72003f5..f974a10 100644 --- a/src/test/java/io/github/mfaisalkhatri/tests/retrytests/RetryFailedTests.java +++ b/src/test/java/io/github/mfaisalkhatri/tests/retrytests/RetryFailedTests.java @@ -29,7 +29,7 @@ public void setupTests () { @Test (retryAnalyzer = Retry.class) public void testNavigationToLoginPage () { final LoginPage loginPage = this.homePage.navigateToLoginPage (); - assertEquals (loginPage.loginBoxTitle (), "Returning Customers"); + assertEquals (loginPage.loginBoxTitle (), "Returning Customer"); } @Test