activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

工作流活动

上次更新日期 2025年9月30日

VerifyExpressionWithOperator

通过与带有运算符的给定表达式相关的断言来验证表达式。

定义

命名空间: UiPath.Testing.API

程序集: UiPath.Testing.Activities.Api(在 UiPath.Testing.Activities.Api.dll 中)

重载

重载描述
VerifyExpressionWithOperator(object, Comparison, object, string)通过与带有运算符的给定表达式相关的断言来验证表达式。
VerifyExpressionWithOperator(object, Comparison, object)string, bool, string, bool, bool)通过与带有运算符的给定表达式相关的断言来验证表达式。 除了验证之外,您还可以执行其他配置,例如配置输出消息格式,或者在断言失败时截取屏幕截图。

VerifyExpressionWithOperator(object, Comparison, object, string)

通过与带有运算符的给定表达式相关的断言来验证表达式。

bool VerifyExpressionWithOperator(
	Object firstExpression,
	Comparison operatorValue,
	Object secondExpression
       string outputMessageFormat = null
)bool VerifyExpressionWithOperator(
	Object firstExpression,
	Comparison operatorValue,
	Object secondExpression
       string outputMessageFormat = null
)
第一个表达式 对象
验证流程中的第一个表达式。
运算符值 比较
要用于验证两个表达式的可能数学运算符。
第二个表达式 对象
验证流程中的第二个表达式。
输出消息格式 字符串
输出消息的格式。 支持的参数包括:
  • {Expression}
  • {ExpressionText}
  • {RightExpression}
  • {RightExpressionText}
  • {Result}
  • {Operator}
有关更多信息,请查看“配置 outputMessageFormat”部分。

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

通过与带有运算符的给定表达式相关的断言来验证表达式。 除了验证之外,您还可以执行其他配置,例如配置输出消息格式,或者在断言失败时截取屏幕截图。

bool VerifyExpressionWithOperator(
	Object firstExpression,
	Comparison operatorValue,
	Object secondExpression,
	string outputMessageFormat,
	bool continueOnFailure,
	string alternativeVerificationTitle,
	bool takeScreenshotInCaseOfFailingAssertion,
	bool takeScreenshotInCaseOfSucceedingAssertion
)bool VerifyExpressionWithOperator(
	Object firstExpression,
	Comparison operatorValue,
	Object secondExpression,
	string outputMessageFormat,
	bool continueOnFailure,
	string alternativeVerificationTitle,
	bool takeScreenshotInCaseOfFailingAssertion,
	bool takeScreenshotInCaseOfSucceedingAssertion
)
第一个表达式 对象
验证流程中的第一个表达式。
运算符值 比较
验证这两个表达式时可能要使用的数学运算符。通过 Comparison 对象访问运算符。可选择以下选项:
  • 包含
  • 平等
  • GreaterThan
  • 大于或等于
  • 不等式
  • 小于
  • LessThanOrEqual
  • 正则表达式匹配
第二个表达式 对象
验证流程中的第二个表达式。
输出消息格式 字符串
输出消息格式。支持的参数包括:
  • {Expression}
  • {ExpressionText}
  • {RightExpression}
  • {RightExpressionText}
  • {Result}
  • {Operator}
有关更多信息,请查看“配置 outputMessageFormat”部分。
失败时继续 布尔值
指定如果活动引发错误,是否仍应继续自动化。默认值为 False。因此,如果该字段为空且活动引发错误,系统将停止执行项目。如果该值设为“True”,则无论出现何种错误,系统都将继续执行项目。
可选验证名称 字符串
此标题将显示在 Orchestrator 中。
在断言失败的情况下截取屏幕截图 布尔值
如果设置为 True,则在验证失败时截取目标流程的屏幕截图。
在断言成功的情况下获取屏幕截图 布尔值
如果设置为 True,则在验证成功后截取目标流程的屏幕截图。

返回值

如果验证通过/成功,则为“True”;如果验证失败,则为“False”。

配置输出消息格式

outputMessageFormat参数可以配置受支持的参数,这些参数充当验证操作中所用值的占位符。在这些占位符中,系统会自动填充在运行时调用编码自动化 API 时定义的变量或值。

对于使用运算符验证表达式编码的自动化 API,您可以在创建输出消息时实现以下支持的参数:

  • {Expression}:表示您为 firstExpression 参数提供的首个表达式的值。
  • {ExpressionText}:表示您为 firstExpression 参数插入的首个表达式的文本。
  • {RightExpression}:表示您为 secondExpression 参数提供的第二个表达式的值。
  • {RightExpressionText}:表示您为 secondExpression 参数插入的第二个表达式的文本。
  • {Result} :表示编码自动化 API 的返回值,即验证结果。
  • {Operator:表示验证中使用的运算符,由 operatorValue 参数设置。
以下示例说明了如何使用“VerifyExpressionWithOperator”编码自动化 API,其中包括配置outputMessageFormat参数:
// Initialize variables for the expressions to be verified
var expression1 = "User created succesfully";
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}.");// Initialize variables for the expressions to be verified
var expression1 = "User created succesfully";
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}.");

在提供的示例中,大括号中的占位符在运行时替换为相应的变量名称及其值,从而提供自定义的输出消息。

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2025 UiPath。保留所有权利。