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 PageObjectExample { | |
| private WebDriver driver; | |
| @FindBy(id = "email") | |
| private WebElement email; | |
| @FindBy(id = "password") | |
| private WebElement password; |
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 PageObjectExample { | |
| @FindBy(id = "email") | |
| private WebElement email; | |
| @FindBy(id = "password") | |
| private WebElement password; | |
| @FindBy(name = "next") | |
| private WebElement next; |
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 PageObjectExample { | |
| private final WebDriver driver; | |
| public PageObjectExample(WebDriver driver) { | |
| this.driver = driver; | |
| } | |
| public void login(String email, String password) { | |
| driver.findElement(By.id("email")).sendKeys(email); |
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 PageObjectExample { | |
| private WebDriver driver; | |
| @FindBy(id = "email") | |
| private WebElement email; | |
| @FindBy(id = "password") | |
| private WebElement password; |
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
| class BookRoomWebTest extends BaseWeb { | |
| @Test | |
| void bookARoom() { | |
| driver.navigate().to(configuration.url() + | |
| "how-to-create-lean-test-automation-architecture-for-web-using-java-libraries"); | |
| assertThat(driver.findElement(By.cssSelector(".hestia-title.title-in-content")).getText()). | |
| isEqualTo("How to create Lean Test Automation Architecture for Web using Java libraries"); | |
| } |
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 BaseWeb { | |
| protected WebDriver driver; | |
| protected Configuration configuration; | |
| @BeforeEach | |
| public void preCondition() { | |
| configuration = configuration(); | |
| driver = new DriverFactory().createInstance(configuration().browser()); |
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
| private RemoteWebDriver createRemoteInstance(MutableCapabilities capability) { | |
| RemoteWebDriver remoteWebDriver = null; | |
| try { | |
| String gridURL = String.format("http://%s:%s", configuration().gridUrl(), configuration().gridPort()); | |
| remoteWebDriver = new RemoteWebDriver(new URL(gridURL), capability); | |
| } catch (java.net.MalformedURLException e) { | |
| logger.log(Level.SEVERE, "Grid URL is invalid or Grid is not available"); | |
| logger.log(Level.SEVERE, String.format("Browser: %s", capability.getBrowserName()), e); | |
| } catch (IllegalArgumentException e) { |
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 DriverFactory { | |
| public WebDriver createInstance(String browser) { | |
| Target target = Target.valueOf(configuration().target().toUpperCase()); | |
| WebDriver webdriver; | |
| switch (target) { | |
| case LOCAL: | |
| webdriver = BrowserFactory.valueOf(browser.toUpperCase()).createDriver(); | |
| break; |
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 enum BrowserFactory { | |
| CHROME { | |
| @Override | |
| public WebDriver createDriver() { | |
| WebDriverManager.getInstance(DriverManagerType.CHROME).setup(); | |
| return new ChromeDriver(getOptions()); | |
| } |
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
| # target execution: local or remote | |
| target = local | |
| # browser to use | |
| browser = chrome | |
| # run test into headless mode | |
| headless = true | |
| # initial URL |