Introduction

QForce is a Robot Framework testing library for Salesforce cloud.

This document contains all keywords that have been specifically added for Salesforce.

In addition the QForce library includes ALL keywords from our generic web testing library, QWeb

You DO NOT need to import QWeb separately.

QForce contains both Web/UI level keywords and REST API keywords. REST API keywords are listed under REST_API tag.

Keywords

Arguments

quote_model product_models group_key
= 0
timeout
= None

Documentation

Adds products with ProductModels to a QuoteModel https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_api_add_products.htm

NOTE: Authentication has to be done once before calling this keyword.

Examples

${cpq_quote_model}=    Read CPQ Quote      ${quote_id}
${cpq_product}=        Read CPQ Product    ${product_id}[records][0][Id]    ${pricebook_id}[records][0][Id]    USD
${quote_with_product}=  Add CPQ Products  ${cpq_quote_model}    ${cpq_product}

Parameters

quote_model : str/dict
Quote Model (json/dict) of quote to which add products.
product_models : str/dict
Product model(s) of products to be added to quote.
group_key : int
An index of the existing quote line group where youโ€™re adding products (0 indexed by default). Required only for grouped quotes.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

dict
Quote model (dictionary) of fields and values of the cpq quote, where products have been added.

Raises

ValueError
Authentication failed, quote/product model was not found, api call was malformatted.

Arguments

client_id client_secret username password sandbox
= False
custom_url
= None
timeout
= None

Tags

REST_API

Documentation

Authenticates to Salesforce REST API and sets access token which will be used in all subsequent calls.

Note

Needs a consumer key and a consumer secret from OAuth Connected App.

Basic steps to enable REST API authentication:

Precondition(s): Make sure to enable "Allow OAuth Username-Password Flows" from Settings > Identity > OAuth and OpenID Connect Settings.

  1. Create a new Connected app (Setup / App Manager -> New Connected App)
  2. Fill in Connected App Name and Contact Email
  3. Check Enable OAuth Settings
  4. Click Save and Continue
  5. Click Manage and Edit policies and relax possible ip restrictions
    • Optional, needed if used ip's are not white listed
  6. Click Manage Consumer Details
  7. Note down Consumer Key and Consumer Secret. Keep these safe!
  8. Wait about 10 minutes for oauth settings to take place.
  9. Use Consumer Key and Consumer secret together with username and password to authenticate.

More information in Salesforce documentation: Defining Connected Apps

Examples

Authenticate     ${client_id}   ${client_secret}   myusername@test.com    ${password}

# Authenticate to sandbox (can be accessed via https://test.salesforce.com)
Authenticate     ${client_id}   ${client_secret}   myusername@test.com    ${password}   sandbox=True

# Authenticate with custom url
Authenticate     ${client_id}   ${client_secret}   jdoe@test.com    ${password}   custom_url=https://someurl.com

# Authenticate and reuse access token in 3rd party library
Import      QForce
Import      RequestsLibrary
# you can also get the token using GetAccessToken keyword
${token}=                 Authenticate     ${client_id}   ${client_secret}   jdoe@test.com    ${password}
${my_acc}=                Create Record               Account             Name=My Account      NumberOfEmployees=83
${api_version_url}=       Get API Version Url
${instance_url}=          Get Instance Url
# Call SF Rest API using RequestsLibrary keyword and token from QForce Authenticate
&{headers}=               Create Dictionary  Authorization=Bearer ${token}
${resp}=                  GET                url=${instance_url}${api_version_url}/sobjects/Account/${my_acc}
...                       headers=&{headers}  timeout=10
Log                       ${resp.json()}  console=true
Should Be Equal           ${resp.json()}[Name]  My Account
Should Be Equal           ${resp.json()}[Id]    ${my_acc}

Parameters

client_id : str
Consumer key of a connected app
client_secret : str
Consumer secret of a connected app
username : str
Your Salesforce username
password : str
Your Salesforce password
sandbox : bool (optional)

Is the instance a sandbox instance? This flag will set login url accordingly, either login.salesforce.com or test.salesforce.com (sandbox). Default: False (-> login.salesforce.com)

You can find out if your environment is a sandbox by trying to login with your credentials through https://login.salesforce.com and https://test.salesforce.com. If you can login through https://login.salesforce.com then your environment is NOT a sandbox and if you can login through https://test.salesforce.com then your environment is a sandbox.

custom_url : str (optional)
Custom instance url in cases where you can login only using custom url, not the default Salesforce urls mentioned above. If custom_url is given, sandbox will be ignored.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

token
Access token to be used in all subsequent calls. Note this value is automatically used in QForce keywords, but returned in case you want to use the same authentication token with a custom call with other libraries.

Raises

ConnectionError
Authentication call was not successful.
KeyError
Reply did not contain expected data.

Arguments

quote_model timeout
= None

Documentation

Calculates quote with the given QuoteModel and returns an updated QuoteModel https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_quote_api_calculate_final.htm

NOTE: Authentication has to be done once before calling this keyword

Examples

${cpq_quote}=           Read CPQ Quote         a2w7Q000000LBGRQA4
${calculated_quote}=    Calculate CPQ Quote    ${cpq_quote}

Parameters

quote_model : str
Quote Model (json/dict) of quote to be calculated. TIP: Use "CPQ Read Quote" to get the quote model.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

dict
Quote model (dictionary) of fields and values of the calculated cpq quote

Raises

ValueError
Authentication failed, quote was not found, api call was malformatted.

Arguments

sobject additional_headers
= None
timeout
= None
** data

Documentation

Creates a new record to Salesforce instance.

NOTE: Authentication has to be done once before calling this keyword

Examples

${contact}=      Create Record   Contact    FirstName=Jane    LastName=Doe
${account}=      Create Record   Account    Name=KindCorp     BillingPostalCode=12345

# if duplicate check rule is on, you can give additional headers:

# works with string header
${account2}=     Create Record   Account    Name=KindCorp     BillingPostalCode=12345    additional_headers={"Sforce-Duplicate-Rule-Header": "allowSave=true"}
# works with dict header
&{headers_dict} =               Create Dictionary               Sforce-Duplicate-Rule-Header=allowSave=true
${account3}=     Create Record   Account    Name=KindCorp     BillingPostalCode=12345    additional_headers=${headers_dict}

Parameters

sobject : str
Salesforce object type. You can use keyword "List Objects" to get names of all Salesforce objects.
additional_headers : str/dict
Additional headers which will be appended to auth/content-type header. See examples.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)
**data: str
Fields and values for the new record. You must specify values for required fields as part of the data. Specifying values for other fields is optional.

Returns

id : str
Id of the newly created record.

Raises

ValueError
Authentication failed, record was not found or api call was malformatted.

Arguments

sobject oid timeout
= None

Documentation

Deletes a record from Salesforce instance.

NOTE: Authentication has to be done once before calling this keyword

Examples

${contact}=      Create Record  Contact            FirstName=Jane         LastName=Doe
${account}=      Create Record  Account            Name=KindCorp
Delete Record    Contact        ${contact}
Delete Record    Account        ${account}
Delete Record    Account        0015E000024YyV0QAK

Parameters

sobject : str
Salesforce object type. You can use keyword "List Objects" to get names of all Salesforce objects.
oid: str
ID of the record to be deleted
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Raises

ValueError
Authentication failed, record was not found or api call was malformatted.

Arguments

script is_file
= False
timeout
= None

Documentation

Executes an anonymous Apex script. Script can be given as a file or as string. The action done by Apex script needs to be verified with other keywords. This keyword verifies that the API call is successful, Apex script is successfully compiled and run.

Returns the return value from API call in json format.

NOTE: Authentication has to be done once before calling this keyword

Examples

${results}=     Execute Apex      Account newAccount = new Account();\nnewAccount.Name = String.valueOf(Date.today());\ninsert newAccount;
${results}=     Execute Apex      my_script.apex    is_file=True

Parameters

script : str
Apex script as a string or path to a file containing the script.
is_file : bool
False (default): Apex script is given as string True: Apex script is stored in a file. Filepath should be given in first argument.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

dict
dictionary of fields and values of the queried object

Raises

ValueError
Authentication failed, record was not found or api call was malformatted.

Arguments

query output_file timeout
= None

Documentation

Executes a SOQL Query and saves returned records as .json file. Returns the path of a saved file.

NOTE: Authentication has to be done once before calling this keyword

Examples

${results}=     Export Records       SELECT id,name from Contact      ${OUTPUTDIR}/contacts.json

Parameters

query : str
SOQL query.
output_file : str
Full path to .json file which will be created for output. Directories must exist, file will be created.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

