Skip to content

Instantly share code, notes, and snippets.

@Julian88Tex
Created February 9, 2022 18:33
Show Gist options
  • Save Julian88Tex/e17ed5489497a28806de13a0d48e1ebf to your computer and use it in GitHub Desktop.
Save Julian88Tex/e17ed5489497a28806de13a0d48e1ebf to your computer and use it in GitHub Desktop.
Enable Field History in Salesforce UI Using Robot Framework/CumulusCI
*** Settings ***
Resource cumulusci/robotframework/Salesforce.robot
Library cumulusci.robotframework.PageObjects
Suite Setup Run Keywords
... Setup Test Data
... Open Test Browser
Suite Teardown Delete Records And Close Browser
*** Tasks ***
Enable History
[Documentation] Enables Account and Contact History settings. Manage has a dependency
... on these features.
Enable History If Disabled Account
Enable History If Disabled Contact
*** Keywords ***
Setup Test Data
[Documentation] Sets up all data required for test.
Get Salesforce Instance URL
Get Salesforce Instance URL
[Documentation]
... Get Salesforce Org Instance URL.
... Sets as a Test Variable.
${org_info} = Get Org Info
${instance_url} = Pop From Dictionary ${org_info}
... instance_url
${instance_url} = Set Suite Variable ${instance_url}
Enable History If Disabled
[Documentation] Checks if the Object History setting has been enabled and if not,
... enables it.
[Arguments] ${Object}
Navigate To Object Field History
... ${Object}
# iframe for Salesforce Classic setup pages
Select Frame //*[@id="setupComponent"]/div/div/div/force-aloha-page/div/iframe
# Following element appears to be only indicator of enablement
${enablement_status} = Run Keyword And Return Status
... Page Should Not Contain Element
... //*[@id="hideableButtons"][contains(@style,'display: none')]
# Runs Enable History if the enabled indicator is present
Run Keyword If '${enablement_status}' == 'True'
... Enable History
Navigate To Object Field History
[Documentation] Navigates to the Object Field History page.
[Arguments] ${Object}
${history_url} = Set Variable
... ${instance_url}/lightning/setup/ObjectManager/${Object}/FieldsAndRelationships/setHistoryTracking
Go To ${history_url}
Enable History
[Documentation] Navigates into iframe containing History Setting and clicks it.
# Click "Enable Account History" checkbox
# "//input[@id='enable']//preceding-sibling::label[text()='Enable Account History']"
# Above should be a better locator but not working.
Click Element //*[@id="enable"]
# Click top "Save" button
Click Element //*[@id="topButtonRow"]/input[@name='save']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment