Skip to content

Commit

Permalink
minor changes made (#136)
Browse files Browse the repository at this point in the history
* minor changes related to retry listener and tests made

* updated drivermanager class back to use getProperty method for lambdatest credentials
  • Loading branch information
mfaisalkhatri authored Mar 25, 2024
1 parent 230961d commit d5dc0b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions src/main/java/io/github/mfaisalkhatri/drivers/DriverManager.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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";
Expand Down Expand Up @@ -64,8 +64,6 @@ public static void quitDriver () {

private static HashMap<String, Object> ltOptions () {
final var ltOptions = new HashMap<String, Object> ();
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");
Expand Down Expand Up @@ -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);
}

}
Expand Down Expand Up @@ -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);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d5dc0b0

Please sign in to comment.