All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.shaft.dsl.gui.Element Maven / Gradle / Ivy

Go to download

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!

There is a newer version: 8.2.20240402
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy