Class VerificationSteps

java.lang.Object
com.dougnoel.sentinel.steps.VerificationSteps

public class VerificationSteps extends Object
Methods used to defined basic validations
  • Constructor Details

    • VerificationSteps

      public VerificationSteps()
  • Method Details

    • verifyNumDiffFixedDecimals

      @Then("^I verify the value of the (.*?) is (.*?) (greater|less) than the old value of the (.*?)( (rounded|truncated) to )?(([0-9]+) decimal places?)?$") public static void verifyNumDiffFixedDecimals(String elementName, double difference, String operator, String storedValueKey, String isRounded, String decimalCount)

      Used to compare the numerical text, or input element value, of an element to a stored value to verify how much it has changed given a set number of decimal places truncated or rounded up/down Can verify whether a value is greater than or less than the stored by a given amount.

      Only numerical values will correctly work with this verification step. Supports decimals, rounding up/down (half up), and truncation padded to a given decimal length.

      Examples:

      • Compare 0.0010 is equivalent to later displayed -0.0011 due to another operation
      • Compare 0.0010 is equivalent to later displayed 0.0011 due to another operation
      • Compare 5.1-2 is equivalent to displayed 3.1
      • Compare 5-2 is equivalent to displayed 3
      • Compare 5-2 is equivalent to displayed 3.00

      Gherkin Examples:

      • I verify the value of the raw text div is .3005 greater than the old value of the raw text div
      • I verify the value of the raw text div is .1 less than the old value of the raw text div
      • I verify the value of the rounded text div is 3 greater than the old value of the raw text div rounded to 0 decimal places
      • I verify the value of the rounded text div is .1 less than the old value of the raw text div rounded to 1 decimal place
      • I verify the value of the truncated text div is 3 greater than old the value of the raw text div truncated to 0 decimal places
      • I verify the value of the truncated text div is .1 less than the old value of the raw text div truncated to 1 decimal place

      Scenario Outline Example: I verify the value of the <String> is <Number> <String (greater|less)> than the old value of the <String> <<String (rounded|truncated)> to <Integer> decimal places>

      Parameters:
      elementName - String the name of the element whose value/text we are fetching
      difference - Double how much more/less the new value is from the stored value
      operator - String whether we're checking if the new value is more or less than the stored value
      storedValueKey - String the key of the stored value
      isRounded - String to determine if we're rounding (half-up), or truncating
      decimalCount - String how many decimal places we wish to pad/truncate/round to (0 if null with rounding/truncation specified)
    • verifyElementExists

      @Then("^I verify (?:the|a|an) (.*?)( does not)?(?: does)? exists?$") public static void verifyElementExists(String elementName, String assertion)
      Verifies the given element exists. The given element string is made lower case and whitespaces are replaced with underscores, then it is sent the isDisplayed event and returns true or false. It also has an assertion variable which is set if the words "does not" are used, and it looks for a negative assertion. The word "does" can be used optionally, and was added to support the use of a Scenario Outline which switches between "does" and "does not" in its tests.

      Gherkin Examples:

      • I verify a submit button exists
      • I verify the Plan Dropdown does not exist
      • I verify an area map does exist
      Scenario Outline Example:

      I verify the <element> <Assertion> exists

      Examples:
      | element | Assertion |
      | first dropdown | does |
      | second dropdown | does not |

      Parameters:
      elementName - String Element to check
      assertion - String "does" or does not" for true or false
    • verifyElementIsSelected

      @Then("^I verify(?: the)? (.*) is (not |un)?(?:checked|selected)$") public static void verifyElementIsSelected(String elementName, String assertion)
      Verifies the whether the given element is selected or not. Intended to be used with check boxes and radio buttons. Using the optional word not will check to make sure the item is not checked/selected.

      Gherkin Examples:

      • I verify the Yes check box is checked
      • I verify the Female Radio Button is selected
      • I verify the I would like fries with that Check box is not selected
      Parameters:
      elementName - String Element to check
      assertion - String "" or " not" for true or false
    • verifyElementHasAttribute

      @Then("^I verify (?:the|a|an) (.*?) (has|does not have) the attribute (.*?)$") public static void verifyElementHasAttribute(String elementName, String assertion, String attribute)
      Verifies an element has an attribute.

      Gherkin Examples:

      • I verify the table has the attribute table-striped
      • I verify the textbox does not have the attribute listStyleClass
      • I verify the div has the attribute container
      Parameters:
      elementName - String element to inspect
      assertion - String "has" for a positive check, anything else for negative
      attribute - String class attribute to verify
    • verifyElementHasClass

      @Then("^I verify (?:the|a|an) (.*?)( does not)? (has|have|contains?) the class (.*?)$") public static void verifyElementHasClass(String elementName, String assertion, String matchType, String className)
      Verifies an element has a class.

      Gherkin Examples:

      • I verify the table has the class heading"
      • I verify the textbox does not have the class style"
      • I verify the div contains the class aria
      • I verify the button does not contain the class disabled
      Parameters:
      elementName - String element to inspect
      assertion - String "has" for a positive check, anything else for negative
      matchType - String whether we are doing an exact match or a partial match
      className - String class to verify
    • verifyElementAttributeHasStoredValue

      @Then("^I verify the (.*?) attribute of the (.*?)( does not)? match(?:es)? the (.*?)$") public static void verifyElementAttributeHasStoredValue(String attribute, String elementName, String assertion, String key)
      Verifies an attribute for an element has a given previously stored value.

      Gherkin Examples:

      • I verify the boxes table with the attribute color has the same value used for the blue box
      • I verify the New Div with the attribute style does not have the same value used for the font style
      • I verify the Title Text with the attribute class contains the same value stored as the title text entry
      • I verify the Submit Button with the attribute class does not contain the same value stored for the disabled attribute
      Parameters:
      elementName - String element to inspect
      assertion - String "has" for a positive check, anything else for negative
      attribute - String attribute to inspect
      key - String key of the stored value to expect
    • verifyElementAttributeHasValue

      @Then("^I verify (?:the|a|an) (.*?) with (?:the|a|an) attribute (.*?)( does not)? (has|have|contains?) (?:the|a|an) value (.*?)$") public static void verifyElementAttributeHasValue(String elementName, String attribute, String assertion, String matchType, String value)
      Verifies an attribute for an element has a given value.

      Gherkin Examples:

      • I verify the boxes table with the attribute color has the value blue"
      • I verify the New Div with the attribute style does not have the value aria"
      • I verify the Title Text with the attribute class contains the value large-12
      • I verify the Submit Button with the attribute class does not contain the value disabled
      Parameters:
      elementName - String element to inspect
      assertion - String "has" for a positive check, anything else for negative
      matchType - String whether we are doing an exact match or a partial match
      attribute - String attribute to inspect
      value - String value expected
    • verifyElementIsEnabled

      @Then("^I verify (?:the|a|an) (.*?) is (enabled|disabled)$") public static void verifyElementIsEnabled(String elementName, String assertion)
      Verifies an element is enabled by asserting the element found for the given element name is enabled

      Gherkin Examples:

      • I verify the submit button is not enabled
      • I verify the home link is enabled
      • I verify the link to open a pdf is enabled
      Parameters:
      elementName - String the name of the element
      assertion - String "enabled" for a positive check, anything else for negative
    • verifyElementVisibility

      @Then("^I verify (?:the|a|an) (.*?) is (visible|hidden)$") public static void verifyElementVisibility(String elementName, String assertion)
      Verifies an element is enabled by asserting the element for the given element name is hidden

      Gherkin Examples:

      • I verify the iframe is hidden
      • I verify the document link is not hidden
      • I verify the data for the user's current plan is not hidden
      Parameters:
      elementName - String the name of the element
      assertion - String "visible" for a positive check, anything else for negative
    • verifyJsAlertPresent

      @Then("^I verify (?:the|a) JS alert is( not)? present$") public static void verifyJsAlertPresent(String assertion)
      Verifies the existence of a Javascript alert.

      Gherkin Example:

      • I verify the JS alert is present
      • I verify a JS alert is not present
      Parameters:
      assertion - String any string for a negative check, nothing (null) for a positive check
    • verifyJsAlertText

      @Then("^I verify the JS alert (does not )?contains? the text (.*)?$") public static void verifyJsAlertText(String assertion, String expectedText)
      Verifies the existence of a Javascript alert.

      Gherkin Example:

      • I verify the JS alert contains the text Hello, World!
      • I verify the JS alert does not contain the text Goodbye, World!
      Parameters:
      assertion - String any string for a negative check, nothing (null) for a positive check
    • verifyElementDisplayOrderOnPage

      @Then("^I verify the (.*) is (to the right of|to the left of|below|above) the (.*)$") public static void verifyElementDisplayOrderOnPage(String element1, String relativeLocation, String element2)
    • verifyOneOfTwoElementsIsFound

      @Then("^I verify either (?:the|a|an) (.*?) or (?:the|a|an) (.*?) exist$") public static void verifyOneOfTwoElementsIsFound(String elementName, String otherElementName)
      Verifies one of two given elements is present on the page. Does not check for visibility of elements. Useful for when a certain action may produce two different results on a page and either is acceptable for test to continue.

      Gherkin Example:

      • I verify either the client table or the no rows found warning exist
      Parameters:
      elementName -
      otherElementName -