Skip to content

Instantly share code, notes, and snippets.

@aevans-mms
Created March 2, 2023 15:10
Show Gist options
  • Save aevans-mms/0da43157ab772ecde5d0c102553547d2 to your computer and use it in GitHub Desktop.
Save aevans-mms/0da43157ab772ecde5d0c102553547d2 to your computer and use it in GitHub Desktop.
<!-- add to your pom.xml -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.4.0</version>
</dependency>
package org.mms;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
import static org.assertj.core.api.Assertions.assertThat;
public class SimpleGridTest
{
RemoteWebDriver driver;
String SELENIUM_VANILLA = "https://selenium-vanilla.nejmgroup-dev.org"; // Chrome, Linux
String SELENIUM_PINEAPPLE = "https://selenium-pineapple.nejmgroup-dev.org"; // Edge, Linux
String SELENIUM_MINT = "https://selenium-mint.nejmgroup-dev.org"; // Firefox, Linux
@Before
public void setup()
{}
@After
public void teardown()
{
if (driver != null)
{
driver.quit();
}
}
@Test
public void usingChrome() throws MalformedURLException
{
URL url = new URL(SELENIUM_VANILLA);
Capabilities capabilities = new ChromeOptions();
System.out.println(capabilities);
driver = new RemoteWebDriver(url, capabilities);
System.out.println(driver);
System.out.println(driver.getCapabilities());
test();
}
@Test
public void usingEdge() throws MalformedURLException
{
URL url = new URL(SELENIUM_PINEAPPLE);
EdgeOptions options = new EdgeOptions();
// options.setCapability("browserVersion", "latest");
// options.setCapability("platformName", "Linux");
driver = new RemoteWebDriver(url, options);
test();
}
@Test
public void usingFirefox() throws MalformedURLException
{
URL url = new URL(SELENIUM_MINT);
FirefoxOptions options = new FirefoxOptions();
options.setCapability("browserVersion", "latest");
options.setCapability("platformName", "Linux");
driver = new RemoteWebDriver(url, options);
test();
}
public void test()
{
driver.get("https://www.nejm-qa.org");
String title = driver.getTitle();
System.out.println(title);
assertThat(title).isNotEmpty();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment