Actions

  1. Overview
  2. SnapTest and Selenium-only Actions
  3. Full-project generators
  4. Action JSON
  5. Generator Action Contract

Overview

Tests are composed of a list of actions - commands to tell the browser what to do and assertions to check for. For example, a simple test may say:

  1. Load a page.
  2. Check for an element to exist.
  3. Click on a link.

This test is composed of 3 actions. If this test succeeds, you can by nature assert these things: The page exists and works, an element exists, and a link exists and can be clicked.

SnapTest and Selenium-only Actions

Most actions can be executed within the extension, but due to Chrome extension limitations, some actions can only be "automated" by running the generated Selenium code (iFrames, window context switching, drag and drop).
If an action turns "yellow" in the extension, it means that it is a Selenium only action and will need to be manually executed in the extension.

Selenium-only actions played within the extension will soon get "pause and wait for manual action" feature for those who like to stay within SnapTest for running tests.

Currently, when you toggle the timeout between custom and global, it applies the global to the custom value afterwards.

It's possible to restore the old value, but you'll have to remember what you put before and input it manually.

This shouldn't be an issue if you're setting the custom timeout once.

A few uses cases for custom timeouts are:

  1. Page loads.
  2. Registration.
  3. Submitting a purchase.
  4. Waiting for an event to appear.

Full-project generators

SnapTest strives to give its users the ability to generate entire projects in various frameworks, which should just work without requiring you to adjust your tests for other frameworks.

In order to do this, project/code generators must meet the Generator Action Contract so that the Selenium playback matches the extension playback. For a generator to be considered a "Full-project generator", it must fulfill the following action specifications at 100%:

Action JSON

Each action is defined by a JSON array entry. Each action has:

  1. A "description" variable that should help generate better error reports and/or add code comments.
  2. A "skipIfFailed" variable that should continue execution if action fails.
  3. A "timeout" variable. If null, it should use the global timeout setting.

Generator Action Contract:

Navigation Commands:

Action:Type:Spec:Variables:Automated in:
Load PageFULL_PAGELOADPerform a GET request at the url value and sets window dimensions to width & height.
  • value: String - Fully qualified url. accepts variables.
  • width: Number - Window width
  • height: Number - Window height
Snaptest/Selenium
BackBACKPerforms a "back" operation, same as clicking the back button in a browser.NoneSnaptest/Selenium
ForwardFORWARDPerforms a "forward" operation, same as clicking the foward button in a browser.NoneSnaptest/Selenium
RefreshREFRESHPerforms a soft "refresh" operation, meaning no cache's are getting cleared.NoneSnaptest/Selenium
Focus windowCHANGE_WINDOWChanges the test "focus" or "context" to index value. Initial tab/window is 0, and any additional windows are incrementally numbered by the order they're opened.
  • value: Number - Index of the window to be focused.
Selenium-only

General Commands:

Action:Type:Spec:Variables:Automated in:
Click elementMOUSEDOWN1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. performs a full click on that element.
  • selector: String - CSS selector
  • timeout: Number - MS to wait for element.
  • x: Number - (optional use) the X coord of the click.
  • y: Number - (optional use) the Y coord of the click.
Snaptest/Selenium
Press key...KEYDOWN1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. Sends a key press signal to an element with the keyValue keycode.
  • selector: String - CSS selector
  • keyValue: String ("Enter" or "Escape")
  • timeout: Number - MS to wait for element.
Selenium-only
Change input...INPUT1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. Fully replace the element's value with value.
  • selector: String - CSS selector
  • value: String - New value to replace the old value with. (should accept variables)
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
Form submitSUBMIT1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. Triggers the form submit functionality on a form. Can be triggered via JS or focusing and clicking "Enter".
  • selector: String - CSS selector of a form.
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
Mouse overMOUSEOVER1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. Simulate a user mousing over the element.
  • selector: String - CSS selector.
  • timeout: Number - MS to wait for element.
Selenium-only
FocusFOCUS1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. Perform a focus on the element.
  • selector: String - CSS selector.
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
BlurBLUR1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. Perform a blur off of the element.
  • selector: String - CSS selector.
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
PausePAUSEPause test execution for value amount of milliseconds.
  • value: Number - Amount in milliseconds to pause.
Snaptest/Selenium
Execute scriptEXECUTE_SCRIPTInject and execute the script string in the page. May return true or false for asserting. If returns false, it should fail as an assertion.
  • script: String - Javacript code to be injected.
Snaptest/Selenium
Clear cookiesCLEAR_COOKIESClear the cookies at domain value. value must be a fully qualified url with protocol.
  • value: String - Url to clear cookies of: should be an FQDN - "https://www.snaptest.io" not "www.snaptest.io" (should accept variables)
Snaptest/Selenium

Scrolling Commands:

Action:Type:Spec:Variables:Automated in:
Scroll win(dow) to...SCROLL_WINDOWScroll the window to the x and y coordinates. Should trigger "onscroll" events.
  • x: Number - the target X coord
  • y: Number - the target Y coord
Snaptest/Selenium
Scroll win(dow) to el(ement)...SCROLL_WINDOW_ELEMENT1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. Scroll the window to the element.
  • selector: String - CSS selector
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
Scroll el(ement) to...SCROLL_ELEMENT1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. Scroll an element to the x / y position.
  • selector: String - CSS selector
  • x: Number - the target X coord
  • y: Number - the target Y coord
  • timeout: Number - MS to wait for element.
Snaptest/Selenium

Assertions:

Action:Type:Spec:Variables:Automated in:
El is presentEL_PRESENT_ASSERT1. Check that an element at selector exists. Retry every second for total amount of timeout ms.
  • selector: String - CSS selector
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
El isn't presentEL_NOT_PRESENT_ASSERT1. Check that an element at selector doesn't exist. Retry every second for total amount of timeout ms.

  • selector: String - CSS selector
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
El text is...TEXT_ASSERT1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. If regex is false, then check for the element's text to equal value. retry every second for the remaining timeout value.

3. If regex is true, then check for the element's text to test positive against the regex (/value/g).
  • selector: String - CSS selector
  • value: String - value to match. if matching regex, it will be /value/g (should accept variables)
  • regex: Boolean - specifies whether this assertion should use a regex
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
Input value is...VALUE_ASSERT1. Check that an element at selector exists. Retry every second for total amount of timeout ms.

2. If regex is false, then check for the inputs's value to equal value. retry every second for the remaining timeout value.

3. If regex is true, then check for the input's value to test positive against the regex (/value/g).
  • selector: String - CSS selector
  • value: String - value to match. if matching regex, it will be /value/g (should accept variables)
  • regex: Boolean - specifies whether this assertion should use a regex
  • timeout: Number - MS to wait for element.
Snaptest/Selenium
Path is...PATH_ASSERTNote: "Path" refers "/hello" in "https://www.wowow.com/hello?cool=neat#awesome"

1. DOM is ready. Retry every second for total amount of timeout ms.

2. If regex is false, then check for the path's value to equal value. retry every second for the remaining timeout value.

3. If regex is true, then check for the path's value to test positive against the regex (/value/g).
  • value: String - value to match. if matching regex, it will be /value/g
  • regex: Boolean - specifies whether this assertion should use a regex
  • timeout: Number - MS to wait for element.
Snaptest/Selenium

Miscellaneous:

Action:Type:Spec:Variables:Automated in:
ComponentCOMPONENTCall the component of componentId from the component pool. When calling the component, pass in the variable array as the method arguments.
  • componentId: String - ID of the component to execute
  • variable: Array - Instance variables that will override the default variales of a component.
Snaptest/Selenium
Url change indicatorURL_CHANGE_INDICATORA non-functional "flag" that helps in the generation of code and visual clarity in the snaptest tool.
  • value: String - The name of the page. (auto-generated as the page - e.g. /login).
Snaptest/Selenium
Take screenshotSCREENSHOTTake a screenshot and save it with the filename value in the default/configured location.
  • value: String - The file name and path of where the screenshot should be saved.
Selenium-only
Group 6Record it…Play it…Generate it…GeneratorsSelector AlgorithmsPrivate modeTest organizationTeamsWorkspacesDedicated supportTest data storageDebugger toolsAdaptable TestsCLI tools and APIWhite-labeled codeVariablesMulti-test playbackManual testsComponents