str
Full path to newly created file which contains query results.

Raises

ValueError
Authentication failed, record was not found or api call was malformatted.

Documentation

Gets the Access Token. This is useful when combining QForce API keywords with 3rd party library.

NOTE: Authentication has to be done once before calling this keyword

Examples

${token}=    Get Access Token

Documentation

Gets the API version used in instance. This is useful when combining QForce API keywords with 3rd party library.

NOTE: Authentication has to be done once before calling this keyword

Examples

${api_version_url}=    Get API Version URL

Documentation

"Gets the instance url after authentication. This same url should be used in all subsequent API calls. This is useful when combining QForce API keywords with 3rd party library.

NOTE: Authentication has to be done once before calling this keyword

Examples

${instance_url}=    Get Instance URL

Arguments

sobject oid timeout
= None

Documentation

Authenticates to Salesforce REST API and sets access token which will be used in all subsequent calls

NOTE: Authentication has to be done once before calling this keyword

Examples

Authenticate     ${client_id}   ${client_secret}   myusername@test.com    ${password}
${account}=      Get Record     Account            0015E00001TyR6mQAF
Should Be Equal As Strings     ${account}[Name]               Corporation

Parameters

sobject : str
Salesforce object type. You can use keyword "List Objects" to get names of all Salesforce objects.
oid: str
Salesforce object id
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

dict
dictionary of fields and values of the queried object

Raises

ValueError
Authentication failed, record was not found or api call was malformatted.

Arguments

sobject file additional_headers
= None
timeout
= None

Documentation

Creates multiple records defined in .json file.

Returns a json format response including id's of created objects.

NOTE: Authentication has to be done once before calling this keyword

Example .json file content (new_records.json)

{
    "records" :[{
        "attributes" : {"type" : "Account", "referenceId" : "ref1"},
        "name" : "SampleAccount1",
        "phone" : "1111111111",
        "website" : "www.salesforce.com",
        "numberOfEmployees" : "100",
        "industry" : "Banking"
        },{
        "attributes" : {"type" : "Account", "referenceId" : "ref2"},
        "name" : "SampleAccount2",
        "phone" : "2222222222",
        "website" : "www.salesforce2.com",
        "numberOfEmployees" : "250",
        "industry" : "Banking"
        },{
        "attributes" : {"type" : "Account", "referenceId" : "ref3"},
        "name" : "SampleAccount3",
        "phone" : "3333333333",
        "website" : "www.salesforce3.com",
        "numberOfEmployees" : "52000",
        "industry" : "Banking"
        },{
        "attributes" : {"type" : "Account", "referenceId" : "ref4"},
        "name" : "SampleAccount4",
        "phone" : "4444444444",
        "website" : "www.salesforce4.com",
        "numberOfEmployees" : "2500",
        "industry" : "Banking"
        }]
    }

Example Test Script

# using .json in test script
${json}=      Import Records   Account    ${CURDIR}/resources/new_records.json

# Get id's from response
${id1}=                  Set Variable                ${json}[results][0][id]
${id2}=                  Set Variable                ${json}[results][1][id]
${id3}=                  Set Variable                ${json}[results][2][id]
${id4}=                  Set Variable                ${json}[results][3][id]

# can also get all id's to list at once like this
@{created_ids}=             Evaluate                   [x['id'] for x in $json['results']]

Parameters

sobject : str
Salesforce object type. You can use keyword "List Objects" to get names of all Salesforce objects.
file : str
Full path to .json file describing the objects to be created.
additional_headers : str/dict
Additional headers which will be appended to auth/content-type header. See examples.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

id : str
Id of the newly created record.

Raises

ValueError
Authentication failed, record was not found or api call was malformatted.

Arguments

timeout
= None

Documentation

Lists all available sObjects.

Examples

ListObjects

Parameters

timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Arguments

query timeout
= None

Documentation

Executes a SOQL Query. See: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm

NOTE: Authentication has to be done once before calling this keyword

Examples

${results}=     QueryRecords       SELECT id,name from Contact WHERE name LIKE 'John%'

Parameters

query : str
SOQL query.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

dict
dictionary of fields and values of the queried object

Raises

ValueError
Authentication failed, record was not found or api call was malformatted.

Arguments

product_id pricebook_id currency_code
= USD
timeout
= None

Documentation

Retrieves a ProductModel from Salesforce with product id and pricebook id https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_api_read_product.htm

NOTE: Authentication has to be done once before calling this keyword.

Examples

${product_id}=      Query Records    query=Select Id FROM Product2 WHERE Name='SLA: Gold'
${pricebook_id}=    Query Records    query=Select Id FROM Pricebook2 WHERE IsStandard=True
${cpq_product}=     Read CPQ Product    ${product_id}[records][0][Id]    ${pricebook_id}[records][0][Id]    USD

Parameters

product_id : str
Product Id.
pricebook_id : str
Pricebook Id.
quote_model : str
The ISO code of a Salesforce currency where the productโ€™s price is loaded. Required only for multi-currency orgs. Default: USD.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

dict
Product model (dictionary) of fields and values of the cpq product.

Raises

ValueError
Authentication failed, quote was not found, api call was malformatted.

Arguments

quote_id timeout
= None

Documentation

Retrieves a QuoteModel from Salesforce with a quote id https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_api_read_quote.htm

NOTE: Authentication has to be done once before calling this keyword

Examples

${cpq_quote}=      Read CPQ Quote    a2w7Q000000LBGRQA4

Parameters

quote_id : str
Id of the CPQ Quote
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

dict
dictionary of fields and values of the queried cpq quote

Raises

ValueError
Authentication failed, quote was not found, api call was malformatted.

Arguments

timeout
= None

Tags

REST_API

Documentation

Revokes authentication token. You need to call Authenticate again to continue using the Salesforce REST API keywrods

More information in Salesforce documentation: Defining Connected Apps

Examples

Authenticate     ${client_id}   ${client_secret}   myusername@test.com    ${password}
# do actions with API
Revoke

Parameters

timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Raises

ConnectionError
Authentication call was not successful.

Arguments

quote_model timeout
= None

Documentation

Saves QuoteModel to Salesforce https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_quote_api_save_final.htm

NOTE: Authentication has to be done once before calling this keyword.

NOTE: Save must be done before any changed are applied to CPQ quote.

Examples

${cpq_quote}=           Read CPQ Quote         a2w7Q000000LBGRQA4
${calculated_quote}=    Calculate CPQ Quote    ${cpq_quote}
${saved_quote}=         Save CPQ Quote         ${calculated_quote}

Parameters

quote_model : str
Quote Model (json/dict) of quote to be saved.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

dict
Quote model (dictionary) of fields and values of the saved cpq quote

Raises

ValueError
Authentication failed, quote was not found, api call was malformatted.

Arguments

sobject oid timeout
= None
** data

Documentation

Updates a record in Salesforce instance.

NOTE: Authentication has to be done once before calling this keyword

Examples

${contact}=      Create Record      Contact     FirstName=Jane         LastName=Doe
${account}=      Create Record      Account     Name=KindCorp

Update Record    Contact    ${contact}    FirstName=Jamie     Email=jamie.doe@fake.com

Parameters

sobject : str
Salesforce object type. You can use keyword "List Objects" to get names of all Salesforce objects.
oid: str
ID of the record to be deleted
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Raises

ValueError
Authentication failed, record was not found or api call was malformatted.

Arguments

quote_model timeout
= None

Documentation

Executes quotes validation rules for a QuoteModel https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/cpq_api_validate_quote.htm

NOTE: Authentication has to be done once before calling this keyword

Examples

${cpq_quote}=           Read CPQ Quote         a2w7Q000000LBGRQA4
${validation_errors}=   Validate CPQ Quote     ${cpq_quote}

Parameters

quote_model : str
Quote Model (json/dict) of quote to be calculated. TIP: Use "CPQ Read Quote" to get the quote model.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)

Returns

list
Returns empty list if validation was successful. If not, returns list of validation errors.

Raises

ValueError
Authentication failed, quote was not found, api call was malformatted.

Arguments

sobject oid partial_match
= False
timeout
= None
** data

Documentation

Verifies record's fields.

NOTE: Authentication has to be done once before calling this keyword

Examples

${contact}=      Create Record      Contact     FirstName=Jane         LastName=Doe
Update Record    Contact    ${contact}  FirstName=Jamie    Email=jamie.doe@fake.com
Verify Record    Contact    ${contact}  FirstName=Jamie    LastName=Doe   Email=jamie.doe@fake.com

Parameters

