# VerifyExpressionWithOperator

> Verifies an expression by asserting it in relation to a given expression with an operator.

Verifies an expression by asserting it in relation to a given expression with an operator.

## Definition

**Namespace:** UiPath.Testing.API

**Assembly:** UiPath.Testing.Activities.Api (in UiPath.Testing.Activities.Api.dll)

## Overloads

| Overload | Description |
| --- | --- |
| `VerifyExpressionWithOperator(object, Comparison, object, string)` | Verifies an expression by asserting it in relation to a given expression with an operator. |
| `VerifyExpressionWithOperator(object, Comparison, object)``string, bool, string, bool, bool)` | Verifies an expression by asserting it in relation to a given expression with an operator. You can also perform other configurations additional to the verification, such as configuring an output message format, or taking a screenshot in case the assertion fails. |

## `VerifyExpressionWithOperator(object, Comparison, object, string)`

Verifies an expression by asserting it in relation to a given expression with an operator.

```
bool VerifyExpressionWithOperator(
    Object firstExpression,
    Comparison operatorValue,
    Object secondExpression
       string outputMessageFormat = null
)
```

`firstExpression` [Object](https://learn.microsoft.com/dotnet/api/system.object) : The first expression in the verification process.

`operatorValue` `Comparison` : Possible mathematical operators you want to use to verify the two expressions.

`secondExpression` [Object](https://learn.microsoft.com/dotnet/api/system.object) : The second expression in the verification process.

`outputMessageFormat` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string?view=net-8.0) : The format of the output message. The supported arguments are:

* `{Expression}`
* `{ExpressionText}`
* `{RightExpression}`
* `{RightExpressionText}`
* `{Result}`
* `{Operator}`

For more information, check the **Configuring the `outputMessageFormat`** section.

## `VerifyExpressionWithOperator(object, Comparison, object)string, bool, string, bool, bool)`

Verifies an expression by asserting it in relation to a given expression with an operator. You can also perform other configurations additional to the verification, such as configuring an output message format, or taking a screenshot in case the assertion fails.

```
bool VerifyExpressionWithOperator(
    Object firstExpression,
    Comparison operatorValue,
    Object secondExpression,
    string outputMessageFormat,
    bool continueOnFailure,
    string alternativeVerificationTitle,
    bool takeScreenshotInCaseOfFailingAssertion,
    bool takeScreenshotInCaseOfSucceedingAssertion
)
```

`firstExpression` [Object](https://learn.microsoft.com/dotnet/api/system.object) : The first expression in the verification process.

`operatorValue` `Comparison` : Possible mathematical operators you want to use to verify the two expressions. Access the operators through the `Comparison` object. The following options are available:

* `Contains`
* `Equality`
* `GreaterThan`
* `GreaterThanOrEqual`
* `Inequality`
* `LessThan`
* `LessThanOrEqual`
* `RegexMatch`

`secondExpression` [Object](https://learn.microsoft.com/dotnet/api/system.object) : The second expression in the verification process.

`outputMessageFormat` [String](https://learn.microsoft.com/dotnet/api/system.string) : Format of the output message. The supported arguments are:

* `{Expression}`
* `{ExpressionText}`
* `{RightExpression}`
* `{RightExpressionText}`
* `{Result}`
* `{Operator}`

For more information, check the **Configuring the `outputMessageFormat`** section.

`continueOnFailure` [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) : Specifies if the automation should continue even when the activity throws an error. The default value is False. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set to True, the execution of the project continues regardless of any error.

`alternativeVerificationTitle` [String](https://learn.microsoft.com/dotnet/api/system.string) : This title will be displayed in orchestrator.

`takeScreenshotInCaseOfFailingAssertion` [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) : If set to `True`, takes a screenshot of the target process if the verification has failed.

`takeScreenshotInCaseOfSucceedingAssertion` [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) : If set to `True`, takes a screenshot of the target process if the verification has been successful.

## Return value

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

It is “True” if the Verification passed/succeeded, and “False” if the Verification failed.

## Configuring the outputMessageFormat

The `outputMessageFormat` parameter can be configured with supported arguments, that act as placeholders for the values used in the verification operation. These placeholders are automatically populated with the variables or values defined when invoking the coded automation API at runtime.

For the VerifyExpressionWithOperator coded automation API, you can implement the following supported arguments when creating an output message:

* `{Expression}`: Represents the value of the first expression you provided for the `firstExpression` parameter.
* `{ExpressionText}`: Represents the text of the first expression you inserted for the `firstExpression` parameter.
* `{RightExpression}`: Represents the value of the second expression you provided for the `secondExpression` parameter.
* `{RightExpressionText}`: Represents the text of the second expression you inserted for the `secondExpression` parameter.
* `{Result}`: Represents the coded automation API's return value, which is the verification result.
* `{Operator`: Represents the operator used in the verification, set by the `operatorValue` parameter.

The following is an example on how to use the VerifyExpressionWithOperator coded automation API, which includes configuring the `outputMessageFormat` parameter:

```
// Initialize variables for the expressions to be verified
var expression1 = "User created successfully";
var expression2 = "successfully created user";

// Employ the VerifyExpressionWithOperator coded automation API, with the last string parameter being the outputMessageFormat
testing.VerifyExpressionWithOperator(expression1, Comparison.Contains, expression2, "{Expression} {Operator} the {RightExpression}, so the verification is {Result}.");
```

In the provided example, the placeholders within the curly brackets are replaced with the corresponding variable names and their values at runtime, providing a customized output message.
