Created
August 13, 2024 14:38
-
-
Save SarahElson/c3f8825eaa2da7197608b551b3159407 to your computer and use it in GitHub Desktop.
ExpectedConditions In Selenium: Types And Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseTest { | |
protected RemoteWebDriver driver; | |
@BeforeClass | |
public void setup() { | |
String USERNAME = System.getenv("LT_USERNAME") == null ? "LT_USERNAME" : System.getenv("LT_USERNAME"); | |
String ACCESS_KEY = System.getenv("LT_ACCESS_KEY") == null ? "LT_ACCESS_KEY" : System.getenv("LT_ACCESS_KEY"); | |
String GRID_URL = "@hub.lambdatest.com/wd/hub"; | |
try { | |
this.driver = new RemoteWebDriver(new URL("http://" + USERNAME + ":" + ACCESS_KEY + GRID_URL), getChromeOptions()); | |
} catch (final MalformedURLException e) { | |
System.out.println("Could not start the remote session on LambdaTest cloud grid"); | |
} | |
this.driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20)); | |
} | |
public ChromeOptions getChromeOptions() { | |
final var browserOptions = new ChromeOptions(); | |
browserOptions.setPlatformName("Windows 10"); | |
browserOptions.setBrowserVersion("126.0"); | |
final HashMap<String, Object> ltOptions = new HashMap<String, Object>(); | |
ltOptions.put("project", "Expected Conditions Blog"); | |
ltOptions.put("build", "LambdaTest"); | |
ltOptions.put("name", "Expected Conditions Demo"); | |
ltOptions.put("visual", true); | |
ltOptions.put("network", true); | |
ltOptions.put("console", true); | |
ltOptions.put("w3c", true); | |
ltOptions.put("plugin", "java-testNG"); | |
browserOptions.setCapability("LT:Options", ltOptions); | |
return browserOptions; | |
} | |
@AfterClass | |
public void tearDown() { | |
this.driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment