Skip to main content

Similarity capture

I capture the similarity score of <textRef> compared to "<text>" as <name>

Compares a text reference with a text value for similarity using the DSC (Dice Similarity Coefficient) algorithm and binds the calculated score to name in the global scope.

Where

  • <textRef> is the name of the binding containing a text reference

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <text> is the text to compare <textRef> against
  • <name> is the name to bind the calculated score to

Example

  Given the phrase is "Hello world!"
When I capture the similarity score of the phrase compared to "Hello world" as similarity score 1
And I capture the similarity score of the phrase compared to "hello world" as similarity score 2
And @IgnoreCase I capture the similarity score of the phrase compared to "hello world" as similarity score 3
Then similarity score 1 should be "0.9411764705882353"
And similarity score 2 should be "0.8235294117647058"
And similarity score 3 should be "0.9411764705882353"

Trimming and ignoring case (since v3.62.0)

  • The @Trim annotation can be used on step to trim strings when comparing
  • The @IgnoreCase annotation can be used on step to ignore case when comparing
I capture the similarity score of <textRef1> compared to <textRef2> as <name>

Compares a text reference with another for similarity using the DSC (Dice Similarity Coefficient) algorithm and binds the calculated score to name in the global scope.

Where

  • <textRef1> is the name of the binding containing a text reference

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <textRef2> is the name of the binding containing the second text reference to compare <textRef1> against

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <name> is the name to bind the calculated score to

Example

  Given phrase 1 is "Hello world!"
And phrase 2 is "hello world"
When I capture the similarity score of phrase 1 compared to phrase 2 as similarity score 1
And @IgnoreCase I capture the similarity score of phrase 1 compared to phrase 2 as similarity score 2
Then similarity score 1 should be "0.8235294117647058"
And similarity score 2 should be "0.9411764705882353"

Trimming and ignoring case (since v3.62.0)

  • The @Trim annotation can be used on step to trim strings when comparing
  • The @IgnoreCase annotation can be used on step to ignore case when comparing
I capture the similarity score of <textRef> compared to "<text>"

Compares a text reference with a text value for similarity using the DSC (Dice Similarity Coefficient) algorithm and binds the calculated score to the similarity score attribute in the global scope.

Where

  • <textRef> is the name of the binding containing a text reference

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <text> is the text to compare <textRef> against

Example

  Given the phrase is "Hello world!"
When I capture the similarity score of the phrase compared to "Hello world"
Then similarity score should be "0.9411764705882353"

Trimming and ignoring case (since v3.62.0)

  • The @Trim annotation can be used on step to trim strings when comparing
  • The @IgnoreCase annotation can be used on step to ignore case when comparing
I capture the similarity score of <textRef1> compared to <textRef2>

Compares a text reference with another for similarity using the DSC (Dice Similarity Coefficient) algorithm and binds the calculated score to the similarity score attribute in the global scope.

Where

  • <textRef1> is the name of the binding containing a text reference

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.
  • <textRef2> is the name of the binding containing the second text reference to compare <textRef1> against

    • Can be the name of any binding that contains or resolves to a text value, including a web element in which case the text in the element will be dynamically retrieved and used.

Example

  Given phrase 1 is "Hello world!"
And phrase 2 is "hello world"
When I capture the similarity score of phrase 1 compared to phrase 2
Then similarity score should be "0.8235294117647058"

Trimming and ignoring case (since v3.62.0)

  • The @Trim annotation can be used on step to trim strings when comparing
  • The @IgnoreCase annotation can be used on step to ignore case when comparing