Created
March 2, 2023 15:10
-
-
Save aevans-mms/0da43157ab772ecde5d0c102553547d2 to your computer and use it in GitHub Desktop.
This file contains 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
<!-- add to your pom.xml --> | |
<dependency> | |
<groupId>org.seleniumhq.selenium</groupId> | |
<artifactId>selenium-java</artifactId> | |
<version>4.4.0</version> | |
</dependency> |
This file contains 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
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