-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathcommon.robot
More file actions
125 lines (99 loc) · 6.29 KB
/
common.robot
File metadata and controls
125 lines (99 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
*** Settings ***
Documentation Example resource file with custom keywords. NOTE: Some keywords below may need
... minor changes to work in different instances.
Library QForce
Library String
Library DateTime
*** Variables ***
# IMPORTANT: Please read the readme.txt to understand needed variables and how to handle them!!
${BROWSER} chrome
${username} richagupta8nov.7786979797d3426b1976@agentforce.com
${login_url} https://login.salesforce.com/ # Salesforce instance. NOTE: Should be overwritten in CRT variables
${home_url} ${login_url}/lightning/page/home
${password} kljdsflkjsdkljf
*** Keywords ***
Setup Browser
# Setting search order is not really needed here, but given as an example
# if you need to use multiple libraries containing keywords with duplicate names
Set Library Search Order QForce QWeb
Open Browser about:blank ${BROWSER}
SetConfig LineBreak ${EMPTY} #\ue000
Evaluate random.seed() random # initialize random generator
SetConfig DefaultTimeout 20s #sometimes salesforce is slow
# adds a delay of 0.3 between keywords. This is helpful in cloud with limited resources.
SetConfig Delay 0.3
End suite
Close All Browsers
Login
[Documentation] Login to Salesforce instance. Takes instance_url, username and password as
... arguments. Uses values given in Copado Robotic Testing's variables section by default.
[Arguments] ${sf_instance_url}=${login_url} ${sf_username}=${username} ${sf_password}=${password}
GoTo ${sf_instance_url}
TypeText Username ${sf_username} delay=1
TypeSecret Password ${sf_password}
ClickText Log In
# We'll check if variable ${secret} is given. If yes, fill the MFA dialog.
# If not, MFA is not expected.
# ${secret} is ${None} unless specifically given.
${MFA_needed}= Run Keyword And Return Status Should Not Be Equal ${None} ${secret}
Run Keyword If ${MFA_needed} Fill MFA ${sf_username} ${secret} ${sf_instance_url}
Login As
[Documentation] Login As different persona. User needs to be logged into Salesforce with Admin rights
... before calling this keyword to change persona.
... Example:
... LoginAs Chatter Expert
[Arguments] ${persona}
ClickText Setup
ClickItem Setup delay=1
SwitchWindow NEW
TypeText Search Setup ${persona} delay=2
ClickElement //*[@title\="${persona}"] delay=2 # wait for list to populate, then click
VerifyText Freeze timeout=45 # this is slow, needs longer timeout
ClickText Login anchor=Freeze partial_match=False delay=1
Fill MFA
[Documentation] Gets the MFA OTP code and fills the verification dialog (if needed)
[Arguments] ${sf_username}=${username} ${mfa_secret}=${secret} ${sf_instance_url}=${login_url}
${mfa_code}= GetOTP ${sf_username} ${mfa_secret} ${login_url}
TypeSecret Verification Code ${mfa_code}
ClickText Verify
Home
[Documentation] Example appstarte: Navigate to homepage, login if needed
GoTo ${home_url}
${login_status} = IsText To access this page, you have to log in to Salesforce. 2
Run Keyword If ${login_status} Login
ClickText Home
VerifyTitle Home | Salesforce
# Example of custom keyword with robot fw syntax. NOTE: These keywords may need to be adjusted
# to work in your environment
VerifyStage
[Documentation] Verifies that stage given in ${text} is at ${selected} state; either selected (true) or not selected (false)
[Arguments] ${text} ${selected}=true
VerifyElement //a[@title\="${text}" and (@aria-checked\="${selected}" or @aria-selected\="${selected}")]
VerifyStageColor
[Documentation] Example keyword on how to verify background color of element.
... Note that this keyword might need adjusting in your instance (colors and locators can be different)
[Arguments] ${stage_text} ${color}=navy
&{COLORS}= Create Dictionary navy=rgba(1, 68, 134, 1) green=rgba(59, 167, 85, 1)
${elem}= GetWebElement ${stage_text} element_type=item
${background_color}= Evaluate $elem.value_of_css_property("background-color")
Should Be Equal ${COLORS.${color}} ${background_color} msg=Error: Background color ( ${background_color}) differs from ${color} (${COLORS.${color}})
NoData
VerifyNoItem ${data} tag=a timeout=3 delay=2
DeleteAccounts
[Documentation] RunBlock to remove all data until it doesn't exist anymore
ClickText ${data}
ClickText Delete
VerifyText Are you sure you want to delete this account?
ClickText Delete 2
VerifyText Undo
VerifyNoText Undo
ClickText Accounts partial_match=False
DeleteLeads
[Documentation] RunBlock to remove all data until it doesn't exist anymore
ClickText ${data}
ClickText Delete
VerifyText Are you sure you want to delete this lead?
ClickText Delete 2
VerifyText Undo
VerifyNoText Undo
ClickText Leads partial_match=False