sobject : str
Salesforce object type. You can use keyword "List Objects" to get names of all Salesforce objects.
oid: str
ID of the record to be verified
partial_match: bool
Require full string match (default) or accept partial matches.
timeout : str | int (optional)
How long we wait for API call response before failing. Default 10 (seconds)
**data: str
Set of fieldname/expected value pairs to verify

Raises

KeyError
Given field does not exist.
ValueError
Authentication failed, record was not found, api call was malformatted or at least one of the verified fields has different value than expected.

Arguments

column row double
= False
timeout
= 0
** kwargs

Documentation

Clicks a cell in a sf_standard_table.

Examples

ClickTableCell           Quantity             3
ClickTableCell           List Unit Price      5     double=True  # double clicks field

Parameters

column : str
Column header in table.
row : str
Row number in the column.
double : str
False (default): single-click. True: double-clicks the cell.

Arguments

text anchor
= 1
timeout
= 0
parent
= None
child
= None
js
= None
recognition_mode
= web
** kwargs

Documentation

Click text on web page.

Keyword looks for an exact match and if not found uses xpath defined in Search Strategy. If the given text corresponds to multiple elements, it clicks the first element.

If you want to click other element than the first one found, you need to use anchor or index.

Keyword tries to click element until it succeeds or timeout has passed. If timeout is not specified, default timeout is used. DefaultTimeout can be adjusted with SetConfig DefaultTimeout keyword.".

You can also use computer vision engine to find texts from UI. This is useful for example in situations where text element is under shadow DOM.

Examples

ClickText        Canis

In the above example the ClickText keyword will click the word Canis. If there are multiple instances of the word Canis on the page, first one will be clicked unless 'anchor' is given. You can specific which one should be clicked by either:

  • a number or
  • a word that is near to the word Canis

For example

ClickText    Canis    3     # clicks the third "Canis" on the page
ClickText    Canis    Dog   # clicks the "Canis" near to the word "Dog"
# handling numeric anchors as text, not index
ClickText    Canis    3     anchor_type=text   # clicks the "Canis" next text "3"

If text can't be found with normal means, you can use computer vision engine instead:

# clicks the text "Canis" using computer vision engine
ClickText    Canis    recognition_mode=vision

If you want to specify how long ClickText tries, you need to add both anchor and timeout.

ClickText    Canis    1     20s   # Tries to click the first "Canis" for 20s

If clickable element is child or parent of locator element use child/parent attribute + elements tagname to pick right element

ClickText   Canis     parent=span # Clicks Canis element's first parent with span -tag
ClickText   Canis     child=a     # First childnode with a -tag
ClickText   Canis     js=true     #Use Javascript click instead of Selenium

To double-click text, use argument doubleclick=True

ClickText   Canis       doubleclick=True

Or use SetConfig

SetConfig   DoubleClick     On
ClickText   Canis

To extend normal text search to shadow DOM, use SetConfig ShadowDOM. Note that certain arguments like partial_match are ignored when searching from shadow DOM.

SetConfig   ShadowDOM     True
ClickText   Canis

Parameters

text : str
Text to be clicked.
anchor : str
Text near the element to be clicked or index. If the page contains many places where the text argument is then anchor is used to get the one that is closest to it. (default 1)
timeout : str | int
How long we wait element to appear and click to succeed
parent : str
tag name for clickable parent.
child : str
tag name for clickable child.
js : boolean
If set to true, uses javascript instead of selenium to click element.
recognition_mode : str
Use either "web" backend (default) or computer vision ("vision"). Computer vision finds texts from the screen regardless how they appear on DOM. This is useful to verify truncated ui texts and especially when elements are under shadow dom.
Accepted kwargs:
css=False/off: Use this to bypass css search when finding elements by visible text

Arguments

label expanded
= True
index
= 1
timeout
= 0
** kwargs

Documentation

Expands or closes parent element in Lightning Tree

./img/lwc_tree.png

Examples

ClickTree        Western Sales Director   # expands node, does nothing if already expanded
ClickText        CA Sales Rep  # clicks subtree node
ClickTree        Western Sales Director   False   # collapses parent Tree node "User"

Parameters

label : str
Label of the parent tree element to click
expanded : bool
True (default) expands tree node, False will close it.
index : int
If there are multiple duplicate nodes in Tree layout, index can be used to identify which one should be verified. Note: only affects partial match, see below
timeout : str
How long to wait for page header to appear. Default 0 (use the default timeout setting)
kwargs :
Accepted kwargs:
partial_match: True. If element is found by it's attribute set partial_match
to True to allow partial match

Raises

QWebElementNotFoundError
Page did not contain parent Tree node element with given name. Note: If tree node does not have children, use ClickText instead. You can't expand/collapse nodes without children.

Arguments

locator value timeout
= 0
index
= 1
selection_delay
= 1
all_results
= False
** kwargs

Documentation

Searches and selects a value from a Salesforce combobox.

NOTE: only full matches are allowed for the item/value that will be selected.

NOTE: only works for comboboxes which do have the input field available. In some cases combobox is prefilled with values and there is no input. In these cases, please remove existing values first or make the input visible by clicking one of the selected values.

Examples

Combobox        Search Accounts...      Test Account
# using label and selecting 3rd duplicated instance
Combobox        *Account Name           Test Account   index=3

Parameters

locator : str
Placeholder for combobox (preferred) or label of the field having combobox. Note that all comboboxes do not open just by clicking the label. If using label, mandatory fields need the "*" character.
value : str
Value to be searched and selected from a combobox.
timeout : str | int
How long we try to find the combobox before failing. Default: DefaultTimeout configuration value.
index : int
If there are duplicated values in the search results, index of the instance which will be selected.
selection_delay : int
The delay in seconds after typing search term and starting to select item from results list. Default: 1 second
all_results : bool
If true, does not select the value from proposed values, but clicks "Show all results for..." item and selects value from the dialog that will open.

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

label index
= 1
tag
= span
timeout
= 0

Documentation

Gets a value from Aura/Lightning recordlayout field in Salesforce. Correct field is found using label. By default text under lightning-formatted-/span tag is returned. Some salesforce texts are under non-formatted <a> tag and with these you need to use tag argument

Examples

${value}=          GetFieldValue        Phone           # returns 12345
${value}=          GetFieldValue        Notes           # returns text from Notes field

# returns non-formated text from a tag
${value}=          GetFieldValue        Quote Number    tag=a

Parameters

label : str
Label/heading of the record to verify.
index : int
If there are multiple duplicate labels in record layout, index can be used to identify which one should be verified.
timeout : str | int
Timeout for waiting element to appear before failing. Default value is what is set in "DefaultTimeout".

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

username secret url
= https://login.salesforce.com

Tags

MFA,
Utilities

Documentation

Generates one-time password as an authentication app on your mobile would. See MFA Setup

Examples

${mfa_code}=    GetOTP          my_user@testsf.com    ${MY_SECRET}
TypeText        Code            ${mfa_code}

Parameters

usenname : str
Salesforce username of the user logging in.
secret : str
Secret given by Salesforce when connecting an OTP authentication app to an account.
url : str
Salesforce instance url. Default: "https://login.salesforce.com"

Raises

ValueError
An error occurred while generating OTP. Please make sure correct details (user, secret) are used.

Setup

1.Enable OTP authentication app in your SF user settings:

./img/connect_mfa_app.png

2. Get the security code. You can hover on top of the QR code or right-click and open the image in another tab (code will be in url):

./img/mfa_security_code.png

3. FInalize the setup with you mobile authentication app and provide first code from the app.

4. Provide the security token in variable ${secret}. This should be given as encrypted variable in Copado Robotic Testing.

Arguments

label index
= 1
selected
= False
timeout
= 0
** kwargs

Documentation

Returns all or selected options available in picklist. Supports both Lightning and Aura pick lists.

Examples

${options}=         GetPicklist        Salutation
# Returns  ['--None--', 'Mr.', 'Ms.', 'Mrs.', 'Dr.', 'Prof.']
${selected}=        GetPicklist        Salutation   selected=True
# Returns  'Mr.' if that one was selected.

Parameters

label : str
Label of the pick list where value should be selected.
index : int
If multiple picklists are present with same label, index can be used to identify which one should be selected. Default: 1
selected : bool
Return all options (False) or just currently selected option (True). Default: False
timeout : str | int
How long we try to find the picklist before failing. Default: DefaultTimeout configuration value.

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

label index
= 1
timeout
= 0
** kwargs

Documentation

Returns the count of options in a picklist identified by label. Supports both Lightning and Aura pick lists.

Examples

${count}=   GetPickListCount        Salutation   # returns 5

Parameters

label : str
Label of the pick list where value should be selected.
timeout : str | int
How long we try to find the picklist before failing. Default: DefaultTimeout configuration value.

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

column row timeout
= 0

Documentation

Gets a value from a sf_standard_table using row and column. Works with sf_standard_table elements, for example Quotes/Edit Lines:

./img/sf_standard_table.png

Examples

${value}=    GetTableCell          Quantity             3
${value}=    GetTableCell          List Unit Price      5

Parameters

column : str
Column header in table.
row : str
Row number in the column.

Arguments

app_name tab
= None
connected_app
= False
index
= 1

Tags

Navigation

Documentation

Launches an app using Salesforce app menu / app launcher.

NOTE: If the requested app is already open, it will NOT be re-launched and a message explaining this will be logged.

Examples

LaunchApp          Sales    # Launch normal app
LaunchApp          Sales    Opportunities   # Launch app + check text after launch
LaunchAPp          Gmail    connected_app=True  # Launch connected app, skips checks
LaunchApp          E-Bikes  index=2   # Launch second instance if there are duplicates

Parameters

app_name : str
Exact name of the application to launch.
tab : str
Tab text which will be verified to exist after succesfully opening an application (optional).
connected_app: bool
Connected apps behave differently than "native" apps. After launching applauncher is left open and app opens in a new tab. If True is given here, we will skip check that applauncher is closed and verification of tab name. (optional) Default: False
index : int
If there are exact duplicate app names, index of item that should be selected (optional) Default: 1

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

label value action
= Move selection to Chosen
timeout
= 0

Documentation

Selects/unselects a value from a Salesforce Lightning multiselection pick list.

./img/multipicklist.png

Examples

MultiPicklist    Hide Tabs     Auto Resolved Conflicts
# Move from "selected" back to "available"
MultiPicklist    Hide Tabs     Auto Resolved Conflicts   action=Move selection to Available

Parameters

label : str
Label of the pick list where value should be selected.
value : str
Value to be selected from a pick list.
action : str
Action of the button to click after selection. It's usually the text next to the button, or the text that appears when mouse pointer is hovered over the button. Default: "Move selection to Chosen" (select). Change to "Move selection to Available" to unselect.

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

label value index
= 1
timeout
= 0
** kwargs

Documentation

Selects a value from a Salesforce pick list. Supports both Lightning and Aura pick lists. Pick list is found based on it's label. Both exact match and partial match are supported.

NOTE: Special characters need to be escaped with "\" in case included in search text. This is especially the case on mandatory pick lists, which do contain "*" in the label text and you search with exact match.

Examples

PickList        Salutation      Mr.

# Finding with exact label when label includes special characters
# ("*" needs to be escaped with "\")
PickList        \*Status        Open     partial_match=False

Parameters

label : str
Label of the pick list where value should be selected.
value : str
Value to be selected from a pick list.
index : int
If multiple picklists are present with same label, index can be used to identify which one should be selected. Default: 1
timeout : str | int
How long we try to find the picklist before failing. Default: DefaultTimeout configuration value.
kwargs :
Accepted kwargs:
partial_match: False. If partial matches are accepted set
partial_match to True.
Default: as set in config PartialMatch. Check with 'GetConfig PartialMatch'

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

scrollable
= None
direction
= pagedown
tag
= div
timeout
= 0
** kwargs

Tags

Navigation

Documentation

Scrolls using keys in Salesforce's list views.

Examples

# Default action, page down in a list
ScrollList

# Scrolls list up by one page
ScrollList  direction=page_up

# Scroll list right
ScrollList  uiScroller      right

# Scroll to the bottom of a list using different locator and tag
ScrollList  scrollable2     bottom      tag=custom_tag

# Scroll to the top of a list
ScrollList  direction=top

# Scroll (page) down 3 times in a list
Repeat Keyword     3 times    ScrollList    direction=down

Parameters

scrollable: str
Attribute value or xpath to identify scrollable element. Default: as set in setting SFScrollable
direction : str
Direction to scroll to (down, up, left, right, top, bottom, page_down, page_up).
  • Down/up/left/right map to respective ARROW keys.
  • Top/Bottom map to HOME & END keys.
  • Page_up/Page_down map to PAGE_UP and PAGE_DOWN keys.

Default value: page_down

tag : str
Tag of the scrollable element. Needed if attribute value is used instead of xpath. Default value: div
timeout : str
How long to wait for the search results page to appear. Default 0 (use the default timeout setting).

