User Tools

Site Tools


wiki:pickle:supported_statements

Statements Supported in Pickle Execution

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

Why?

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.

How does it work?

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

Compatibility

The automation that selenium can support will vary by browser and the driver. Where the statement is only compatible with specific browsers, the statement will feature some of the following icons.

Modern Browsers

- Google Chrome (best compatibility)

- Edge Chromium (best compatibility)

- Firefox

Legacy Browsers

- Internet Explorer

- Classic Edge

Override Failures

Added 1.15.0.0

On occasion, you will need a statement to execute without consequence (failed step/test). This will allow for misbehaved applications, for example:

Scenario: when something is selected form a list, it navigates to a new page without user input. Consequence: The step to select the item will fail because the page has changed when pickle attempts to validate the selection has been applied.

You can override the failure by adding the following text to the end of the statement:

* (pass if fail) * (warn if fail)

(pass if fail) forces pickle to ignore any failure (Pass) and continue to the next step.

(warn if fail) forces pickle to note the issue (Passed with Issue) and continue to the next step.

Important Note: By using this statement, you are disabling the assertion of a statement and therefore it is advised that the next statement validates that the page is in the state expected (separate assertion).

Example Script:

Feature: Manage failures correctly based on overrides.

Scenario: #43 - Case should fail
Given "match" equals "notmatch" (pass if fail)
Given "match" equals "notmatch" (warn if fail)
Given "match" equals "notmatch"

Scenario: #43 - Case should pass
Given "match" equals "notmatch" (pass if fail)
Given "match" equals "notmatch" (warn if fail)
Given "match" equals "notmatch" (pass if fail)

Selenium timeouts

Added 1.15.0.0

By default, the selenium timeout is 20 seconds and can be overridden by using a configuration file.

You can also override the timeout for a specific statement (only works for browser automation statements). This allows for the speed up or slowdown of an assertion/command. You can append the following statement to the end of and step:

(timeout in n seconds)

n represetns the number of seconds.

Example Script:

Feature: #44 Custom timeout

@javascript
Scenario: #44 Test Case
Given I go to "http://myUrl.com"
#normal timing
Then I should see "[byid] thisIDdoesnotexist" (warn if fail)
#normal timing
Then I should see "[byid] thisIDdoesnotexist" (timeout in 5 seconds)(warn if fail)
#normal timing
Then I should see "[byid] thisIDdoesnotexist" (timeout in 60 seconds)(warn if fail)
#normal timing
Then I should see "[byid] thisIDdoesnotexist" (warn if fail)

Filename Macros

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. * %appdatapath% - the “Application Data” path. Added 1.14.0.0 * %desktoppath% - The Windows Desktop path. Added 1.14.0.0 * %downloadpath% - The default downnload folder. Added 1.14.0.0

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"

Static Variables

Added 1.14.0.0

Pickle provides several static variables that can be used in your scripts:

* %username% - Your windows user name. * %computer% - The computers name. * %seleniumdriver% - The name of the browser/selenium driver. * %ipaddress% - The computers local IP address.

Given I record "%username%" into {Username}
Given I record "%computer%" into {ComputerName}
Given I record "%seleniumdriver%" into {SeleniumDriver}
Given I record "%ipaddress%" into {IPAddres}

File Writing Macros

Added 1.15.0.0

When writing files, certain characters could conflict with pickles normal operation. Macros have been provided to fix this issue. For file creation and writing command, the following are valid:

CodeReplaced with
&cr;\n (Return/New Line)
&lf;\r (Line Feed) - Unix end of line
&crlf;\r\n (Return & Line Feed) - MS Windows end of line
&tab;\t (Tab)
&quote;“ (Quote)
&$;$
&lb;{
&rb;}
&fs;/
&bs;\
&hash;#
&perc;%
&&
&u0000;A unicode character (replace 0000 with the uniicode decimal value) See this.
&a000;An ASCIIcharacter (replace 0000 with the ASCII decimal value)

Examples:

Scenario: Special Characters
Given I delete the file "%scriptpath%\fileTest\#38-UnitTest.chars.txt" (pass if fail)
Given I create the UTF8 file "%scriptpath%\fileTest\#38-UnitTest.chars.txt" containing "All lines should have a Carriage Return & linefeed.&crlf;"
Given I write the UTF8 characters "quote &quote;&crlf;" to the file "%scriptpath%\fileTest\#38-UnitTest.chars.txt"
Then I write the UTF8 characters "tab = &tab;<--&cr;&lf;" to the file "%scriptpath%\fileTest\#38-UnitTest.chars.txt"
And I write the UTF8 line "Chars: &$;&lb;&rb;&fs;&bs;&hash;&perc;" to the file "%scriptpath%\fileTest\#38-UnitTest.chars.txt"
And I write the UTF8 line "Unicode Chars: &u1035;&u1120;&u0040;&u0041;" to the file "%scriptpath%\fileTest\#38-UnitTest.chars.txt"
And I write the UTF8 line "Ascii Chars: &a0040;&a0041;" to the file "%scriptpath%\fileTest\#38-UnitTest.chars.txt"
And I record the data from the UTF8 file "%scriptpath%\fileTest\#38-UnitTest.chars.txt" to {fileData}
And I manually verify the characters once completed.

Searching for a Web Page Element?

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:

  • ID
  • Name
  • Link Text
  • Partial Link Text
  • CSS Selector
  • XPath
  • Last

This is very inefficient but will generally find an item if it exists. It would be best if you remembered 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. You can change the individual timeout for a statement using - see this section.

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.
  • [ByName] - 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-element used in a previous statement.

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.

A List All Supported Statements

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 Response Capture Fields

StatementSyntaxLink
Given I record the "prompt" into {field} Instructs the tester to capture (enter) a value.
Given I capture the "prompt" with the format "format" into {field} Instructs the tester to capture (enter) a value in a specific format.
Given 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>" Click a web element based on Name, Link Text, Id, CSS Selector or XPath. -
Given I follow"<element>" 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 Scroll the specified 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

Assertions

StatementSyntaxLink
Given "x" equals "x" Instructs Pickle TS to compare two values and only pass the step if they are identical.
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.

1.11.0.6 Beta

Assertions

StatementSyntaxLink
Given "<text>" equals "<text>" Instructs Pickle TS to compare two values and only pass the step if they are identical.
Given <num> equals <num> Instructs Pickle TS to compare two values and only pass the step if they are identical.
Given <num> does not equal <num> Instructs Pickle TS to compare two values and only pass the step if they are different.
Given <num> is greater than <num> Instructs Pickle TS to compare two values and only pass the step if the first value is greater than the second.
Given <num> is less than <num> Instructs Pickle TS to compare two values and only pass the step if the first value is less than the second.
Given <num> is between <num> and <num> Instructs Pickle TS to compare values and only pass the step if the first value is between the other values.

1.11.0.7 Beta

Browser Automation

StatementSyntaxLinkCompatibility
Given I record the innertext of "<Element>" to {field} Stores the inner text of an element to the specified field.
Given I record the innerhtml of "<Element>" to {field} Stores the inner HTML of an element to the specified field.

1.12.0.0 Beta

Assertions

StatementSyntaxLink
Given "Value" matches "RegExp" Instructs Pickle TS to evaluate if a value matches a regular expression.Regular Expressions
Given "Value" does not match "RegExp" Instructs Pickle TS to evaluate if a value matches a regular expression.Regular Expressions
Given I extract "RegExp" from "Value" and record it to {field} Capture a subset of the data from a value using a regular expression.Regular Expressions

1.14.0.0 Beta

Calculated Fields

StatementSyntaxLink
Given I convert {source} to lowercase Instructs Pickle TS tpo vonvert a variable to lowercase.-
Given I convert {source} to uppercase Instructs Pickle TS tpo vonvert a variable to uppercase.-
Given I convert {source} to titlecase Instructs Pickle TS tpo vonvert a variable to title case.-

1.15.0.0 Beta

File Management

StatementSyntaxLink
Given the file "path\file.name" existsVerifies a file exists.-
Given the file "path\file.name" does not existsVerifies a file does not exists.-
Given I delete the file "path\file.name"Delete a file.-
Given I copy the file "path\file.name" to "path\file.name"copy a file.-
Given I move the file "path\file.name" to "path\file.name"move/rename a file.-
Given I create the UTF8\ASCII file "path\file.name" containing "file-content"Create an empty UTF8 or ASCII file with specified contents.See File Writing Macros
Given I write the UTF8\ASCII characters "data" to the file "path\file.name"Append UTF8 or ASCII data to the specified file.See File Writing Macros
Given I write the UTF8\ASCII line "data" to the file "path\file.name"Append UTF8 or ASCII data to the specified file with a line break after (CR+LF).See File Writing Macros
Given I record the data from the UTF8\ASCII file "path" to {field}Stores the data from a file into the specified field.-
Given the UTF8\ASCII file "path" contains "RegExp"Verifies the file contains the specified regular expression.Regular Expressions
Given the UTF8\ASCII file "path" does not contain "RegExp"Verifies the file does not contain the specified regular expression.Regular Expressions
Given I replace "Data" with "Data" in the UTF8\ASCII file "path"Replace the specified data in a file.-
replacing it with "RegExp" in the UTF8\ASCII file "path"|Given I match "RegExp"| replacing it with "RegExp" in the UTF8\ASCII file "path" Replace the specified data in a file using a regular expression.Regular Expressions & Regular Expression Replacement/Sunstiution
Given the file "filename" is between 0MB\KB\bytes and 0MB\KB\bytesAssert a file is between a range of sizes.-
Given the file "filename" is not between 0MB\KB\bytes and 0MB\KB\bytesAssert a file is not between a range of sizes.-
Given I record the name of the latest file created in the folder "path" matching "(RegExp)" to {field}Stores the filename (not path) of the latest file matching the Regular Expression created in a specified folder.Regular Expressions
Given I record the name of the latest file updated in the folder "path" matching "(RegExp)" to {field}Stores the filename (not path) of the latest file matching the Regular Expression updated in a specified folder.Regular Expressions
Given I record the name of the latest file created in the folder "path" to {field}Stores the filename (not path) of the latest file created in a specified folder.-
Given I record the name of the latest file updated in the folder "path" to {field}Stores the filename (not path) of the latest file updated in a specified folder.-
/kunden/homepages/16/d819147553/htdocs/thinkingengine/wiki/data/pages/wiki/pickle/supported_statements.txt · Last modified: 12/09/2020 02:50 by ThinkingEngine