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

工作流活动

上次更新日期 2026年5月13日

VerifyRange

验证表达式是否位于给定范围内。

定义

命名空间: UiPath.Testing.API

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

重载

VerifyRange(object,VerificationType, object, string)验证表达式是否位于给定范围内。
VerifyRange(object,VerificationType, object, object,``string, bool, string, bool, bool)验证表达式是否位于给定范围内。 除了验证之外,您还可以执行其他配置,例如配置输出消息格式,或在断言失败时截取屏幕截图。

VerifyRange(object,VerificationType, object, string)

验证表达式是否位于给定范围内。

bool VerifyRange(
    Object expression,
    VerificationType verificationType,
    Object lowerLimit,
    Object upperLimit
)
bool VerifyRange(
    Object expression,
    VerificationType verificationType,
    Object lowerLimit,
    Object upperLimit
)

expression “对象” :要在给定范围内验证的表达式。

verificationType VerificationType :选择验证类型 - 在范围内或之外:

  • IsWithin
  • IsNotWithin

lowerLimit对象:范围的下限。

upperLimit对象:范围的上限。

outputMessageFormat String : 输出消息的格式。支持的参数包括:

  • {Expression}
  • {ExpressionText}
  • {Operator}
  • {LowerLimit}
  • {LowerLimitText}
  • {UpperLimit}
  • {UpperLimitText}
  • {Result}

有关更多信息,请查看“配置outputMessageFormat部分。

VerifyRange(Object,VerificationType, Object, Object,``String, Boolean, String, Boolean, Boolean)

验证表达式是否位于给定范围内。您还可以执行验证以外的其他配置,例如配置输出消息格式,或者在断言失败时截取屏幕截图。

bool VerifyRange(
    Object expression,
    VerificationType verificationType,
    Object lowerLimit,
    Object upperLimit,
    string outputMessageFormat,
    bool continueOnFailure,
    string alternativeVerificationTitle,
    bool takeScreenshotInCaseOfFailingAssertion,
    bool takeScreenshotInCaseOfSucceedingAssertion
)
bool VerifyRange(
    Object expression,
    VerificationType verificationType,
    Object lowerLimit,
    Object upperLimit,
    string outputMessageFormat,
    bool continueOnFailure,
    string alternativeVerificationTitle,
    bool takeScreenshotInCaseOfFailingAssertion,
    bool takeScreenshotInCaseOfSucceedingAssertion
)

expression “对象” :要在给定范围内验证的表达式。

verificationType VerificationType :选择验证类型 - 在范围内或之外:

  • IsWithin
  • IsNotWithin

lowerLimit对象:范围的下限。

upperLimit对象:范围的上限。

outputMessageFormat String : 输出消息的格式。支持的参数包括:

  • {Expression}
  • {ExpressionText}
  • {Operator}
  • {LowerLimit}
  • {LowerLimitText}
  • {UpperLimit}
  • {UpperLimitText}
  • {Result}

有关更多信息,请查看“配置outputMessageFormat部分。

continueOnFailure Boolean - 指定在活动引发错误时是否应继续自动化。默认值为 FALSE。因此,如果该字段为空且活动引发错误,系统将停止执行项目。如果该值设为“True”,则无论出现何种错误,系统都将继续执行项目。

alternativeVerificationTitle String : 这将在 Orchestrator 中显示。

takeScreenshotInCaseOfFailingAssertion Boolean :如果设置为True ,则在验证失败时截取目标流程的屏幕截图。

takeScreenshotInCaseOfSucceedingAssertion布尔值:如果设置为True ,则在验证成功后截取目标流程的屏幕截图。

返回值

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

Configuring the outputMessageFormat

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

对于“验证范围”编码自动化 API,您可以在创建输出消息时实现以下支持的参数:

  • {Expression}:表示您为 expression 参数提供的表达式的值。
  • {ExpressionText}:表示您为 expression 参数插入的表达式的文本。
  • {Operator}:对应 verificationType 参数。
  • {LowerLimit}:表示用于 lowerLimit 参数的变量名称。
  • {LowerLimitText}:指用于 lowerLimit 参数的变量的文本表示。
  • {UpperLimit}:表示用于 upperLimit 参数的变量名称。
  • {UpperLimitText}:指用于 upperLimit 参数的变量的文本值。
  • {Result} :表示编码自动化 API 的返回值,即验证结果。

以下示例说明了如何使用“验证范围”编码自动化 API,其中包括配置outputMessageFormat参数:

// Initialize a variable for the expression to be verified
var Expression1 = 23;

// Employ the VerifyRange coded automation API, with the last string parameter being the outputMessageFormat
testing.VerifyRange(Expression1, VerificationType.IsWithin, 1, 25, "The {Expression} should be greater than {LowerLimitText}, and less than {UpperLimitText}");
// Initialize a variable for the expression to be verified
var Expression1 = 23;

// Employ the VerifyRange coded automation API, with the last string parameter being the outputMessageFormat
testing.VerifyRange(Expression1, VerificationType.IsWithin, 1, 25, "The {Expression} should be greater than {LowerLimitText}, and less than {UpperLimitText}");

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

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新