Skip to content

Positive Assertions


assertTextPresentInPage

Description: This function will assert if the expected text is present on the page.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
Mobile 🟢 assertTextPresentInPage @value ⬅ Hardcoded Input
Mobile 🟢 assertTextPresentInPage Sheet:Column ⬅ Input from Datasheet
Mobile 🟢 assertTextPresentInPage %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.MOBILE, desc = "Assert if text: [<Data>] is present on the page", input = InputType.YES)
public void assertTextPresentInPage() throws RuntimeException {

    try {
        String strObj = Data;
        if (mDriver.findElement(By.tagName("html")).getText().contains(strObj)) {
            System.out.println("assertTextPresent passed");
            Report.updateTestLog("assertTextPresentInPage",
                    "Expected text '" + strObj + "' is  present in the page", Status.PASS);

        } else {
            System.out.println("assertTextPresentInPage failed");
            throw new Exception("Expected text  '" + strObj + "' is not present in the page");
        }

    } catch (Exception e) {
        Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
        throw new ForcedException("assertTextPresentInPage", e.getMessage());
    }
}

assertCookiePresent

Description: This function will assert if the cookie is present.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
Mobile 🟢 assertCookiePresent @value ⬅ Hardcoded Input
Mobile 🟢 assertCookiePresent Sheet:Column ⬅ Input from Datasheet
Mobile 🟢 assertCookiePresent %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.MOBILE, desc = "Assert if cookie name: [<Data>] is present", input = InputType.YES)
public void assertCookiePresent() {
    try {
        String strCookieName = Data;
        if ((mDriver.manage().getCookieNamed(strCookieName) != null)) {
            System.out.println("assertCookiePresent Passed");
            Report.updateTestLog("assertCookiePresent", "Cookie name matched with the data provided", Status.PASS);
        } else {
            throw new Exception("Cookie name did not match with data provided");
        }
    } catch (Exception ex) {
        System.out.println("assertCookiePresent Failed");
        Logger.getLogger(Assertions.class.getName()).log(Level.SEVERE, null, ex);
        throw new ForcedException("assertCookiePresent", ex.getMessage());
    }
}

assertCookieByName

Description: This function will assert if the cookie has the expected name.

Input Format : @Expected text

ObjectName Action Input Condition Reference
Mobile 🟢 assertCookieByName @value ⬅ Hardcoded Input
Mobile 🟢 assertCookieByName Sheet:Column ⬅ Input from Datasheet
Mobile 🟢 assertCookieByName %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.MOBILE, desc = "Assert if cookie: [<Object>] has name: [<Data>]", input = InputType.YES)
public void assertCookieByName() {
    try {

        String strCookieName = Data.split(":", 2)[0];
        String strCookieValue = Data.split(":", 2)[1];
        if (mDriver.manage().getCookieNamed(strCookieName) != null) {
            if ((mDriver.manage().getCookieNamed(strCookieName).getValue().equals(strCookieValue))) {
                System.out.println("assertCookieByName Passed");
                Report.updateTestLog("assertCookieByName", "Cookie name matched with provided data", Status.PASS);

            } else {
                throw new Exception("Cookie value did not match with provided data");
            }
        } else {
            throw new Exception("Cookie  with the name '" + strCookieName + "' did not exist");
        }
    } catch (Exception ex) {
        System.out.println("assertCookieByName Failed");
        Logger.getLogger(Assertions.class.getName()).log(Level.SEVERE, null, ex);
        throw new ForcedException("assertCookieByName", ex.getMessage());
    }
}

assertElementPresent

Description: This function will assert if the Element is present.

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementPresent
@Action(object = ObjectType.APP, desc = "Assert if [<Object>] is present")
public void assertElementPresent() {
    assertElement(elementPresent());

assertElementSelected

Description: This function will assert if the Element is selected.

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementSelected
@Action(object = ObjectType.APP, desc = "Assert if [<Object>] element is selected")
public void assertElementSelected() {
    assertElement(elementSelected());
}

assertElementDisplayed

Description: This function will assert if the Element is displayed.

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementDisplayed
@Action(object = ObjectType.APP, desc = "Assert if [<Object>] element is displayed")
public void assertElementDisplayed() {
    assertElement(elementDisplayed());
}

assertElementEnabled

Description: This function will assert if the Element is enabled.

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementEnabled
@Action(object = ObjectType.APP, desc = "Assert if [<Object>] is enabled on the current page")

public void assertElementEnabled() {
    assertElement(elementEnabled());
}

assertElementAttrEquals

Description: This function will assert if element attribute equals given data in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementAttrEquals @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementAttrEquals DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementAttrEquals %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc ="Assert if [<Object>]'s Attribute Equals [<Data>]", input =InputType.YES)
public void assertElementAttrEquals() {
    assertElementAttr(SpecText.Type.IS);
}

assertElementAttrContains

