Statements Supported in Pickle Execution

Pickle Test Suite will automatically detect and execute certain Gherkin statements to assist in execution of testing.

The concept of Gherkin is that a test script is totally self-contained. Whilst this is still the primary aim, in the real world, test scripts will need to interact and gather data generate by systems for later test steps.

During execution, when Pickle finds a statement it can help with, it will complete that step automatically.

Some commands require a filename (Execute the script and attach file for example). To make pathing dynamic, macro variables are usable in any script to provide the path dynamically:

  • %scriptpath% = the current pickle script or project path.
  • %docpath% = the “MyDocuments” path.

For example the statement:

And I run the local JavaScript file "%docpath%\unittests\test.js"
Could be resolved to:
And I run the local JavaScript file "C:\Users\user1\Documents\unittests\test.js"

Wherever a scrip[t mentions an “element” this will be an element of the page (DOM). The default search will identify the first element that matched the search text provided. It searches in the following in order

  1. ID
  2. Name
  3. Link Text
  4. Partial Link Text
  5. CSS Selector
  6. XPath
  7. Last

This is very inefficient but will generally find an item if it exists. You should remember that each of the above implements a search with its own timeout, therefore it could take 20+ seconds to get through to find an XPath.

To combat this, firstly the last element found in a script is cached (until the page is changed or reloaded), making secondary actions immediate without a search.

You can also limit the search by preceding the element text with a search criteria keyword. Valid keywords are:

  • [ByID] - The search is for the ID Attribute only.
  • [ByNmae] - The search is for the Name Attribute only.
  • [ByCLass] - - The search is for the Class Attribute only.
  • [ByLinkText] - Only search link text.
  • [ByPartLinkText] - Only search link text (partial match).
  • [ByTag] - Search for the item with the tHTML Tag specified.
  • [ByCSS] Search for the CSS selector specified.
  • [ByXPath] Search for the XPath specified.
  • [Last] Ignores any further element identifier and uses the web-elment used in a previous staement.

Because these keywords limit the search, the result is returned much faster.

For example, if I wanted to press an element with the ID of Button1, I could use:

Given I press "Button1"

But it would be more efficient to use:

Given I press "[ByID]Button1"

The last keyword can make scripts easier to edit with less correction when the page changes.

Given I clear "[ByID]MyUserNameField"
And I fill in "[last]" with "myemail@myserver.com"

The above would clear the field and then type the e-mail address into it.

Pre 1.11.0.0

Calculated Fields

StatementSyntaxLink
Given I record a unique value to {field} Instructs the tester to generate a unique value (in pickle execution this will be automatic).
Given I record a unique alphabetic value to {field} Instructs the tester to generate a unique value (in pickle execution this will be automatic).
Given I select an item from [item1,item2] and record it to {field} Instructs the tester to select an item from a pre-defined list.
Given I select a date between “1 Feb 2017” and “1 Feb 2018” then record it to {field} Instructs the tester to select a date in a range.
Given I select a number between 1 and 99 then record it to {field} Instructs the tester to select a number in a range.
Given I select a number between 1.1 and 1.9 then record it to {field} Instructs the tester to select a number in a range.
Given I record “data” into {field} Instructs the tester to capture a constant string value. -
Given I record 9.99 into {field} Instructs the tester to capture a number value. -
Given I create an email address for the domain “domain.com” and record it to {field} Instructs the tester to create a unique e-mail address.
Given I record the date into {field} Instructs the tester to record the current date. -
Given I record the time into {field} Instructs the tester to record the current time. -
Given I record the date/time in the format “dd MMM yy HH:mm:ss” into {field} Instructs the tester to record the current date/time in a specific format.
Given I calculate “1+1” and store it to {field} Instructs the tester to calculate a value.

User Responese Capture Fields

StatementSyntaxLink
person_outlineGiven I record the “prompt” into {field} Instructs the tester to capture (enter) a value.
person_outlineGiven I capture the “prompt” with the format “format” into {field} Instructs the tester to capture (enter) a value in a specific format.
person_outlineGiven I capture the “Prompt.” into {field} Instructs the tester to capture (enter) a value.

1.11.0.0 Beta

Calculated Fields

StatementSyntaxLink
Given I add <days> days to “Date” and store it to {field} Instructs the tester to add the sprified number of days to a date and store the value. -
Given I add between <StartDays> and <EndDays> days to “Date” and store it to {field} Instructs the tester to randomly add a number of days within a range to a date and store the value. -
Given I convert the date “<date>” as “dd\\MM\\yy”, recording it into {field} Instructs the tester to record the specified date in a specific format. -

Browser Automation

StatementSyntaxLinkCompatibility
Given I go to “URL Navigate to a URL in the browser. -
Given I am on “URL Validate the current browser URL. -
Given I am not on “URL Validate the current browser URL is not the specified. -
Given I am on the host “host” Validate the current browser URL is within a specified host. -
Given I am not on the host “host” Validate the current browser URL is not within a specified host. -
Given I reload the page Reload the current page. -
Given I move backward one page Navigate backward one page. -
Given I move forward one page Navigate forward one page. -
Given I press “<element>” Click a web <element> based on Name, Link Text, Id, CSS Selector or XPath. -
Given I click “<element>” (Corrected Documentation) Click a web element based on Name, Link Text, Id, CSS Selector or XPath. -
Given I follow“<element>” (Corrected Documentation) Follow a link based on Name, Link Text, Id, CSS Selector or XPath. -
Given I fill in “<element>” with “value” Replace a form fields value with that specified. -
Given I fill in “<value>” for “<element>” Replace a form fields value with that specified. -
Given the “<field>” field should contain “<match>” The value of a specified form field should contain <match>. -
Given the “<field>” field should not contain “<match>” The value of a specified form field should not contain <match>. -
Given I should see “<match>” in the “<field>” element The value of a specified form field should contain <match>. -
Given I should not see “<match>” in the “<field>” element The value of a specified form field should not contain <match>. -
Given I record the value of “<field>” to {variable} The value of a specified form field will be recorded to the specified variable. -
Given I record the “<attribute>” of “<element>” to {variable} The attribute of a specified element will be recorded to the specified variable. -
Given I select “<option>” from “<optionlist>” Select an option from the option list. -
Given I additionally select “<option>” from “<optionlist>” Select another option from the option list. -
Given I also select “<option>” from “<optionlist>” Select another option from the option list. -
Given I select <index> from “<optionlist>” Select an option index from the option list. -
Given I additionally select <index> from “<optionlist>” Select another option index from the option list. -
Given I also select <index> from “<optionlist>” Select another option index from the list. -
Given I check “<checkbox>” Check the checkbox element. -
Given I uncheck “<checkbox>” Uncheck the checkbox element. -
Given I attach the file “<filename>” to “<file form field>” #use %scriptpath% or %docpath% in the path if needed Attach a file to a file form field. -
Given I should see “<search text>” The source contains the search text. -
Given the response should contain “<search text>” The source contains the search text. -
Given I should not see “<search text>” The source does not contain the search text. -
Given the response should not contain “<search text>” The source does not contain the search text. -
Given the “<checkbox>” checkbox should be checked The checkbox field should be checked. -
Given the “<checkbox>” checkbox should not be checked The checkbox field should not be checked. -
Given I should be on “<URL>” The page should be the specified URL. -
Given the url should match “<URL Fragment>” The page URL should contain the URL Fragment. -
Given I should not be on “<URL>” The page should not be the specified URL. -
Given the url should not match “<URL Fragment>” The page URL should not contain the specified URL Fragment. -
Given the <index> element should contain “<value>” The <index> element should have the specified value. -
Given the “<index>” element should contain “<value>” The <index> element should have the specified value. -
Given the “<index>” element should not contain “<value>” The <index> element should not have the specified value. -
Given the <index> element should not contain “<value>” The <index> element should not have the specified value. -
Given I should see an “<element>” element The element exists on the page. -
Given I should not see an “<element>” element The element does not exist on the page. -
Given the response status code should be <httpCode> The HTTP response code is the one specified. -
Given the response status code should not be <httpCode> The HTTP response code is not the one specified. -
Given I wait for <num-seconds> seconds The script will wait for the specified number of seconds. -
Given I wait for “<element>” element to be on the page within <num-seconds> seconds Waits for the specified element to be visible on the page (not always to the user). -
Given I wait for “<element>” element to be on the screen within <num-seconds> seconds Waits for the specified element to be visible to the user. -
Given I wait for “<element>” element to not be on the page within <num-seconds> seconds Waits for the specified element to not be visible on the page. -
Given I wait for “<element>” element to not be on the screen within <num-seconds> seconds Waits for the specified element to not be visible to the user. -
Given “<element>” element is on the page Validates that the specified element is on the page (not always visible to the user). -
Given the user can see “<element>” element Validates that the specified element is visible to the user. -
Given “<element>” element is not on the page Validates that the specified element is not on the page. -
Given the user cannot see “<element>” element Validates that the specified element is not visible to the user. -
Given I scroll “<element>” element into view

1.11.0.1 Beta

Browser Automation

StatementSyntaxLinkCompatibility
Given I submit the form “<formElement>” Submit a webform using standard submit functionality. -
Given I simulate a click on “<Element>” Simulate a mouse right click on the element using Syn.js. -
Given I simulate a double click on “<Element>” Simulate a mouse right double click on the element using Syn.js. -
Given I simulate typing “text” into “<Element>” Simulate typing the specified text into the element using Syn.js. -
Given I run the local JavaScript file “Filename” Runs a locally stored JavaScript file. Allows the inserting of custom funcitons that can be run later. #use %scriptpath% or %docpath% in the path if needed.
Given I run the JavaScript command “<JsCommand>” Runs a JavaScript command against the browser.
Given the JavaScript function “<JsCommand>” returns true Runs a JavaScript function against the browser and ensures that it returns true.
Given the JavaScript function “<JsCommand>” returns false Runs a JavaScript function against the browser and ensures that it returns false.

1.11.0.2 Beta

Browser Automation

StatementSyntaxLinkCompatibility
Given I record the result of the JavaScript function “<JSCommand>” to {field} Runs a JavaScript function and record the response into the specified field.

1.11.0.3 Beta

Browser Automation

StatementSyntaxLinkCompatibility
Given I clear {field} Clears the vlaue in a text field.

1.11.0.4 Beta

Calculated Fields

StatementSyntaxLink
Given Given “x” equals “x” Instructs Pickle TS to compare two values and only pass the step if they are identical.
Given Given “x” does not equal “y” Instructs Pickle TS to compare two values and only pass the step if they are different.

Browser Automation

StatementSyntaxLinkCompatibility
Given I dismiss the alert Dismisses a popup alert
Given I accept the alertAccepts a popup alert
Given I switch to the first tabSwitches to the first tab in the browser
Given I switch to the lasttabSwitches to the last tab in the browser
Given I switch to tab <num>Switches to tab <num> in the browser. Index started at 1.
Given I switch to the iFrame “<frame element>”Switches to iFrame specified.
Given I switch to the parent iFrame of “<frame element>”Switches to parent of the iFrame specified.
Given I switch to the default contentSwitches to the deafuly content/frame.
Given I delete all cookiesDeletes all coookies associates with the site.
Given I set the cookie called “<cookie name>” to “<value>”Sets/Add the cookie with the value specified.
Given the cookie called “<cookie name>” contains “<value>”Verifies the cookie contains the specified value.
Given the cookie called “<cookie name>” does not contain “<value>”Verifies the cookie does not contain the specified value.
Given tI delete the cookie called “cookie name”Deleted the cookie specified.
  • wiki/pickle/supported_statements.txt
  • Last modified: 28/07/2019 17:24
  • by ThinkingEngine