Raises

QWebValueError
Direction is not given in correct format.
QWebElementNotFoundError
Page did not contain given scrollable element

Arguments

timestr round_to
= 3
accept_plain_values
= True

Documentation

Parses time like '1h 10s', '01:00:10' or '42' and returns seconds.

Arguments

column row text timeout
= 0

Documentation

Type a value to a field in a sf_standard_table at specific column/row.

Examples

TypeTable          Quantity             3     2.00
TypeTable          List Unit Price      5     9322

Parameters

column : str
Column header in table.
row : str
Row number in the column.
text : str
Text to be written into the field

Arguments

label expected index
= 1
partial_match
= False
tag
= span
timeout
= 0

Documentation

Verifies a field value in Salesforce (Aura/Lightning) Record Layout. Correct field is found using label and value is compared to expected value given as argument. By default verifies text under lightning-formatted-/span tag. Some salesforce texts are under non-formatted <a> tag and with these you need to use tag argument

./img/verify_field_example.png

Examples

VerifyField        Phone             12345
VerifyField        Phone             123                 partial_match=True
VerifyField        Account Name      Customer X
VerifyField        Notes             This is the begi    partial_match=True

# verifies that field "Type" is empty
VerifyField        Type              ${EMPTY}

# Verifies text in non-formatted a tag
VerifyField        Lead Owner        John Doe            tag=a

Parameters

label : str
Label/heading of the record to verify.
value : str
Value which is expected to be in the field.
index : int
If there are multiple duplicate labels in record layout, index can be used to identify which one should be verified.
partial_match : bool
If full match is expected or if partial match is accepted. Default: False (full match)
timeout : str | int
Timeout for waiting element to appear before failing. Default value is what is set in "DefaultTimeout".

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

tab_name timeout
= 0

Tags

Navigation

Documentation

Verifies the current page's header.

./img/verify_page_header_example.png

Examples

VerifyPageHeader    Opportunities

Parameters

tab_name : str
Name of the tab which should be opened.
timeout : str
How long to wait for page header to appear. Default 0 (use the default timeout setting)

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

label * args ๐Ÿท index
= 1
๐Ÿท selected
= False
๐Ÿท timeout
= 0
** kwargs

Documentation

Verifies that one or many option values exists in a specific picklist. Supports both Lightning and Aura pick lists.

Examples

# Verify specific option value exists
VerifyPicklist        Salutation    Dr.
# Verify multiple option values exist
VerifyPicklist        Salutation    Mr.   Ms.    Dr.
# Verify specific value exists and is selected
VerifyPicklist        Salutation    Dr.   selected=True

Parameters

label : str
Label of the pick list where value should be selected.
args: str
Option values which should exist on a picklist
index : int
If multiple picklists are present with same label, index can be used to identify which one should be selected. Default: 1
selected : bool
Verifies that given option exists only (False) or that it also is the currently selected option (True). Default: False
timeout : str | int
How long we try to find the picklist before failing. Default: DefaultTimeout configuration value.

Raises

QWebElementNotFoundError
Page did not contain element

Arguments

column row expected partial_match
= False
timeout
= 0

Documentation

Verifies a value from a sf_standard_table at specific column/row.

./img/sf_standard_table.png

Examples

VerifyTableCell          Quantity             3     2.00
VerifyTableCell          List Unit Price      5     7 632     partial_match=True

Parameters

column : str
Column header in table.
row : str
Row number in the column.
expected : str
Expected value in column to verify against.
partial_match : str
False (default): expect full match. True: allow partial matches

Arguments

text timeout
= 0
anchor
= 1
recognition_mode
= web
** kwargs

Documentation

Verifies that a text appears on screen".

Examples

VerifyText          Canis
VerifyText          Canis       20  # Waits max 20 seconds for text to appear
VerifyText          Canis       recognition_mode=vision  # Use Computer Vision engine

Parameters

text : str
Text to be verified.
timeout : str | int
How long we try to find text before failing. Default 10 (seconds)
anchor : str | int
Another text close to text we are trying to find or index.
recognition_mode : str
Use either "web" backend (default) or computer vision ("vision"). Computer vision finds texts from the screen regardless how they appear on DOM. This is useful to verify truncated ui texts and especially when elements are under shadow dom.

QForce

image/svg+xml