/**
* Method to verify text of given element
*
* @param expectedText
* @param element
* @param fieldName
*/
public boolean verifyElementText(String expectedText, WebElement element, String fieldName) {
boolean boolFlag = false;
try {
String actualText = element.getText().trim();
if (actualText.contentEquals(expectedText.trim())) {
boolFlag = true;
logStepResult(LogResult.PASS, "'" + actualText + "' value of '" + fieldName + "' field is matched with expected '" + expectedText + "'");
} else
logStepResult(LogResult.FAIL, "'" + actualText + "' value of '" + fieldName + "' field is not matched with expected '" + expectedText + "'");
} catch (Exception e) {
logStepResult(LogResult.FAIL, "Exception in verifyElementText()", e);
}
return boolFlag;
}

Verify Element Text

Method to verify text of given element

/**
* Method to verify attribute value of given element
*
* @param element
* @param attribute
* @param expectedValue
* @param fieldName
* @return
*/
public boolean verifyElementAttributeValue(WebElement element, String attribute, String expectedValue, String fieldName) {
boolean boolFlag = false;
try {
String actualValue = element.getAttribute(attribute).trim();
if (actualValue.contentEquals(expectedValue.trim())) {
boolFlag = true;
logStepResult(LogResult.PASS, "'" + actualValue + "' value of '" + fieldName + "' field is matched with expected '" + expectedValue + "'");
} else
logStepResult(LogResult.FAIL, "'" + actualValue + "' value of '" + fieldName + "' field is not matched with expected '" + expectedValue + "'");
} catch (Exception e) {
logStepResult(LogResult.FAIL, "Exception in verifyElementAttributeValue()", e);
}
return boolFlag;
}

Verify Attribute Value

Method to verify attribute value of given element