Class WebDriverElementValidationsBuilder

java.lang.Object
com.shaft.validation.internal.WebDriverElementValidationsBuilder
All Implemented Interfaces:
ElementAssertions

public class WebDriverElementValidationsBuilder extends Object implements ElementAssertions
  • Constructor Details

    • WebDriverElementValidationsBuilder

      public WebDriverElementValidationsBuilder(ValidationEnums.ValidationCategory validationCategory, org.openqa.selenium.WebDriver driver, org.openqa.selenium.By locator, StringBuilder reportMessageBuilder)
  • Method Details

    • exists

      public ValidationsExecutor exists()
      Use this to check that the target element exists
      Specified by:
      exists in interface ElementAssertions
      Returns:
      a ValidationsExecutor object retained for source compatibility
    • doesNotExist

      public ValidationsExecutor doesNotExist()
      Use this to check that the target element does not exist
      Specified by:
      doesNotExist in interface ElementAssertions
      Returns:
      a ValidationsExecutor object retained for source compatibility
    • matchesReferenceImage

      public ValidationsExecutor matchesReferenceImage()
      Use this to check that the target element matches a reference image (using the Artificial Intelligence library SHUTTERBUG). On the first test run this method will take a screenshot of the target element and the test will pass, and on following runs the element will be compared against that reference image. The reference images are stored under src/test/resources/DynamicObjectRepository for later maintenance
      Specified by:
      matchesReferenceImage in interface ElementAssertions
      Returns:
      a ValidationsExecutor object retained for source compatibility
    • matchesReferenceImage

      public ValidationsExecutor matchesReferenceImage(ValidationEnums.VisualValidationEngine visualValidationEngine)
      Use this to check that the target element matches a reference image.
      Specified by:
      matchesReferenceImage in interface ElementAssertions
      Parameters:
      visualValidationEngine - the selected visualValidationEngine that will be used to perform the image comparison
      Returns:
      a ValidationsExecutor object retained for source compatibility
    • doesNotMatchReferenceImage

      public ValidationsExecutor doesNotMatchReferenceImage()
      Use this to check that the target element does not match a reference image (using the Artificial Intelligence library OpenCV). On the first test run this method will take a screenshot of the target element and the test will pass, and on following runs the element will be compared against that reference image. The reference images are stored under src/test/resources/DynamicObjectRepository for later maintenance
      Specified by:
      doesNotMatchReferenceImage in interface ElementAssertions
      Returns:
      a ValidationsExecutor object retained for source compatibility
    • doesNotMatchReferenceImage

      public ValidationsExecutor doesNotMatchReferenceImage(ValidationEnums.VisualValidationEngine visualValidationEngine)
      Use this to check that the target element does not match a reference image.
      Specified by:
      doesNotMatchReferenceImage in interface ElementAssertions
      Parameters:
      visualValidationEngine - the selected visualValidationEngine that will be used to perform the image comparison
      Returns:
      a ValidationsExecutor object retained for source compatibility
    • matchesScreenshot

      public ValidationsExecutor matchesScreenshot()
      Use this to check that the target element matches its visual-regression baseline screenshot (pixel diff via OpenCV). On the first test run this method takes a screenshot of the target element and the test passes, saving it as the baseline for subsequent runs. Baselines are stored alongside the other visual baselines under the configured dynamicObjectRepositoryPath. The comparison runs when this terminal assertion is called.
      Specified by:
      matchesScreenshot in interface ElementAssertions
      Returns:
      a ValidationsExecutor object to optionally set a custom validation message
    • matchesScreenshot

      public ValidationsExecutor matchesScreenshot(VisualComparisonOptions options)
      Same as matchesScreenshot(), but with diff-budget/mask options (see VisualComparisonOptions). The comparison executes immediately.
      Specified by:
      matchesScreenshot in interface ElementAssertions
      Parameters:
      options - the visual comparison options (diff budgets, masks), or null for defaults
      Returns:
      a ValidationsExecutor object to optionally set a custom validation message
    • matchesAriaSnapshot

      public ValidationsExecutor matchesAriaSnapshot(String snapshotFileName)
      Use this to check that the target element matches its accessible-name-tree ("aria") baseline snapshot, using partial-subset semantics (see AriaSnapshotHelper). On the first test run this method saves the current snapshot as the baseline and the test passes, under the configured ariaSnapshotFolderPath.
      Specified by:
      matchesAriaSnapshot in interface ElementAssertions
      Parameters:
      snapshotFileName - the baseline file name (without extension) to compare against or create
      Returns:
      a ValidationsExecutor object retained for source compatibility
    • attribute

      public NativeValidationsBuilder attribute(String attribute)
      Use this to check against a certain element attribute
      Specified by:
      attribute in interface ElementAssertions
      Parameters:
      attribute - the target element attribute that will be checked against
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • domAttribute

      public NativeValidationsBuilder domAttribute(String domAttribute)
      Specified by:
      domAttribute in interface ElementAssertions
    • domProperty

      public NativeValidationsBuilder domProperty(String domProperty)
      Specified by:
      domProperty in interface ElementAssertions
    • property

      public NativeValidationsBuilder property(String domProperty)
      Use this to check against a certain element attribute
      Specified by:
      property in interface ElementAssertions
      Parameters:
      domProperty - the target element DOM property that will be checked against
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • isSelected

      public ValidationsExecutor isSelected()
      Use this to check against the provided elements selected attribute
      Specified by:
      isSelected in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • isChecked

      public ValidationsExecutor isChecked()
      Use this to check against the provided elements checked attribute
      Specified by:
      isChecked in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • isVisible

      public ValidationsExecutor isVisible()
      Use this to check against the provided elements hidden attribute
      Specified by:
      isVisible in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • isEnabled

      public ValidationsExecutor isEnabled()
      Use this to check against the provided elements disabled attribute
      Specified by:
      isEnabled in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • isNotSelected

      public ValidationsExecutor isNotSelected()
      Use this to check against the provided elements selected attribute
      Specified by:
      isNotSelected in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • isNotChecked

      public ValidationsExecutor isNotChecked()
      Use this to check against the provided elements checked attribute
      Specified by:
      isNotChecked in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • isHidden

      public ValidationsExecutor isHidden()
      Use this to check against the provided elements hidden attribute
      Specified by:
      isHidden in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • isDisabled

      public ValidationsExecutor isDisabled()
      Use this to check against the provided elements disabled attribute
      Specified by:
      isDisabled in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • text

      public NativeValidationsBuilder text()
      Use this to check against the provided elements text attribute
      Specified by:
      text in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • textTrimmed

      public NativeValidationsBuilder textTrimmed()
      Use this to check against the provided elements text attribute after it's trimmed (all leading and trailing space removed)
      Specified by:
      textTrimmed in interface ElementAssertions
      Returns:
      a NativeValidationsBuilder object to continue building your validation
    • cssProperty

      public NativeValidationsBuilder cssProperty(String elementCssProperty)
      Use this to check against a certain element attribute
      Specified by:
      cssProperty in interface ElementAssertions
      Parameters:
      elementCssProperty - the target element css property that will be checked against
      Returns:
      a NativeValidationsBuilder object to continue building your validation