Description: This function will assert if element attribute contains given data in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementAttrContains @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementAttrContains DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementAttrContains %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc ="Assert if [<Object>]'s Attribute Contains [<Data>]", input =InputType.YES)
public void assertElementAttrContains() {
    assertElementAttr(SpecText.Type.CONTAINS);
}

assertElementAttrStartsWith

Description: This function will assert if element attribute starts with given data in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementAttrStartsWith @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementAttrStartsWith DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementAttrStartsWith %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc ="Assert if [<Object>]'s Attribute StartsWith [<Data>]", input =InputType.YES)
public void assertElementAttrStartsWith() {
    assertElementAttr(SpecText.Type.STARTS);
}

assertElementAttrEndsWith

Description: This function will assert if element attribute ends with given data in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementAttrEndsWith @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementAttrEndsWith DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementAttrEndsWith %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc ="Assert if [<Object>]'s Attribute EndsWith [<Data>]", input =InputType.YES)
public void assertElementAttrEndsWith() {
    assertElementAttr(SpecText.Type.ENDS);
}

assertElementAttrMatches

Description: This function will assert if element attribute matches given data in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementAttrMatches @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementAttrMatches DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementAttrMatches %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc ="Assert if [<Object>]'s Attribute Matches [<Data>]", input =InputType.YES)
public void assertElementAttrMatches() {
    assertElementAttr(SpecText.Type.MATCHES);
}

assertElementContains

Description: This function will assert if element contains

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementContains PageName
@Action(object = ObjectType.APP, desc ="Assert if [<Object>] contains <Object2> ", condition = InputType.YES)
public void assertElementContains() {
    assertElementContains(false);
}

assertElementContainsPartly

Description: This function will assert if element partly contains

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementContainsPartly PageName
@Action(object = ObjectType.APP,desc ="Assert if [<Object>] partly contains  <Object2> ", input =InputType.NO, 
        condition = InputType.YES)
    public void assertElementContainsPartly() {
        assertElementContains(true);
}

assertElementTextEquals

Description: This function will assert if element text equals given text in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementTextEquals @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementTextEquals DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementTextEquals %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP,desc = "Assert if [<Object>]'s Text Equals [<Data>]",input = InputType.YES)
public void assertElementTextEquals() {
    assertElementText(Type.IS);
}

assertElementTextContains

Description: This function will assert if element text contains given text in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementTextContains @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementTextContains DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementTextContains %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc = "Assert if [<Object>]'s Text Contains [<Data>]", input = InputType.YES)
public void assertElementTextContains() {
    assertElementText(Type.CONTAINS);
}

assertElementTextStartsWith

Description: This function will assert if element text starts with given text in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementTextStartsWith @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementTextStartsWith DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementTextStartsWith %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc = "Assert if [<Object>]'s Text StartsWith [<Data>]", input = InputType.YES)
public void assertElementTextStartsWith() {
    assertElementText(Type.STARTS);
}

assertElementTextEndsWith

Description: This function will assert if element text ends with given text in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementTextEndsWith @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementTextEndsWith DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementTextEndsWith %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc = "Assert if [<Object>]'s Text EndsWith [<Data>]", input = InputType.YES)
public void assertElementTextEndsWith() {
    assertElementText(Type.ENDS);
}

assertElementTextMatchesWith

Description: This function will assert if element text matches with given text in input column

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementTextMatchesWith @Data PageName << Hardcoded Input
mobileObject 🟢 assertElementTextMatchesWith DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 assertElementTextMatchesWith %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc = "Assert if [<Object>]'s Text Matches [<Data>]", input = InputType.YES)
public void assertElementTextMatchesWith() {
    assertElementText(Type.MATCHES);
}

assertElementTextByLabel

Description: This function is used to assert if the element text adjacent to provided label element equals the expected data.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementTextByLabel @value ⬅ Hardcoded Input
mobileObject 🟢 assertElementTextByLabel Sheet:Column ⬅ Input from Datasheet
mobileObject 🟢 assertElementTextByLabel %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Assert if [<Object>]'s Text adjacent to provided label element Equals [<Data>]", input = InputType.YES)
public void assertElementTextByLabel() {
    cc.Element = findInputElementByLabelTextByXpath();
    new Text(cc).assertElementTextEquals();
}

assertElementTextContainsByLabel

Description: This function is used to assert if the element text adjacent to provided label element contains the expected data.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
mobileObject 🟢 assertElementTextContainsByLabel @value ⬅ Hardcoded Input
mobileObject 🟢 assertElementTextContainsByLabel Sheet:Column ⬅ Input from Datasheet
mobileObject 🟢 assertElementTextContainsByLabel %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Assert if [<Object>]'s Text adjacent to provided label element Contains [<Data>]", input = InputType.YES)
public void assertElementTextContainsByLabel() {
    cc.Element = findInputElementByLabelTextByXpath();
    new Text(cc).assertElementTextContains();
}