PageObjectModel/src/tests/webdriver/GettingStartedTests.java

36 lines
1.1 KiB
Java

package tests.webdriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import pages.webdriver.GettingStartedPage;
public class GettingStartedTests
{
public static void main(String[] args)
{
// 1. Define the path to the WebDriver for the web browser:
System.setProperty("webdriver.gecko.driver", "/snap/bin/geckodriver");
// 2. Start a session in a maximized web browser:
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
// 3. Navigate to a URL:
driver.navigate().to("https://ramoncaballero.dev/sdet/selenium-webdriver/playgrounds/");
// 4. Interact with WebElements.
// When testing on a web page we want to make sure that something in it matches an expected value.
// For example, this tests that the title of the web page is what we expect:
GettingStartedPage page = new GettingStartedPage(driver);
String actual = page.getTitle();
String expected = "ramoncaballero.dev - Selenium Playground";
assert actual.equals(expected);
System.out.print("All tests passed!");
// 5. End the session:
driver.quit();
}
}