### Start Browser or Device Source: https://testrigor.com/docs/language Starts a new browser session or device instance. The 'start browser "User 2" and switch' variant immediately switches to the newly opened session. ```testRigor start browser "User 2" ``` ```testRigor start browser "User 2" and switch ``` ```testRigor start device "User 2" ``` -------------------------------- ### Install Application Source: https://testrigor.com/docs/language Installs a pre-uploaded mobile application onto the testRigor Android/iOS device. ```APIDOC ## Install Application ### Description Installs a pre-uploaded mobile application onto the testRigor Android/iOS device. ### Method `install application` ### Parameters - **alias** (string) - Required - The alias of the mobile application to install. ### Example ```apidoc install application "whatsapp" ``` ``` -------------------------------- ### Login Steps Example Source: https://testrigor.com/docs/language This example shows the typical steps executed for a simple email and password login. Ensure login credentials are configured for your application on testRigor. ```testRigor enter stored value "username" into "email" enter stored value "password" into "password" click "Log In" ``` -------------------------------- ### Install Mobile Applications Source: https://testrigor.com/docs/language Install applications that have been uploaded via Settings->Multiple applications. Use the alias defined for the application. ```testrigor install application "whatsapp" ``` -------------------------------- ### Start Browser with TLS Client Certificate Source: https://testrigor.com/docs/language Launch a browser instance with a specified TLS client certificate for authentication. Requires certificates to be uploaded to Test Data and available as stored variables. ```testrigor // certificate is uploaded to variable CERT_USER_ADMIN start browser "context-admin" with certificate from stored variable "CERT_USER_ADMIN" and switch ``` -------------------------------- ### Define and Use Reusable Rule (Subroutine) Source: https://testrigor.com/docs/language Example of creating a reusable rule with a sequence of steps and then calling it. This rule simulates navigating to a checkout page. ```testRigor login click "Men Clothing" scroll down click "Men's cargo shorts" click "brown" click "Size 34" click "Add to cart" check that page contains "Your order is nearly complete!" ``` ```testRigor go to checkout page check page contains "Add to cart" ``` -------------------------------- ### Check URL Starts With Validation Source: https://testrigor.com/docs/language Validates if the current URL begins with a specified string. Execution continues even if the validation fails. ```testRigor check that url starts with "https" ``` -------------------------------- ### Mix Commands and Rules in Conditional Blocks Source: https://testrigor.com/docs/language Demonstrates the flexibility of conditional blocks by mixing commands and rules. This example handles different page states with specific actions. ```testrigor if page contains "Welcome" then accept all cookies wait 20 sec open the main menu else if page contains "Search" then click "Search" enter "Big TV's" purchase the first item on the list else login end ``` -------------------------------- ### JsonPath Path Examples Source: https://testrigor.com/docs/language Demonstrates various JsonPath expressions for selecting elements from a sample JSON object, including wildcards, deep scans, array indexing, slicing, and filtering. ```jsonpath $.store.book[*].author ``` ```jsonpath $..author ``` ```jsonpath $.store.* ``` ```jsonpath $.store..price ``` ```jsonpath $..book[2] ``` ```jsonpath $..book[-2] ``` ```jsonpath $..book[0,1] ``` ```jsonpath $..book[:2] ``` ```jsonpath $..book[1:2] ``` ```jsonpath $..book[-2:] ``` ```jsonpath $..book[2:] ``` ```jsonpath $..book[?(@.isbn)] ``` ```jsonpath $.store.book[?(@.price < 10)] ``` ```jsonpath $..book[?(@.price <= $['expensive'])] ``` ```jsonpath $..book[?(@.author =~ /.*REES/i)] ``` ```jsonpath $..* ``` ```jsonpath $..book.length() ``` -------------------------------- ### Call API with Multi-line Body from String Source: https://testrigor.com/docs/language Construct API calls using parameters and multi-line strings for the request body. The body content starts after 'body text starting from next line' and ends with '[END]'. ```testRigor call api post from the string with parameters "${homePrefix}/api/v1/create" with headers "Content-Type:application/json" and "Accept:application/json" and body text starting from next line and ending with [END] { "param": "value", "param2": "value2" } [END] and get "$.data.name" and save it as "createdName" ``` -------------------------------- ### 2FA Login with SMS Verification Source: https://testrigor.com/docs/language Example demonstrating a typical 2FA login flow using SMS verification. It involves clicking sign-in, entering credentials, verifying SMS code, and completing login. ```testrigor click "Sign in" enter "jacob" into "Username" enter "jacobs-secure-password" into "Password" click "Verify me" check that sms to "+12345678902" is delivered and matches regex "Code\:\d\d\d\d" and save it as "sms" extract value by regex "(?<=Code\:)[0-9]{4}" from "sms" and save it as "confirmationCode" enter saved value "confirmationCode" into "code" click "Continue to Login" check that page contains text "Welcome, Jacob!" ``` -------------------------------- ### Test Sign-up Flow with Email Verification Source: https://testrigor.com/docs/language This snippet demonstrates a complete sign-up flow, including generating unique credentials, submitting the form, and verifying email delivery and content. It ensures that emails are only considered if sent after the test case started. ```Testrigor click "Sign up" generate unique email, then enter into "Email" and save as "generatedEmail" generate unique name, then enter into "Name" and save as "generatedName" enter "PasswordSuperSecure" into "Password" click "Submit" check that email to stored value "generatedEmail" was delivered click "Confirm email" check that page contains "Email was confirmed" check that page contains expression "Hello, ${generatedName}" ``` -------------------------------- ### Play Audio with Start and Stop Controls Source: https://testrigor.com/docs/language Play a specified audio reference after a click event and stop it after another click event. This provides granular control over audio playback during a test. ```Testrigor play audio "sound-to-play-ref" after clicking "start-recording" then click "stop-recording" ``` -------------------------------- ### Select books from index 1 up to (but not including) index 2 Source: https://testrigor.com/docs/json-path Array slicing syntax `[start:end]` selects elements from the start index (inclusive) up to the end index (exclusive). This selects only the second book. ```jsonpath $..book[1:2] ``` -------------------------------- ### Define and Use Reusable Rule with Dynamic Parameters Source: https://testrigor.com/docs/language Example of creating a reusable rule that accepts dynamic parameters. The parameters are defined within quotes in the rule name and used as variables within the steps. ```testRigor search "product" click on the link and then press "button" ``` ```testRigor enter stored value "product" into "search" click link stored value "product" click stored value "button" ``` ```testRigor search "Computer" click on the link and then press "Add to Cart" ``` -------------------------------- ### Generate Unique Phone Number with Simple Template Source: https://testrigor.com/docs/simple-template Use the 'generate from template' command to create unique data based on a specified pattern. This example shows how to generate a phone number. ```testRigor generate from template "###-555-####", then enter into "Phone" and save as "generatedPhone" ``` -------------------------------- ### Call API with Dynamic Body Parameters Source: https://testrigor.com/docs/language Utilize parameters within the request body, including dynamic values referenced by variables. The body content, which can include parameters, starts after 'body from the string with parameters text starting from next line' and ends with '[END]'. ```testRigor call api post from the string with parameters "${homePrefix}/api/v1/create" with headers "Content-Type:application/json" and "Accept:application/json" and body from the string with parameters text starting from next line and ending with [END] { "param": "value", "param2": "${dynamicValue}" } [END] and get "$.data.name" and save it as "createdName" ``` -------------------------------- ### Natural Language Element Interaction Example Source: https://testrigor.com/docs/advanced Demonstrates a complex natural language command to click an element within a specific table context, using saved values for row identification. ```natural-language click on the first button "delete" or "remove" in the context of the first table "visible" at the row containing saved value "generatedId" and column "actions" ``` -------------------------------- ### Select books from index 2 to the end using JSONPath slice Source: https://testrigor.com/docs/json-path Array slicing syntax `[start:]` selects elements from the specified index (inclusive) to the end of the array. This selects the third book onwards. ```jsonpath $..book[2:] ``` -------------------------------- ### Basic Regex Random Data Generation Source: https://testrigor.com/docs/regex-support A template for generating random data using regex. This specific example is for generating an email address, but the pattern can be adapted for other data types. ```testRigor generate by regex "", then enter into "Email" and save as "newEmail" ``` -------------------------------- ### JsonPath Bracket-Notation Example Source: https://testrigor.com/docs/json-path Use bracket-notation for accessing JSON elements, which is an alternative to dot-notation. It is particularly useful when property names contain special characters or spaces. ```jsonpath $['store']['book'][0]['title'] ``` -------------------------------- ### Get the number of books using JSONPath length function Source: https://testrigor.com/docs/json-path The `length()` function can be applied to arrays to get the number of elements. This returns the count of books. ```jsonpath $..book.length() ``` -------------------------------- ### Basic testRigor Commands Source: https://testrigor.com/docs/language Demonstrates fundamental testRigor commands for interacting with web elements. Use these for common actions like clicking buttons and entering text into fields. ```English click "Submit" ``` ```English enter "Peter" into "First Name" ``` ```English check that page contains "Welcome, Peter!" ``` -------------------------------- ### Using Pre-defined Variables Source: https://testrigor.com/docs/language Demonstrates the usage of various pre-defined variables for entering and opening values. These variables cover user credentials, date and time components, and URL parts. ```testRigor enter stored value "username" into "Email" ``` ```testRigor enter stored value "password" into "Password" ``` ```testRigor open URL from string with parameters "https://${homeDomain}/cart/checkout/confirm" ``` ```testRigor open URL from string with parameters "https://www.example.com${homeFile}" ``` ```testRigor open URL from string with parameters "${homePrefix}/cart/checkout/confirm" ``` ```testRigor enter stored value "todayYear" into "YYYY" ``` ```testRigor enter stored value "todayYearShort" into "Year" ``` ```testRigor enter stored value "todayMonthNumber" into "Month" ``` ```testRigor enter stored value "todayMonthNumberTwoDigits" into "Month" ``` ```testRigor click stored value "todayMonth" ``` ```testRigor click stored value "todayMonthShort" ``` ```testRigor enter stored value "todayDayOfMonth" into "Month" ``` ```testRigor enter stored value "todayDayOfMonthTwoDigits" into "Month" ``` ```testRigor enter stored value "todayDayOfWeek" into "Day" ``` ```testRigor enter stored value "todayDayOfWeekShort" into "Day" ``` ```testRigor select stored value "nowHour" from "Start time" ``` ```testRigor select stored value "nowHourTwoDigits" from "Start time" ``` ```testRigor select stored value "nowHourAmPm" from "Itinerary" ``` ```testRigor select stored value "nowHourTwoDigitsAmPm" from "Itinerary" ``` ```testRigor select stored value "nowAmPm" from "Time of day" ``` ```testRigor enter stored value "nowMinute" into "Start time" ``` ```testRigor enter stored value "nowMinuteTwoDigits" into "Start time" ``` ```testRigor enter stored value "nowSecond" into "Sec" ``` ```testRigor enter stored value "nowSecondTwoDigits" into "Sec" ``` ```testRigor save string with parameters "email${nowNanosecond}@testrigor-mail.com" as "newEmail" ``` ```testRigor save stored value "nowDateIso" as "currentDate" ``` ```testRigor save stored value "nowTimeIso" into "currentTime" ``` ```testRigor save stored value "nowDateTimeIso" as "currentDateTime" ``` ```testRigor save stored value "nowMillisecondsFrom1970" as "timeStamp" ``` ```testRigor save stored value "nowDateTimeRFC1123UTC" as "currentDateTime" ``` ```testRigor save stored value "nowUnixTime" as "currentUnixTime" ``` ```testRigor enter stored value "testSuiteParentFolder" into "Field Name" ``` ```testRigor enter stored value "testSuitePath" into "Field Name" ``` ```testRigor enter stored value "testSuiteName" into "Field Name" ``` ```testRigor enter stored value "testCaseName" into "Field Name" ``` ```testRigor enter stored value "testCaseExecutionLink" into "Field Name" ``` ```testRigor save stored value "currentUrl" as "url" ``` ```testRigor save stored value "browser" as "variable name" ``` ```testRigor save stored value "device" as "variable name" ``` ```testRigor save stored value "provider" as "variable name" ``` ```testRigor save stored value "os" as "variable name" ``` ```testRigor save stored value "osVersion" as "variable name" ``` ```testRigor save stored value "abi" as "variable name" ``` ```testRigor save stored value "appFileName" as "variable name" ``` -------------------------------- ### Escape Special Character Source: https://testrigor.com/docs/language Escapes the following special character. For example, to include '[' and ']' into the set of characters, specify `[ \[ \] ]`. ```testRigor generate by regex "[ \[ \] ]", then enter into "Name" and save as "name" ``` -------------------------------- ### Manage Browser Cookies Source: https://testrigor.com/docs/language Set, get, or clear browser cookies. Supports setting cookies from saved values. ```testrigor set cookie "cookie value" as "cookie-name" ``` ```testrigor set cookie from saved value "variableName" as "cookie-name" ``` ```testrigor get cookie "cookie-name" and save it as "variableName" ``` ```testrigor clear cookies ``` -------------------------------- ### Character Range Selection Source: https://testrigor.com/docs/regex-support Selects a single character randomly from a specified range of characters. The example selects any character from 'a' to 'c'. ```testRigor generate by regex "[a-c]", then enter into "Name" and save as "name" ``` -------------------------------- ### Open URL Source: https://testrigor.com/docs/language Navigates the browser to a specified URL. Ensure the domain is whitelisted in TestRigor settings. ```TestRigor open url "https://example.ai?d=" ``` -------------------------------- ### Character Set Selection Source: https://testrigor.com/docs/regex-support Selects a single character randomly from a specified set of characters. The example selects 'a', 'b', or 'c'. ```testRigor generate by regex "[abc]", then enter into "Name" and save as "name" ``` -------------------------------- ### Exact Repetitions in Regex Source: https://testrigor.com/docs/regex-support Repeats the preceding element precisely a specified number of times. The example repeats the string exactly twice. ```testRigor generate by regex "(Lakshmi ){2}", then enter into "Name" and save as "name" ``` -------------------------------- ### Grouping in Regex Source: https://testrigor.com/docs/regex-support Groups parts of a regex pattern to apply quantifiers or other operations to the entire group. This example repeats the grouped string. ```testRigor generate by regex "(Lakshmi )+", then enter into "Name" and save as "name" ``` -------------------------------- ### Using Stored Credentials Source: https://testrigor.com/docs/language Utilize special stored values 'username' and 'password' for authentication. These can be entered into corresponding fields or used by the 'login' command. ```text enter stored value "username" into "username_field" ``` ```text enter stored value "password" into "password_field" ``` -------------------------------- ### Select File Using Native Dialog Source: https://testrigor.com/docs/language Use this command to select a file via the OS's native file dialog. The file dialog must be open before executing this command. This command does not work in headless mode or when the screenshot configuration uses the browser. ```testrigor select file from stored value "myFile" using file selection dialog ``` -------------------------------- ### JsonPath Dot-Notation Example Source: https://testrigor.com/docs/json-path Use dot-notation to access elements in a JSON structure. This is a common way to traverse nested objects and arrays. ```jsonpath $.store.book[0].title ``` -------------------------------- ### Compare Audio Recording with External File Source: https://testrigor.com/docs/language Compare a saved audio recording against an external audio file (e.g., .wav) hosted at a URL for similarity percentage. This allows validation against pre-defined audio assets. ```Testrigor check that audio from "my-recording" is "85%" similar to "https://some-page.com/path-to-file" ``` -------------------------------- ### Backreference Group Source: https://testrigor.com/docs/regex-support Uses a backreference to a previously captured group (Nth group). This example generates matching opening and closing HTML tags. ```testRigor generate by regex "<(a|button)>data<\/\1>", then enter into "Code" and save as "code" ``` -------------------------------- ### Run SQL Query and Store Results Source: https://testrigor.com/docs/language Execute an SQL query and store each column's value into a separate variable, using the column name as the key. This facilitates easy access to query results. ```Testrigor run sql query "select top 1 UserID, LastName, FirstName from Users;" ``` -------------------------------- ### Escape Special Character Source: https://testrigor.com/docs/regex-support Escapes the following special character, allowing it to be treated as a literal character. This example includes literal square brackets. ```testRigor generate by regex "[[\]]", then enter into "Name" and save as "name" ``` -------------------------------- ### Login Action Source: https://testrigor.com/docs/language Performs a complex login action by identifying and executing the necessary steps. ```testRigor login ``` -------------------------------- ### Range Repetitions in Regex Source: https://testrigor.com/docs/regex-support Repeats the preceding element a number of times between a specified minimum and maximum. The example allows for one or two repetitions. ```testRigor generate by regex "(Lakshmi ){1,2}", then enter into "Name" and save as "name" ``` -------------------------------- ### Drag on canvas with offsets Source: https://testrigor.com/docs/language Allows dragging on a canvas element by specifying start and end points with pixel offsets. Useful for drawing or canvas interactions. ```testrigor drag "canvas1" with offset "0,0" to "canvas1" with offset "50,50" ``` -------------------------------- ### Run SQL Query on CSV File Source: https://testrigor.com/docs/language Execute SQL queries directly on a CSV file after it has been downloaded. This allows for data analysis and manipulation of tabular data stored in CSV format. ```Testrigor click "download" on the right of "Pokemons.csv" check that file "Pokemons.csv" was downloaded run sql query "select Type from Pokemons;" using file "Pokemons.csv" ``` -------------------------------- ### File Download and Validation Source: https://testrigor.com/docs/language Commands to download a file and then validate its content, including checking column value counts within the downloaded file. ```testRigor click button "Download sample xlsx file" check that file "file_example_XLSX_50.xlsx" was downloaded check that file "file_example_XLSX_50.xlsx" at column "Id" the value count is greater than "2" ``` -------------------------------- ### Generate Alphanumeric Data with Date Prefix Source: https://testrigor.com/docs/simple-template Generate random alphanumeric data that starts with the current date and time in ISO format, followed by random characters. ```gherkin generate from template by string with escaped parameters "${nowDateTimeIso}-**********", then enter into "Data" and save as "generatedData" ``` -------------------------------- ### Manage Browser Session and Local Storage Source: https://testrigor.com/docs/language Set, get, or clear items in browser's sessionStorage and localStorage. Supports saving retrieved items into variables. ```testrigor set item "item-data" in sessionstorage as "item-name" ``` ```testrigor get item "item-name" from session storage and save it as "varName" ``` ```testrigor clear sessionstorage ``` ```testrigor set item "item-data" in localstorage as "item-name" ``` ```testrigor get item "item-name" from local storage and save it as "varName" ``` ```testrigor clear localstorage ``` -------------------------------- ### Call API endpoint Source: https://testrigor.com/docs/language Makes an HTTP request to a specified API endpoint. Supports GET, POST, and other methods with custom headers, body, and response parsing. ```testrigor call api "https://example.ai/api" and save it as "result" ``` ```testrigor call api post "http://dummy.restapiexample.com/api/v1/create" with headers "Content-Type:application/json" and "Accept:application/json" and body "{\"name\":\"James\",\"salary\":\"123\",\"age\":\"32\"}" and get "$.data.name" and save it as "createdName" ``` -------------------------------- ### Enter Text and Special Keys Source: https://testrigor.com/docs/language Use the 'enter' command to input text, select options from dropdowns, or interact with checkboxes. For multi-line inputs, use a delimiter like '[END]'. AI can assist in locating elements. ```testrigor enter stored value "actionNotes" into 3rd "Notes" ``` ```testrigor enter "1" into "my_checkbox" ``` ```testrigor enter enter into "Notes" ``` ```testrigor enter text starting from next line and ending with [END] line1 line2[END] into "Notes" ``` ```testrigor select "code or value" from "MySelect" ``` ```testrigor enter "kindle" into "search bar" using AI ``` ```testrigor select 1st option from "MySelect" ``` ```testrigor select second option from "MySelect" ``` ```testrigor select option 10 from "MySelect" ``` -------------------------------- ### Basic JsonPath Dot and Bracket Notation Source: https://testrigor.com/docs/language Illustrates the two primary ways to access elements in a JSON structure using JsonPath: dot notation and bracket notation. ```jsonpath $.store.book[0].title ``` ```jsonpath $['store']['book'][0]['title'] ``` -------------------------------- ### Generic Indexes for Element Referencing Source: https://testrigor.com/docs/language Use generic indexes when multiple instances of the same element exist on the page to target a specific one. For example, 'second' or '2nd'. ```testRigor check that second "peter" color is "ffaabb" ``` ```testRigor check that 2nd "peter" color is "ffaabb" ``` -------------------------------- ### Play Audio from Test Data Reference Source: https://testrigor.com/docs/language Play audio that has been referenced within the test data. This allows for playing pre-loaded or managed audio assets. ```Testrigor play audio "test-data-ref" ``` -------------------------------- ### Send a Simple Email Source: https://testrigor.com/docs/language Use this command to send a basic email with a subject and body. Ensure the recipient's email address is valid. ```testRigor send email to "user@customer.com" with subject "Test message" and body "Hi, this is a test, this is just a test message." ``` -------------------------------- ### Execute JavaScript in Browser Source: https://testrigor.com/docs/language Executes vanilla JavaScript code directly within the browser. The code block starts after the command and ends with a specified delimiter like '[END]'. ```javascript execute JavaScript in the browser text starting from next line and ending with [END] document.querySelector("#input1").value = "John Doe"; [END] ``` -------------------------------- ### Compare Audio Recordings Source: https://testrigor.com/docs/language Compare a previously saved audio recording against another saved recording for similarity percentage. This is useful for verifying audio playback consistency. ```Testrigor check that audio from "my-recording" is "70%" similar to "my-specific-recording" ``` -------------------------------- ### Execute Multiple Commands Conditionally Source: https://testrigor.com/docs/language Use 'if' blocks to execute a sequence of commands when a condition is met. This is useful for complex test steps. ```testrigor if page contains "bla" then click "element" wait 10 sec enter "some text" into "some other element" end ``` -------------------------------- ### Switch Browser/Device/Remote Desktop Context Source: https://testrigor.com/docs/language Switches the active context to a specific browser, device, or remote desktop session. 'default' typically refers to the initial or primary session. ```testRigor switch to browser "User 2" ``` ```testRigor switch to device "User 2" ``` ```testRigor switch to browser "default" ``` ```testRigor switch to remote desktop "default" ``` -------------------------------- ### Fill All Fields Commands Source: https://testrigor.com/docs/language Commands to fill all fields on a form. Options include filling all, only required, only empty, or both, with support for generated values, sample values, AI for unrecognized fields, or skipping unrecognized fields. ```testRigor fill out all fields ``` ```testRigor fill out all required fields ``` ```testRigor fill out all empty fields ``` ```testRigor fill out all empty and required fields ``` ```testRigor fill out all fields with generated values ``` ```testRigor fill out all required fields with sample values ``` ```testRigor fill out all empty fields using ai for unrecognized fields ``` ```testRigor fill out all empty and required fields and skip unrecognized fields ``` -------------------------------- ### Accept Browser Prompt Source: https://testrigor.com/docs/language Accepts a browser prompt (like an alert or confirmation dialog) and optionally provides a value to be entered into the prompt. ```testRigor accept prompt with value "John Doe" ``` -------------------------------- ### Play Audio from Remote File Source: https://testrigor.com/docs/language Play audio from a specified URL. The audio will be downloaded and played. This is useful for testing audio playback functionality from external sources. ```Testrigor play audio "https://some-page.com/path-to-file" ``` -------------------------------- ### Element Referencing Syntax Source: https://testrigor.com/docs/advanced This EBNF-like structure defines how commands can reference elements using natural language, including optional indices, types, and contextual references. ```pseudo-ebnf command [index] [typeOfElement] ["containing"] ["saved value" | "parameterized string"] [elementReference] ["in the context of", elementReference] ``` ```pseudo-ebnf elementReference = "elementName", {"or", elementReference} [insideTableReference] ``` ```pseudo-ebnf insideTableReference = "at" ["row", elementReference] ["column", elementReference] ``` -------------------------------- ### Select authors of all books using JSONPath Source: https://testrigor.com/docs/json-path Use `[*]` to select all elements in an array. This selects the authors of all books in the store. ```jsonpath $.store.book[*].author ``` -------------------------------- ### Grab URL Source: https://testrigor.com/docs/language Retrieves the current browser URL and stores it in a variable for later reference. ```TestRigor grab url and save it as "variableName" ``` -------------------------------- ### Call Phone Number Source: https://testrigor.com/docs/language Initiates a phone call to a specified number. The command can optionally verify if the call was picked up. ```testRigor call "+15344297154" and check it was picked up ``` ```testRigor call "+15344297154" ``` -------------------------------- ### Run SQL Query with Specific Connection Source: https://testrigor.com/docs/language Execute an SQL query against a specific named database connection. If no connection name is provided, the first configured connection is used. ```Testrigor run sql query "select top 1 UserID, LastName, FirstName from Users;" using connection "connectionName" ``` -------------------------------- ### Select all items in the store using JSONPath wildcard Source: https://testrigor.com/docs/json-path The `.*` wildcard selects all properties of an object. This selects both the books array and the bicycle object from the store. ```jsonpath $.store.* ``` -------------------------------- ### Compare Audio Recordings with Different Source: https://testrigor.com/docs/language Check if two audio recordings are different by a specified percentage. This is the inverse of the 'similar' check and can be used for negative testing. ```Testrigor check that audio from "my-recording" is "1%" different to "my-specific-recording" ``` -------------------------------- ### Element Interactions Source: https://testrigor.com/docs/language Describes how to reference elements for interaction using a structured command format, including natural language parsing and direct CSS/XPath references. ```APIDOC ## Element interactions Referencing elements is parsed using ML-based NLP, but can be thought as the following stricture in simplified Pseudo-EBNF: ``` command [index] [typeOfElement] ["containing"] ["saved value" | "parameterized string"] [elementReference] ["in the context of", elementReference] ``` Where: ``` elementReference = "elementName", {"or", elementReference} [insideTableReference] ``` Where: ``` insideTableReference = "at" ["row", elementReference] ["column", elementReference] ``` For example: ``` click on the first button "delete" or "remove" in the context of the first table "visible" at the row containing saved value "generatedId" and column "actions" ``` Or you can refer elements directly through CSS Selectors and Xpaths (DEPRECATED: WILL BE REMOVED BY THE END OF 2025): ``` click XPath "https://example.com/html/body/div[3]" ``` Or: ``` click CSS Selector "a[target=_blank]" ``` ``` -------------------------------- ### Check Page for Regex Match Source: https://testrigor.com/docs/regex-support Use this command to verify if a specific regex pattern exists on the current page. Ensure the regex syntax is compatible with Java 11's Pattern. ```testRigor check that page has regex "Current time: [0-2][0-9]:[0-5][0-9]" ``` -------------------------------- ### Call API with Headers, Body, and Response Handling Source: https://testrigor.com/docs/language Use this command to make an API call with custom headers and body, optionally extracting a specific part of the JSON response into a variable. The 'JsonPath' parameter is optional, but if provided, 'variableName' becomes mandatory. ```testRigor call api "" with headers "a:a" and "b:b" and body "body" and get "JsonPath" and save it as "variableName" ``` ```testRigor call api post "http://dummy.restapiexample.com/api/v1/create" with headers "Content-Type:application/json" and "Accept:application/json" and body "{\"name\":\"James\",\"salary\":\"123\",\"age\":\"32\"}" and get "$.data.name" and save it as "createdName" and then check that http code is 200 ``` ```testRigor call api "api" and save it as "variableName" ``` -------------------------------- ### Basic Regex Generation Source: https://testrigor.com/docs/regex-support Use this syntax to generate random strings based on a specified regex pattern. The generated string is then entered into a named field. ```testRigor generate by regex "[A-Z][a-z]{2,50}", then enter into "Name" and save as "generatedName" ``` -------------------------------- ### Send Email with Attachment from URL Source: https://testrigor.com/docs/language Attach a file to an email by providing a downloadable URL. The URL must be publicly accessible. ```testRigor send email from "sender@customer.com" to "recipient@customer.com" with subject "Test message", and body "Hi, this is a test, this is just a test message.", and attachment "http://online.com/file/name.pdf" ``` -------------------------------- ### Generate Custom Data from Templates Source: https://testrigor.com/docs/language Utilize the 'generate from template' command to create data matching specific formats, such as custom emails, phone numbers, SSNs, credit cards, URLs, and alphanumeric strings. Some templates can include dynamic elements like current date-time. ```testRigor generate from template "$******************************@testrigor-mail.com", then enter into "Email" and save as "newEmail" ``` ```testRigor generate from template "###-###-####", then enter into "Phone" and save as "generatedPhone" ``` ```testRigor generate from template "811-###-####", then enter into "Phone" and save as "generatedPhone" ``` ```testRigor generate from template "000-##-####", then enter into "SSN" and save as "generatedSsn" ``` ```testRigor generate from template "4###-####-####-####", then enter into "card" and save as "generatedCard" ``` ```testRigor generate from template "https://$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.info", then enter into "url" and save as "generatedUrl" ``` ```testRigor generate from template "%******************************", then enter into "data" and save as "generatedData" ``` ```testRigor generate from template by string with escaped parameters "${nowDateTimeIso}-**********", then enter into "Data" and save as "generatedData" ``` ```testRigor generate from template "%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.", then enter into "description" and save as "generatedDescription" ``` -------------------------------- ### Upload File Source: https://testrigor.com/docs/language Uploads a file to a specified URL using FTP, FTPS, or SFTP protocols. Files can be sourced from stored values, templates, or directly from a device. ```TestRigor upload file from stored value "file.txt" to "sftp://example.com/file.txt" using username "user" and password from stored value "sftp_password" ``` ```TestRigor upload file from template stored value "template.json" to "sftp://example.com/default.json" using username "user" and password from stored value "sftp_password" ``` ```TestRigor upload file "https://some-page.com/avatar.jpeg" to device ``` -------------------------------- ### Take a Screenshot Source: https://testrigor.com/docs/language Capture a screenshot at any point during the test execution to aid in debugging or documentation. ```testrigor take screenshot ``` -------------------------------- ### Upload Template Files Source: https://testrigor.com/docs/language Allows uploading files with parameterized content, such as CSV or TXT files, where variables like ${nowDateIso} can be substituted. Use the 'template' keyword to enable this functionality for stored values or URLs. ```testRigor enter template stored value "keyName" into input file "fileField" ``` ```testRigor enter template "" into file input "fileField" ``` -------------------------------- ### Upload Multiple Files Source: https://testrigor.com/docs/language This command is used to upload multiple files into a single file input field. It supports referencing files by stored values or URLs, and requires a specific delimiter to separate file references. ```testRigor enter from the string with parameters text starting from next line and ending with [END] ${file_var_one} [END] into file input "myFileInput" ``` -------------------------------- ### Compare Element or Screen Images Source: https://testrigor.com/docs/language Compare visual elements or the entire screen against previous runs or saved screenshots. Allows for a tolerance percentage for minor differences. ```testRigor compare image of "my_div" to previous version with allowance of "5%" ``` ```testRigor compare screen to previous version ``` ```testRigor compare screen to previous version with allowance of "5%" treating error as "minor" ``` ```testRigor compare screen to stored value "Saved Screenshot" treating error as "minor" ``` -------------------------------- ### Handle Downloaded Files for Upload Source: https://testrigor.com/docs/language Save downloaded files to a variable for later use, such as uploading them to another part of the application. ```testRigor check that file was downloaded and save it as "DownloadedFiles" ``` ```testRigor enter stored value "DownloadedFiles" into "upload-image" ``` -------------------------------- ### Execute XPath Command Source: https://testrigor.com/docs/language Use XPath to locate and interact with elements. This method is deprecated and will be removed by the end of 2025. ```pseudo click XPath "https://example.com/html/body/div[3]" ``` -------------------------------- ### Run No-SQL Query with Specific Connection Source: https://testrigor.com/docs/language Execute a No-SQL query against a specific named database connection. This allows for interacting with non-relational databases. ```Testrigor run no-sql query "" using connection "anotherConnectionName" ``` -------------------------------- ### General Regex Random Data Generation Command Source: https://testrigor.com/docs/language A general template for generating random data using regex. Replace '' with the desired regular expression pattern. The generated data is then entered into a specified UI element and saved. ```testRigor generate by regex "", then enter into "Email" and save as "newEmail" ``` -------------------------------- ### Drag file onto element Source: https://testrigor.com/docs/language Simulates dragging a file from a URL or a saved value onto a target element. Ensure the file is correctly referenced. ```testrigor drag file "" onto "element" ``` ```testrigor drag file from saved value "File to upload" onto "element" ``` -------------------------------- ### Execute JavaScript with testRigor Commands Source: https://testrigor.com/docs/advanced Use JavaScript to interact with testRigor's stored values and execute commands. Ensure the JavaScript code is terminated with '[END]'. ```javascript store value "hello" as "var1" execute JavaScript text starting from next line and ending with [END] if (testRigor.hasStoredValue("var1")) { testRigor.execute('enter stored value "var1" into "Message"'); } testRigor.execute('click "Update"'); testRigor.execute('check that page contains text from stored value "var1"'); [END] ``` -------------------------------- ### Download File Source: https://testrigor.com/docs/language Downloads a file from a given URL. Supports HTTP, HTTPS, FTP, FTPS, and SFTP protocols. Authentication can be embedded in the URL or provided separately. ```TestRigor download file "https://example.com/robots.txt" check that file was downloaded check that downloaded file contains "Sitemap" ``` ```TestRigor download file "ftp://user:password@example.com/file.txt" ``` ```TestRigor download file "ftp://example.com/file.txt" using username "user" and password from stored value "ftp_password" ``` -------------------------------- ### Take Screenshot Source: https://testrigor.com/docs/language Captures a screenshot at any point during the test case execution. ```APIDOC ## Take Screenshot ### Description Captures a screenshot at any point during the test case execution. ### Method `take screenshot` ### Example ```apidoc take screenshot ``` ``` -------------------------------- ### Execute Action Until Condition Met Source: https://testrigor.com/docs/language Use 'until' to repeat an action until a condition is true. This is useful for paginating through lists or waiting for specific elements. ```testRigor click "Next" until page contains stored value "previously generated id" ``` -------------------------------- ### Reset and Restart Application Source: https://testrigor.com/docs/language Reset the application to its home state or restart the application without clearing data. The restart action is mobile-specific. ```testRigor reset to home ``` ```testRigor restart app ``` -------------------------------- ### Match URL with Regex Source: https://testrigor.com/docs/regex-support Validate if the current URL conforms to a specified regex pattern. This is helpful for ensuring correct navigation or API endpoint matching. ```testRigor check that URL matches regex "https://mycompany\.com/list/item/[a-z0-9]{2,30}" ``` -------------------------------- ### Execute Action with Max Retries Until Condition Met Source: https://testrigor.com/docs/language Extend the default 10 retries by specifying 'up to' a number of times. This prevents infinite loops and sets a limit for the condition check. ```testRigor click "Next" up to 12 times until page contains strictly button "Place order" ``` -------------------------------- ### Salesforce Built-in Rules Source: https://testrigor.com/docs/language These rules are available when a suite URL is detected as Salesforce. They cover navigation, creation, editing, and deletion of Salesforce objects. ```testRigor navigate to "object name" using app launcher ``` ```testRigor ensure we are on the "object name" page ``` ```testRigor create new "object name" ``` ```testRigor open list actions for "object name" ``` ```testRigor edit list item "object name" ``` ```testRigor delete list item "object name" ``` ```testRigor change owner of list item "object name" ``` ```testRigor edit labels of list item "object name" ``` ```testRigor search this list for "text" ``` ```testRigor validate that list contains "n" items ``` ```testRigor search for "text" of type "object type" and open ``` ```testRigor verify that object containing "text" of type "object type" exists ``` ```testRigor verify that object containing "text" of type "object type" doesn't exist ``` ```testRigor open edit for "value" in the table ``` ```testRigor change value on the table from "old value" to "new value" ``` ```testRigor pick "value" from "field name" in Salesforce ``` ```testRigor search and pick "value" from "field name" in Salesforce ``` -------------------------------- ### Select books cheaper than 10 using JSONPath filter Source: https://testrigor.com/docs/json-path Filter expressions `[?(@.key < value)]` select elements based on a condition. This selects books whose price is less than 10. ```jsonpath $.store.book[?(@.price < 10)] ``` -------------------------------- ### Manage Browser User Agent Source: https://testrigor.com/docs/language Set a custom user agent string or unset it to revert to the default. ```testrigor set user agent to "My User Agent" ``` ```testrigor unset user agent ``` -------------------------------- ### Type Free Text into Fields Source: https://testrigor.com/docs/language The 'type' command is for free-form text input, especially when the cursor is already in the desired field. It also supports multi-line input and pressing individual keyboard keys. ```testrigor click on "Notes" type "This is a test." ``` ```testrigor click on "Notes" type text starting from next line and ending with [END] line1 line2 line3[END] ``` ```testrigor type enter ``` ```testrigor type arrow right ``` -------------------------------- ### Case-Sensitive and Exact String Matching Source: https://testrigor.com/docs/language Use 'exactly' for case-sensitive, full string matches. This can be combined with strict type selection for more precise targeting. ```text click on exactly "Delete" ``` ```text click on strictly button exactly "Delete" ``` -------------------------------- ### Run SQL Insert Statement Source: https://testrigor.com/docs/language Execute an SQL INSERT statement to add new data into a database table. This is a fundamental operation for populating or modifying database records. ```Testrigor run sql query "insert into Users(UserID, FirstName, LastName) values (3, 'Jon', 'Doe');" ``` -------------------------------- ### Visual Screen Comparison Source: https://testrigor.com/docs/language Compare the current screen against a previous version or a stored screenshot. Allows for specifying tolerance for minor differences and error severity. ```typescript compare screen ``` ```typescript compare screenshot to previous version ``` ```typescript compare screen to previous version with allowance of "1%" treating error as "minor" ``` ```typescript compare screen to previous version treating error as "minor" ``` ```typescript compare screen to stored value "Saved Screenshot" ``` -------------------------------- ### Fill Form Commands Source: https://testrigor.com/docs/language Commands to fill form fields. Specify which fields to fill (required, empty, or all) and optionally identify the form or element. ```testRigor fill out form ``` ```testRigor fill out required fields in form ``` ```testRigor fill out the rest of the form ``` ```testRigor fill out the rest of the required fields in form ``` ```testRigor fill out form "form" ``` ```testRigor fill out form identified by field "element" ``` ```testRigor fill out form "form" with generated values ``` ```testRigor fill out required fields in form "form" with sample values ``` ```testRigor fill out the rest of the form identified by field "element" using ai for unrecognized fields ``` ```testRigor fill out the rest of the required fields in form identified by field "element" and skip unrecognized fields ``` -------------------------------- ### Add One-Line Comments Source: https://testrigor.com/docs/language Add single-line comments to test steps using '//'. Useful for explaining cryptic button names or complex steps. ```testrigor click "my-cryptic-button" // actually clicks "add to cart" ``` -------------------------------- ### Direct XPath Element Interaction Source: https://testrigor.com/docs/advanced Shows how to directly target an element using its XPath for precise selection in test automation. ```testrigor-commands click XPath "/html/body/div[3]" ``` -------------------------------- ### Select the first two books using JSONPath multiple indices Source: https://testrigor.com/docs/json-path Multiple indices can be specified within square brackets to select specific array elements. This selects the first and second books. ```jsonpath $..book[0,1] ``` -------------------------------- ### Grab Value from Element Source: https://testrigor.com/docs/language Use this command to extract text content from a specified element on the page and store it in a variable. It supports basic element selection, AI-based description matching, and attribute/CSS property extraction. ```TestRigor grab value from "element" and save it as "variableName" ``` ```TestRigor grab value of "(?<=UserName\:)[^ ]+" and save it as "generatedUsername" ``` ```TestRigor grab value of "(?<=UserName\:)[^ ]+" from "generated_section" and save it as "generatedUsername" ``` ```TestRigor grab value by template "(###) ###-####" and save it as "phoneNumber" ``` ```TestRigor grab value by template "(###) ###-####" from element below "Phone" and save it as "phoneNumber" ``` ```TestRigor grab value of attribute "href" from "element" and save it as "variableName" ``` ```TestRigor grab value of css property "width" from "element" and save it as "variableName" ``` ```TestRigor grab value by description "10-digit phone number" using AI and save it as "phoneNumber" ``` ```TestRigor grab value by description "10-digit phone number" from "Contact form" using AI and save it as "phoneNumber" ``` -------------------------------- ### Select the third book using JSONPath index Source: https://testrigor.com/docs/json-path Array elements can be accessed by their zero-based index. This selects the third book from the `book` array. ```jsonpath $..book[2] ``` -------------------------------- ### Manage Browser Tabs Source: https://testrigor.com/docs/language Commands to open new tabs, switch between existing tabs using their number or name, and close the current tab. ```testRigor open new tab ``` ```testRigor switch to tab 3 ``` ```testRigor switch to tab "popup" ``` ```testRigor close tab ``` -------------------------------- ### Perform mobile gestures and actions Source: https://testrigor.com/docs/language Execute mobile-specific commands like pressing the home or recent apps button. These commands are essential for navigating mobile applications. ```TestRigor DSL press home click home press home button click home button ``` ```TestRigor DSL press recent click recent press recent button click recent button ```