com.shaft.dsl.gui.Element Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SHAFT_ENGINE Show documentation
Show all versions of SHAFT_ENGINE Show documentation
SHAFT is a unified test automation engine. Powered by best-in-class frameworks, SHAFT provides a
wizard-like syntax to drive your automation efficiently, maximize your ROI, and minimize your learning curve.
Stop reinventing the wheel. Upgrade now!
package com.shaft.dsl.gui;
import com.shaft.gui.element.ElementActions;
import com.shaft.gui.element.internal.FluentElementActions;
import com.shaft.validation.Validations;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
@SuppressWarnings("unused")
public abstract class Element {
static WebDriver driver;
final By locator;
final FluentElementActions elementActions;
protected Element(By locator) {
this.locator = locator;
elementActions = FluentElementActions.getInstance();
}
public static WebDriver getDriver() {
return Element.driver;
}
public static void setDriver(WebDriver driver) {
Element.driver = driver;
}
public boolean isDisplayed() {
return new ElementActions(driver).isElementDisplayed(locator);
}
public void shouldBeDisplayed() {
Validations.assertThat().object(isDisplayed()).isTrue().perform();
}
public void shouldExist() {
Validations.assertThat().element(locator).exists().perform();
}
public void shouldExist(String reportMsg) {
Validations.assertThat().element(locator).exists()
.withCustomReportMessage(reportMsg).perform();
}
public void shouldNotExist() {
Validations.assertThat().element(locator).exists().perform();
}
public void shouldNotExist(String reportMsg) {
Validations.assertThat().element(locator).exists()
.withCustomReportMessage(reportMsg).perform();
}
}