How to pass a string of text that includes quotation marks

How to pass a string of text that includes quotation marks

Problem

I am trying to pass a string of text that includes quotation marks into a variable in Cycle but the quotation marks are not being included.

Solution

Anytime you are entering a string of text that you want Cycle to capture in its entirety even though it contains quotes inside of the string, surround your string in """triple quotes""" (3 sets of double quotes) to ensure that Cycle treats the whole segment as a single string.

Example

You may need to enter text into a field on a web page that is required to be entered with double quotes at the beginning and ending of the text.

The following example demonstrates the usage of triple quotes to allow embedding double quotes within a Cycle step and how this ability changes the way a web page searches for results.

The steps below assign a variable called “item_description” to be searched in the “Items” JDA WMS Web Screen. This variable assignment uses the standard double quotes to make the assignment.

Given I assign "cycle each part" to variable "item_description"

Then I see element $filter_box in web browser within $wait_short ms

And I type $item_description in element $filter_box in web browser within $wait_short ms

And I see element $filter_selection in web browser within $wait_med ms

Then I click element $filter_selection in web browser

And I wait $wait_ex_long ms

Cycle will type the item_description value within the filter box and execute the search. The search returns three records because the search logic is looking for partial matches of ‘cycle each part’ item description:

Cycle Execution

triple1.png

JDA WMS Search Result

triple2.png

 

Alternatively, using triple quotes to embed double quotes within the variable value returns a different result. The steps below use triple quotes to make the variable assignment. Note that within the triple quotes, the item description value itself is surrounded by double quotes (making 4 total double quotes on each side of the string.)

Given I assign """"cycle each part"""" to variable "item_description"

Then I see element $filter_box in web browser within $wait_short ms

And I type $item_description in element $filter_box in web browser within $wait_short ms

And I see element $filter_selection in web browser within $wait_med ms

Then I click element $filter_selection in web browser

And I wait $wait_ex_long ms

This time, Cycle will type the item_description value including the double quotes and the search will return one result due to the double quotes forcing an exact match of “cycle each part” item description:

Cycle Execution

triple3.png

 

JDA WMS Search Result

 triple4.png

    • Related Articles

    • How to use Groovy to work with Dates and Times

      Problem Cycle does not include steps to access and work with Date and Time. Solution Cycle now includes steps to execute simple Groovy statements as well as execute complex Groovy scripts. The 2 Cycle steps that execute Groovy are: I execute Groovy ...
    • Can Cycle execute MOCA and Local Syntax?

      Problem Cycle Features built to interact with and test the JDA WMS need to run queries, execute statements and perform validations directly against the database. Solution JDA WMS provides a framework to ease database interaction called MOCA. Cycle ...
    • How to use Groovy to work with Strings

      Problem Other than concatenate Cycle does not include steps to work with strings. Solution Cycle now includes steps to execute simple Groovy statements inline as well as execute complex Groovy scripts. The 2 Cycle steps that execute Groovy are: I ...
    • How to use Groovy to return values in XML strings

      Problem It may be necessary to return values from XML strings in your automated tests. This article provides examples for common ways to use the Groovy programming language to output XML information. Solution Cycle includes steps to execute simple ...
    • Step Error When Using ‘I assign values from config file’

      This article describes the root cause and resolution for error messages you may encounter when using the ‘I assign values from config file’ step in Cycle. Error Examples You may get error messages similar to the messages below when using the step ‘I ...