sfdc_se 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,128 @@
1
+ # ----------------------------------------------
2
+ # - Page: Home Page Layouts
3
+ # -- Body of the page
4
+ # ----------------------------------------------
5
+
6
+ module SfdcSe
7
+ class Driver
8
+
9
+ # -----------------------------
10
+ # click_Btn_HomePageLayouts_PageLayoutAssignment
11
+ # => Clicks the 'Home Page Layouts' button
12
+ #
13
+ def click_Btn_HomePageLayouts_PageLayoutAssignment
14
+ @driver.find_element(:xpath => "//input[@title='Page Layout Assignment']").click
15
+ sleep(3)
16
+ end
17
+
18
+ # -----------------------------
19
+ # click_Btn_HomePageLayouts_EditAssignment
20
+ #
21
+ def click_Btn_HomePageLayouts_EditAssignment
22
+ @driver.find_element(:xpath => "//input[@title = 'Edit Assignment']").click
23
+ sleep(3)
24
+ end
25
+
26
+ # -----------------------------
27
+ # click_Btn_HomePageLayouts_save
28
+ #
29
+ def click_Btn_HomePageLayouts_save
30
+ @driver.find_element(:xpath => "//td[@id = 'topButtonRow']/input[@title='Save']").click
31
+ return @driver.find_element(:xpath => "//input[@title = 'Edit Assignment']").displayed?
32
+ end
33
+
34
+ # -----------------------------
35
+ # get_elements_HomePageLayouts_Profiles_table
36
+ #
37
+ def get_elements_HomePageLayouts_Profiles_table
38
+ return @driver.find_elements(:xpath => "//table[@class='detailList']/tbody/tr")
39
+ end
40
+
41
+ # -----------------------------
42
+ # get_HomePageLayouts_Profile_Assignments
43
+ # => Returns a hash; Key = Profile Name, Value = Page Layout Assignment
44
+ #
45
+ def get_HomePageLayouts_Profile_Assignments
46
+ hProfiles=Hash.new
47
+ get_elements_HomePageLayouts_Profiles_table.each do |row|
48
+ hProfiles[row.find_element(:xpath => "./td[1]").text] = row.find_element(:xpath => "./td[2]").text
49
+ end
50
+ return hProfiles
51
+ end
52
+
53
+ # -----------------------------
54
+ # set_HomePageLayout_Profile_Assignments
55
+ # => hProfileAssignments = Hash of the profiles and assignments
56
+ # => key = Profile
57
+ # => value = assignment
58
+ # => Return = true or false
59
+ # => true = setting of all assignments were successful
60
+ # => false = setting had an error, or no vales were changed
61
+ #
62
+ def set_HomePageLayout_Profile_Assignments(hProfileAssignments)
63
+ blnChangedValue=false
64
+ begin
65
+ get_elements_HomePageLayouts_Profiles_table.each do |row|
66
+ strProfile=row.find_element(:xpath => "./td[1]").text
67
+ if strProfile[0] == "*"
68
+ strProfile=strProfile[1..-1]
69
+ end
70
+
71
+ if hProfileAssignments.has_key? (strProfile)
72
+ # check if current value is already set to assignment, if not set
73
+ options=row.find_elements(:xpath => "./td[2]/div/select/option")
74
+
75
+ options.each do |option|
76
+ if option.selected?
77
+ $strCurrentlySelected = option.text
78
+ end
79
+ end
80
+
81
+ if hProfileAssignments[strProfile] != $strCurrentlySelected
82
+ options.each do |option|
83
+ if option.text == hProfileAssignments[strProfile]
84
+ option.click
85
+ blnChangedValue=true
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ rescue
92
+ puts $!
93
+ puts $@
94
+ blnChangedValue = false
95
+ end
96
+ return blnChangedValue
97
+ end
98
+ # -----------------------------
99
+
100
+ # -----------------------------
101
+ # set_HomePageLayout_Profile_Assignments2
102
+ # => sProfile = String for profile to check/set
103
+ # => sAssignment = String for Assigment value
104
+ # => Return = true or false
105
+ # => true = setting of value was successfull
106
+ # => false = setting had an error or values was already set correctly
107
+ def set_HomePageLayout_Profile_Assignments(sProfile, sAssignment)
108
+ blnReturn=false
109
+ get_elements_HomePageLayouts_Profiles_table.each do |row|
110
+ if row.find_element(:xpath => "./td[1]").text.gsub("*\n", "") == sProfile
111
+ if !(row.find_element(:xpath => "./td[2]/div/select/option[@selected='selected']").text == sAssignment)
112
+ row.find_elements(:xpath => "./td[2]/div/select/option").each do |option|
113
+ if option.text == sAssignment
114
+ option.click
115
+ blnReturn=true
116
+ break
117
+ end
118
+ end
119
+ end
120
+ break
121
+ end
122
+ end
123
+ return blnReturn
124
+ end
125
+ # -----------------------------
126
+
127
+ end
128
+ end
@@ -0,0 +1,61 @@
1
+ # ----------------------------------------------
2
+ # - Page: Password/Security Setting
3
+ # ----------------------------------------------
4
+
5
+ module SfdcSe
6
+ class Driver
7
+
8
+ # -----------------------------
9
+ # reset_PasswordSecurityQuestion
10
+ def reset_PasswordSecurityQuestion(sCurentPassword, sNewPassword, sAnswer)
11
+ blnEdit=false
12
+
13
+ if @driver.find_elements(:id => 'currentpassword').size > 0
14
+ set_CurrentPasswordField(sCurentPassword)
15
+ set_NewPasswordField(sNewPassword)
16
+ set_ConfirmPasswordField(sNewPassword)
17
+ set_AnswerField(sAnswer)
18
+ click_Btn_ChangePassword
19
+ blnEdit=true
20
+ end
21
+ return blnEdit
22
+ end
23
+ # -----------------------------
24
+
25
+ # -----------------------------
26
+ # set_CurrentPasswordField(sPWD)
27
+ def set_CurrentPasswordField(sPWD)
28
+ @driver.find_element(:id => 'currentpassword').send_keys(sPWD)
29
+ end
30
+ # -----------------------------
31
+
32
+ # -----------------------------
33
+ # set_NewPasswordField(sPWD)
34
+ def set_NewPasswordField(sPWD)
35
+ @driver.find_element(:id => 'newpassword').send_keys(sPWD)
36
+ end
37
+ # -----------------------------
38
+
39
+ # -----------------------------
40
+ # set_ConfirmPasswordField(sPWD)
41
+ def set_ConfirmPasswordField(sPWD)
42
+ @driver.find_element(:id => 'confirmpassword').send_keys(sPWD)
43
+ end
44
+ # -----------------------------
45
+
46
+ # -----------------------------
47
+ # set_AnswerField(sAnswer)
48
+ def set_AnswerField(sAnswer)
49
+ @driver.find_element(:id => 'answer').send_keys(sAnswer)
50
+ end
51
+ # -----------------------------
52
+
53
+ # -----------------------------
54
+ # click_Btn_ChangePassword
55
+ def click_Btn_ChangePassword
56
+ @driver.find_element(:id => 'password-button').click
57
+ end
58
+ # -----------------------------
59
+
60
+ end
61
+ end
@@ -0,0 +1,18 @@
1
+ # ------------------------------
2
+ # - Page: Personal Information
3
+ # -- Body of the page
4
+ # ------------------------------
5
+
6
+ module SfdcSe
7
+ class Driver
8
+
9
+ # -----------------------------
10
+ # get_PersonalInformation_username
11
+ # => Returns the Username value
12
+ #
13
+ def get_PersonalInformation_username
14
+ return @driver.find_element(:xpath => "//table[@class='detailList']/tbody/tr[4]/td[2]").text
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,780 @@
1
+ # ----------------------------------------------
2
+ # - Page: Profiles
3
+ # ----------------------------------------------
4
+
5
+ module SfdcSe
6
+ class Driver
7
+
8
+ # -----------------------------
9
+ # get_ProfileViewOptions
10
+ # => returns all the elements for the Profiles View dropdown
11
+ def get_ProfileViewOptions
12
+ return @driver.find_elements(:xpath => "//form/div[1]/div/select/option")
13
+ end
14
+ # -----------------------------
15
+
16
+ # -----------------------------
17
+ # get_elements_Profiles_table
18
+ # => returns all the elements for the Profiles table
19
+ def get_elements_Profiles_table
20
+ return @driver.find_elements(:xpath => "//table[@class='x-grid3-row-table']/tbody/tr")
21
+ end
22
+ # -----------------------------
23
+
24
+ # -----------------------------
25
+ # get_Profiles_AdministrativePermissions_table
26
+ # => returns all the elements for the Profiles Administravite Permissions table
27
+ def get_Profiles_AdministrativePermissions_table
28
+ return @driver.find_elements(:xpath => "//h3[contains(.,'Administrative Permissions')]/../following-sibling::div[1]/table/tbody/tr")
29
+ end
30
+ # -----------------------------
31
+
32
+ # -----------------------------
33
+ # get_Profiles_GeneralUserPermissions_table
34
+ # => returns all the elements for the Profiles General User Permissions table
35
+ def get_Profiles_GeneralUserPermissions_table
36
+ return @driver.find_elements(:xpath => "//h3[contains(.,'General User Permissions')]/../following-sibling::div[1]/table/tbody/tr")
37
+ end
38
+ # -----------------------------
39
+
40
+ # -----------------------------
41
+ # get_Profiles_StandardObjectPermissions_table
42
+ # => returns all the elements for the Profiles Standard Object Permissions table
43
+ def get_Profiles_StandardObjectPermissions_table
44
+ return @driver.find_elements(:xpath => "//h3[contains(.,'Standard Object Permissions')]/../following-sibling::div[1]/table/tbody/tr")
45
+ end
46
+ # -----------------------------
47
+
48
+ # -----------------------------
49
+ # get_Profiles_CusomObjectPermissions_table
50
+ # => returns all the elements for the Profiles Custom Object Permissions table
51
+ def get_Profiles_CustomObjectPermissions_table
52
+ return @driver.find_elements(:xpath => "//h3[contains(.,'Custom Object Permissions')]/../following-sibling::div[1]/table/tbody/tr")
53
+ end
54
+ # -----------------------------
55
+
56
+ # -----------------------------
57
+ # get_Profiles_TabSettings_table
58
+ # => returns all the elements for the Profiles Tab Settings table
59
+ def get_Profiles_TabSettings_table
60
+ if !@driver.find_elements(:xpath => "//h3[contains(.,'Tab Settings')]").nil?
61
+ @aStandardTable=@driver.find_elements(:xpath => "//h3[contains(.,'Tab Settings')]/../following-sibling::div[1]/table/tbody/tr")
62
+ @aCustomTable=@driver.find_elements(:xpath => "//h3[contains(.,'Tab Settings')]/../following-sibling::div[2]/table/tbody/tr")
63
+ @aStandardTable.push *@aCustomTable
64
+ return @aStandardTable
65
+ end
66
+ end
67
+ # -----------------------------
68
+
69
+ # -----------------------------
70
+ # get_Profiles_CustomProfile_CheckboxValue
71
+ # => Returns true/false
72
+ # True = Custom Profile Checkbox is checked
73
+ # False = Custom Profile Checkbox is NOT checked
74
+ def get_Profiles_CustomProfile_CheckboxValue
75
+ return @driver.find_element(:xpath => "//td[contains(.,'Custom Profile')]/following-sibling::td/img").attribute("title")=='Checked' ? true : false
76
+ end
77
+ # -----------------------------
78
+
79
+ # -----------------------------
80
+ # get_Profiles_ApexClassAccess_table
81
+ # => returns all the elements for the Profiles Apex Class Access table
82
+ def get_Profiles_ApexClassAccess_table
83
+ return @driver.find_elements(:xpath => "//h3[contains(.,'Enabled Apex Class Access')]/../../../../../following-sibling::div[1]/table/tbody/tr")
84
+ end
85
+ # -----------------------------
86
+
87
+ # -----------------------------
88
+ # get_Profiles_VisualforcePageAccess_table
89
+ # => returns all the elements for the Profiles Visualforce Page Access table
90
+ def get_Profiles_VisualforcePageAccess_table
91
+ return @driver.find_elements(:xpath => "//h3[contains(.,'Enabled Visualforce Page Access')]/../../../../../following-sibling::div[1]/table/tbody/tr")
92
+ end
93
+ # -----------------------------
94
+
95
+ # -----------------------------
96
+ # get_Profiles_ApexClassAccess_AvailableSelect
97
+ # => returns all the options for the Availalble Apex Classes
98
+ def get_Profiles_ApexClassAccess_AvailableSelect
99
+ return @driver.find_elements(:xpath => "//select[@id='duel_select_0']/option")
100
+ end
101
+ # -----------------------------
102
+
103
+ # -----------------------------
104
+ # get_Profile_VisualforcePageAccess_EnabledSelect
105
+ # => returns all the options for the Availalble Apex Classes
106
+ def get_Profile_VisualforcePageAccess_EnabledSelect
107
+ return @driver.find_elements(:xpath => "//select[@id='duel_select_1']/option")
108
+ end
109
+ # -----------------------------
110
+
111
+
112
+ # -----------------------------
113
+ # click_btn_Profiles_Edit
114
+ def click_btn_Profiles_Edit
115
+ @driver.find_element(:xpath => "//input[@class='btn' and @title='Edit']").click
116
+ end
117
+ # -----------------------------
118
+
119
+ # -----------------------------
120
+ # click_btn_Profiles_Save
121
+ def click_btn_Profiles_Save
122
+ @driver.find_element(:xpath => "//input[@class='btn' and @title='Save']").click
123
+
124
+ sMsg=""
125
+ a=@driver.switch_to.alert rescue "Exception happened"
126
+ if !(a == "Exception happened")
127
+ sMsg= "Accepting Alert: #{a.text}"
128
+ a.accept
129
+ end
130
+
131
+ return sMsg
132
+ end
133
+ # -----------------------------
134
+
135
+ # -----------------------------
136
+ # click_btn_Profiles_Cancel
137
+ def click_btn_Profiles_Cancel
138
+ @driver.find_element(:xpath => "//input[@class='btn' and @title='Cancel']").click
139
+ end
140
+ # -----------------------------
141
+
142
+ # -----------------------------
143
+ # click_btn_Profiles_ApexClassAccess_Add
144
+ def click_btn_Profiles_ApexClassAccess_Add
145
+ @driver.find_element(:xpath => "//img[@class='rightArrowIcon' and @title='Add']").click
146
+ end
147
+ # -----------------------------
148
+
149
+ # -----------------------------
150
+ # click_Profiles_breadcrumb
151
+ # => clicks the 'Back to List: Profiles' Breadcrumb link
152
+ def click_Profiles_breadcrumb
153
+ @driver.find_element(:xpath => "//div[@class='ptBreadcrumb']/a").click
154
+ @wait.until{@driver.find_element(:xpath => "//input[@class='btn' and @title='New Profile']")}
155
+ end
156
+ # -----------------------------
157
+
158
+ # -----------------------------
159
+ # click_Profiles_ApexClassAccess_Edit
160
+ # => clicks the 'edit' button within the Apex Class Access section
161
+ def click_Profiles_ApexClassAccess_Edit
162
+ @driver.find_element(:xpath => "//h3[contains(.,'Enabled Apex Class Access')]/../following-sibling::td[1]/input[@class='btn' and @title='Edit']").click
163
+ # @driver.find_element(:xpath => "//div[@class='ptBreadcrumb']/a").click
164
+ # @wait.until{@driver.find_element(:xpath => "//input[@class='btn' and @title='New Profile']")}
165
+ end
166
+ # -----------------------------
167
+
168
+ # -----------------------------
169
+ # click_Profiles_VisualforcePageAccess_Edit
170
+ # => clicks the 'edit' button within the Visualforce Page Access section
171
+ def click_Profiles_VisualforcePageAccess_Edit
172
+ @driver.find_element(:xpath => "//h3[contains(.,'Enabled Visualforce Page Access')]/../following-sibling::td[1]/input[@class='btn' and @title='Edit']").click
173
+ end
174
+ # -----------------------------
175
+
176
+ # -----------------------------
177
+ # click_btn_Profiles_ApexClassAccess_Save
178
+ def click_btn_Profiles_ApexClassAccess_Save
179
+ @driver.find_element(:xpath => "//input[@class='btn' and @title='Save']").click
180
+ end
181
+ # -----------------------------
182
+
183
+ # -----------------------------
184
+ # click_btn_Profiles_ApexClassAccess_Cancel
185
+ def click_btn_Profiles_ApexClassAccess_Cancel
186
+ @driver.find_element(:xpath => "//input[@class='btn' and @title='Cancel']").click
187
+ end
188
+ # -----------------------------
189
+
190
+ # -----------------------------
191
+ # set_Profile_View
192
+ # => sViewName = string value of the view name to select
193
+ # => Return = true or false
194
+ # => true = setting of view were successful
195
+ # => false = setting of view had an error
196
+ #
197
+ def set_Profile_View(sViewName)
198
+ blnViewSet=false
199
+ begin
200
+ get_ProfileViewOptions.each do |option|
201
+ if option.text == sViewName
202
+ option.click unless option.selected?
203
+ blnViewSet=true
204
+ return blnViewSet
205
+ end
206
+ end
207
+ rescue
208
+ puts $!
209
+ puts $@
210
+ end
211
+ return blnViewSet
212
+ end
213
+ # -----------------------------
214
+
215
+ # -----------------------------
216
+ # select_Profile
217
+ # => sProfileName = String value of the profile name to select
218
+ # => Return = true or false
219
+ # => true = Profile successfully selected
220
+ # => false = Profile selection had an error
221
+ def select_Profile(sProfileName)
222
+ blnValue=false
223
+ begin
224
+ get_elements_Profiles_table.each do |row|
225
+ tableProfile=row.find_element(:xpath => "./td[4]").text
226
+ if tableProfile==sProfileName
227
+ row.find_element(:xpath => "./td[4]/div/a").click
228
+ blnValue=true
229
+ return blnValue
230
+ end
231
+ end
232
+ rescue
233
+ puts $!
234
+ puts $@
235
+ blnValue = false
236
+ end
237
+ return blnValue
238
+ end
239
+
240
+ # -----------------------------
241
+ # get_Profiles_AdministrativePermissions
242
+ # => Returns a hash; Key = Permission Name, Value = Checked/Unchecked
243
+ #
244
+ def get_Profiles_AdministrativePermissions
245
+ begin
246
+ @aPAP=Hash.new
247
+ if get_Profiles_CustomProfile_CheckboxValue
248
+ get_Profiles_AdministrativePermissions_table.each do |i|
249
+ @aPAP[i.find_element(:xpath => "./td[1]").text]=i.find_element(:xpath => "./td[2]/img").attribute("alt")
250
+ @aPAP[i.find_element(:xpath => "./td[3]").text]=i.find_element(:xpath => "./td[4]/img").attribute("alt") unless i.find_element(:xpath => "./td[3]").attribute("class") == "labelCol last empty"
251
+ end
252
+ end
253
+ return @aPAP
254
+ rescue
255
+ puts $!
256
+ puts $@
257
+ end
258
+ end
259
+ # -----------------------------
260
+
261
+ # -----------------------------
262
+ # set_Profiles_AdministrativePermissions
263
+ # => hValues = an input Hash of the values to set per profile
264
+ # => Returns true/false
265
+ #
266
+ def set_Profiles_AdministrativePermissions(hValues)
267
+ @driver.manage.timeouts.implicit_wait = 0
268
+ blnReturn=false
269
+
270
+ get_Profiles_AdministrativePermissions_table.each do |i|
271
+ # - Left hand column
272
+ if i.find_elements(:xpath => "./td[2]/img").size == 0
273
+ sOrgSetting = i.find_element(:xpath => "./td[2]/input").selected? ? "Checked" : "Not Checked"
274
+ if !(sOrgSetting==hValues[i.find_element(:xpath => "./td[1]").text.gsub("*\n", "")])
275
+ i.find_element(:xpath => "./td[2]/input").click
276
+ blnReturn=true
277
+ end
278
+ end
279
+
280
+ # - Right hand column
281
+ if i.find_elements(:xpath => "./td[4]/img").size == 0 and i.find_element(:xpath => "./td[3]").attribute("class") != "labelCol last empty"
282
+ sOrgSetting = i.find_element(:xpath => "./td[4]/input").selected? ? "Checked" : "Not Checked"
283
+ if !(sOrgSetting==hValues[i.find_element(:xpath => "./td[3]").text.gsub("*\n", "")])
284
+ i.find_element(:xpath => "./td[4]/input").click
285
+ blnReturn=true
286
+ end
287
+ end
288
+
289
+ end
290
+
291
+ @driver.manage.timeouts.implicit_wait = @implicitWait
292
+
293
+ return blnReturn
294
+ end
295
+ # -----------------------------
296
+
297
+ # -----------------------------
298
+ # get_Profiles_GeneralUserPermissions
299
+ # => Returns a hash; Key = Permission Name, Value = Checked/Unchecked
300
+ #
301
+ def get_Profiles_GeneralUserPermissions
302
+ begin
303
+ @aConfig=Hash.new
304
+ if get_Profiles_CustomProfile_CheckboxValue
305
+ get_Profiles_GeneralUserPermissions_table.each do |row|
306
+ @aConfig[row.find_element(:xpath => "./td[1]").text]=row.find_element(:xpath => "./td[2]/img").attribute("alt")
307
+ @aConfig[row.find_element(:xpath => "./td[3]").text]=row.find_element(:xpath => "./td[4]/img").attribute("alt") unless row.find_element(:xpath => "./td[3]").attribute("class") == "labelCol last empty"
308
+ end
309
+ end
310
+ return @aConfig
311
+ rescue
312
+ puts $!
313
+ puts $@
314
+ end
315
+ end
316
+ # -----------------------------
317
+
318
+ # -----------------------------
319
+ # set_Profiles_GeneralUserPermissions
320
+ # => Returns a hash; Key = Permission Name, Value = Checked/Unchecked
321
+ #
322
+ def set_Profiles_GeneralUserPermissions(hValues)
323
+ @driver.manage.timeouts.implicit_wait = 0
324
+ blnReturn=false
325
+
326
+ get_Profiles_GeneralUserPermissions_table.each do |row|
327
+
328
+ # - Left Hand Column
329
+ if row.find_elements(:xpath => "./td[2]/img").size == 0
330
+ sOrgSetting = row.find_element(:xpath => "./td[2]/input").selected? ? "Checked" : "Not Checked"
331
+ if !(sOrgSetting==hValues[row.find_element(:xpath => "./td[1]").text.gsub("*\n", "")])
332
+ row.find_element(:xpath => "./td[2]/input").click
333
+ blnReturn=true
334
+ end
335
+ end
336
+
337
+ # - Right Hand Column
338
+ if row.find_elements(:xpath => "./td[4]/img").size == 0 and row.find_element(:xpath => "./td[3]").attribute("class") != "labelCol last empty"
339
+ sOrgSetting = row.find_element(:xpath => "./td[4]/input").selected? ? "Checked" : "Not Checked"
340
+ if !(sOrgSetting==hValues[row.find_element(:xpath => "./td[3]").text.gsub("*\n", "")])
341
+ row.find_element(:xpath => "./td[4]/input").click
342
+ blnReturn=true
343
+ end
344
+ end
345
+ end
346
+
347
+ # begin
348
+ # @aConfig=Hash.new
349
+ # #-TODO: Check if profile is CustomProfile (if not return blank hash)
350
+ # if get_Profiles_CustomProfile_CheckboxValue
351
+ # get_Profiles_GeneralUserPermissions_table.each do |row|
352
+ # @aConfig[row.find_element(:xpath => "./td[1]").text]=row.find_element(:xpath => "./td[2]/img").attribute("alt")
353
+ # @aConfig[row.find_element(:xpath => "./td[3]").text]=row.find_element(:xpath => "./td[4]/img").attribute("alt") unless row.find_element(:xpath => "./td[3]").attribute("class") == "labelCol last empty"
354
+ # end
355
+ # end
356
+ # return @aConfig
357
+ # rescue
358
+ # puts $!
359
+ # puts $@
360
+ # end
361
+
362
+ @driver.manage.timeouts.implicit_wait = @implicitWait
363
+
364
+ return blnReturn
365
+ end
366
+ # -----------------------------
367
+
368
+ # -----------------------------
369
+ # get_Profiles_TabSettings
370
+ # => Returns a hash; Key = Tab Name, Value = Default On; Default Off; Tab Hidden
371
+ #
372
+ def get_Profiles_TabSettings
373
+ begin
374
+ @hConfig=Hash.new
375
+ if !get_Profiles_TabSettings_table.nil?
376
+ get_Profiles_TabSettings_table.each do |row|
377
+ next if row.attribute("class") == "detailRow"
378
+ @hConfig[row.find_element(:xpath => "./td[1]").text]=row.find_element(:xpath => "./td[2]").text
379
+ @hConfig[row.find_element(:xpath => "./td[3]").text]=row.find_element(:xpath => "./td[4]").text unless row.find_element(:xpath => "./td[3]").attribute("class") == "labelCol last empty"
380
+ end
381
+ return @hConfig
382
+ end
383
+ rescue
384
+ puts $!
385
+ puts $@
386
+ end
387
+ end
388
+ # -----------------------------
389
+
390
+ # -----------------------------
391
+ # set_Profiles_TabSettings
392
+ # => hProfileValues = Hash of the values to be set for the indicated Profile/Section
393
+ # => Returns true/false
394
+ #
395
+ def set_Profiles_TabSettings(hProfileValues)
396
+ blnReturn=false
397
+ begin
398
+ if !get_Profiles_TabSettings_table.nil?
399
+ get_Profiles_TabSettings_table.each do |row|
400
+ next if row.attribute("class") == "detailRow"
401
+
402
+ if row.find_elements(:xpath => "./td[2]//*").size > 0
403
+ if !(row.find_element(:xpath => "./td[2]/div/select/option[@selected='selected']").text == hProfileValues[row.find_element(:xpath => "./td[1]").text.gsub("*\n", "")])
404
+ row.find_elements(:xpath => "./td[2]/div/select/option").each do |option|
405
+ if option.text == hProfileValues[row.find_element(:xpath => "./td[1]").text.gsub("*\n", "")]
406
+ option.click
407
+ blnReturn=true
408
+ end
409
+ end
410
+ end
411
+ end
412
+
413
+ if (row.find_element(:xpath => "./td[3]").attribute("class") != "labelCol last empty") and (row.find_elements(:xpath => "./td[4]//*").size > 0)
414
+ if !(row.find_element(:xpath => "./td[4]/div/select/option[@selected='selected']").text == hProfileValues[row.find_element(:xpath => "./td[3]").text.gsub("*\n", "")])
415
+ row.find_elements(:xpath => "./td[4]/div/select/option").each do |option|
416
+ if option.text == hProfileValues[row.find_element(:xpath => "./td[3]").text.gsub("*\n", "")]
417
+ option.click
418
+ blnReturn=true
419
+ end
420
+ end
421
+ end
422
+ end
423
+ end
424
+ return blnReturn
425
+ end
426
+ rescue
427
+ puts $!
428
+ puts $@
429
+ end
430
+ end
431
+ # -----------------------------
432
+
433
+ # -----------------------------
434
+ # get_Profiles_StandardObjectPermissions
435
+ # => Returns an Nested Hash; {Object Name =>{Key = Header Name, Value = Checked/Unchecked}}
436
+ #
437
+ def get_Profiles_StandardObjectPermissions
438
+ @driver.manage.timeouts.implicit_wait = 0
439
+ begin
440
+ @aSOP_Headers=[]
441
+ response_hash = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) }
442
+
443
+ if get_Profiles_CustomProfile_CheckboxValue
444
+ get_Profiles_StandardObjectPermissions_table.each_with_index do |row, index|
445
+ if index == 0
446
+ row.find_elements(:xpath => "./td[2]/table/tbody/tr[2]/th").each do |header|
447
+ @aSOP_Headers.push(header.text.strip! || header.text)
448
+ end
449
+ else
450
+ # -- Left Column of Table
451
+ $tempObjectName_Left=row.find_element(:xpath => "./th[1]").text
452
+ row.find_elements(:xpath => "./td[1]/table/tbody/tr/td").each_with_index do |hv, idx|
453
+ response_hash[$tempObjectName_Left][@aSOP_Headers[idx]]=hv.find_element(:xpath => "./img").attribute("alt") unless hv.find_elements(:xpath => ".//*").size == 0
454
+ end
455
+
456
+ # -- Right Column of Table
457
+ if row.find_element(:xpath => "./td[2]").attribute("class") != "labelCol last empty"
458
+ $tempObjectName_Right=row.find_element(:xpath => "./th[2]").text
459
+ row.find_elements(:xpath => "./td[2]/table/tbody/tr/td").each_with_index do |hv, idx|
460
+ if hv.find_elements(:xpath => ".//*").size != 0
461
+ response_hash[$tempObjectName_Right][@aSOP_Headers[idx]]=hv.find_element(:xpath => "./img").attribute("alt") unless hv.find_elements(:xpath => ".//*").size == 0
462
+ end
463
+ end
464
+ end
465
+ end
466
+ end
467
+ end
468
+ @driver.manage.timeouts.implicit_wait = @implicitWait
469
+ return response_hash
470
+ rescue
471
+ puts $!
472
+ puts $@
473
+ ensure
474
+ @driver.manage.timeouts.implicit_wait = @implicitWait
475
+ end
476
+ end
477
+ # -----------------------------
478
+
479
+ # -----------------------------
480
+ # set_Profiles_StandardObjectPermissions
481
+ # => hValues = Hash of the values to be set for the indicated Profile/Section
482
+ # => Returns true/false
483
+ #
484
+ def set_Profiles_StandardObjectPermissions(hValues)
485
+ @driver.manage.timeouts.implicit_wait = 0
486
+ blnReturn=false
487
+ @aSOP_Headers=[]
488
+
489
+ get_Profiles_StandardObjectPermissions_table.each_with_index do |row, index|
490
+ next if index < 2
491
+ if index == 2
492
+ row.find_elements(:xpath => "./td[2]/table/tbody/tr[2]/th").each do |header|
493
+ @aSOP_Headers.push(header.text)
494
+ end
495
+ else
496
+ # -- Left Column of Table
497
+ row.find_elements(:xpath => "./td[1]/table/tbody/tr/td").each_with_index do |hv, idx|
498
+ if hv.find_elements(:xpath => ".//*").size > 0
499
+ sOrgSetting = hv.find_element(:xpath => "./input").selected? ? "Checked" : "Not Checked"
500
+ if !(sOrgSetting == hValues[row.find_element(:xpath => "./th[1]").text][@aSOP_Headers[idx]])
501
+ hv.find_element(:xpath => "./input").click
502
+ sMsg=""
503
+ a=@driver.switch_to.alert rescue "Exception happened"
504
+ if !(a == "Exception happened")
505
+ sMsg= "Accepting Alert: #{a.text}"
506
+ a.accept
507
+ end
508
+ blnReturn=true
509
+ end
510
+ end
511
+ end
512
+
513
+ # -- Right Column of Table
514
+ if row.find_element(:xpath => "./td[2]").attribute("class") != "labelCol last empty"
515
+ row.find_elements(:xpath => "./td[2]/table/tbody/tr/td").each_with_index do |hv, idx|
516
+ if hv.find_elements(:xpath => ".//*").size > 0
517
+ sOrgSetting = hv.find_element(:xpath => "./input").selected? ? "Checked" : "Not Checked"
518
+ if !(sOrgSetting == hValues[row.find_element(:xpath => "./th[2]").text][@aSOP_Headers[idx]])
519
+ hv.find_element(:xpath => "./input").click
520
+ sMsg=""
521
+ a=@driver.switch_to.alert rescue "Exception happened"
522
+ if !(a == "Exception happened")
523
+ sMsg= "Accepting Alert: #{a.text}"
524
+ a.accept
525
+ end
526
+ blnReturn=true
527
+ end
528
+ end
529
+ end
530
+ end
531
+
532
+ end
533
+ end
534
+
535
+ @driver.manage.timeouts.implicit_wait = @implicitWait
536
+ return blnReturn
537
+ end
538
+ # -----------------------------
539
+
540
+ # -----------------------------
541
+ # get_Profiles_CustomObjectPermissions
542
+ # => Returns an Nested Hash; {Object Name =>{Key = Header Name, Value = Checked/Unchecked}}
543
+ #
544
+ def get_Profiles_CustomObjectPermissions
545
+ @driver.manage.timeouts.implicit_wait = 0
546
+ begin
547
+ @aCOP_Headers=[]
548
+ response_hash = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) }
549
+
550
+ if get_Profiles_CustomProfile_CheckboxValue
551
+ get_Profiles_CustomObjectPermissions_table.each_with_index do |row, index|
552
+ if index == 0
553
+ row.find_elements(:xpath => "./td[2]/table/tbody/tr[2]/th").each do |header|
554
+ @aCOP_Headers.push(header.text.strip! || header.text)
555
+ end
556
+ else
557
+ # -- Left Column of Table
558
+ $tempObjectName_Left=row.find_element(:xpath => "./th[1]").text
559
+ row.find_elements(:xpath => "./td[1]/table/tbody/tr/td").each_with_index do |hv, idx|
560
+ # puts "Main Table Index: #{index}; Left Column Index: #{idx}"
561
+ print "\rMain Table Index: #{index}; Left Column Index: #{idx}"
562
+ response_hash[$tempObjectName_Left][@aCOP_Headers[idx]]=hv.find_element(:xpath => "./img").attribute("alt") unless hv.find_elements(:xpath => ".//*").size == 0
563
+ end
564
+
565
+ # -- Right Column of Table
566
+ if row.find_element(:xpath => "./td[2]").attribute("class") != "labelCol last empty"
567
+ $tempObjectName_Right=row.find_element(:xpath => "./th[2]").text
568
+ row.find_elements(:xpath => "./td[2]/table/tbody/tr/td").each_with_index do |hv, idx|
569
+ if hv.find_elements(:xpath => ".//*").size != 0
570
+ # puts "Main Table Index: #{index}; Right Column Index: #{idx}"
571
+ print "\rMain Table Index: #{index}; Right Column Index: #{idx}"
572
+ response_hash[$tempObjectName_Right][@aCOP_Headers[idx]]=hv.find_element(:xpath => "./img").attribute("alt") #unless hv.find_elements(:xpath => ".//*").size == 0
573
+ end
574
+ end
575
+ end
576
+ end
577
+ end
578
+ end
579
+ @driver.manage.timeouts.implicit_wait = @implicitWait
580
+ return response_hash
581
+ rescue
582
+ puts $!
583
+ puts $@
584
+ ensure
585
+ puts " "
586
+ @driver.manage.timeouts.implicit_wait = @implicitWait
587
+ end
588
+ end
589
+ # -----------------------------
590
+
591
+ # -----------------------------
592
+ # set_Profiles_CustomObjectPermissions
593
+ # => hValues = Hash of the values to be set for the indicated Profile/Section
594
+ # => Returns true/false
595
+ #
596
+ def set_Profiles_CustomObjectPermissions(hValues)
597
+ @driver.manage.timeouts.implicit_wait = 0
598
+ @aCOP_Headers=[]
599
+ blnReturn=false
600
+
601
+ get_Profiles_CustomObjectPermissions_table.each_with_index do |row, index|
602
+ if index == 0
603
+ row.find_elements(:xpath => "./td[2]/table/tbody/tr[2]/th").each do |header|
604
+ @aCOP_Headers.push(header.text)
605
+ end
606
+ else
607
+ # -- Left Column of Table
608
+ row.find_elements(:xpath => "./td[1]/table/tbody/tr/td").each_with_index do |hv, idx|
609
+ if hv.find_elements(:xpath => ".//*").size > 0
610
+ sOrgSetting = hv.find_element(:xpath => "./input").selected? ? "Checked" : "Not Checked"
611
+ print "Row/Index: #{index}; Label: #{row.find_element(:xpath => "./th[1]").text}; Hash Include True/False: #{hValues.include?(row.find_element(:xpath => "./th[1]").text)}\r"
612
+ if hValues.include?(row.find_element(:xpath => "./th[1]").text)
613
+ if !(sOrgSetting == hValues[row.find_element(:xpath => "./th[1]").text][@aCOP_Headers[idx]])
614
+ hv.find_element(:xpath => "./input").click
615
+ sMsg=""
616
+ a=@driver.switch_to.alert rescue "Exception happened"
617
+ if !(a == "Exception happened")
618
+ sMsg= "Accepting Alert: #{a.text}"
619
+ a.accept
620
+ end
621
+ blnReturn=true
622
+ end
623
+ end
624
+ end
625
+ end
626
+ # -- Right Column of Table
627
+ if row.find_element(:xpath => "./td[2]").attribute("class") != "labelCol last empty"
628
+ row.find_elements(:xpath => "./td[2]/table/tbody/tr/td").each_with_index do |hv, idx|
629
+ if hv.find_elements(:xpath => ".//*").size > 0
630
+ sOrgSetting = hv.find_element(:xpath => "./input").selected? ? "Checked" : "Not Checked"
631
+ if !(sOrgSetting == hValues[row.find_element(:xpath => "./th[2]").text][@aCOP_Headers[idx]])
632
+ hv.find_element(:xpath => "./input").click
633
+ sMsg=""
634
+ a=@driver.switch_to.alert rescue "Exception happened"
635
+ if !(a == "Exception happened")
636
+ sMsg= "Accepting Alert: #{a.text}"
637
+ a.accept
638
+ end
639
+ blnReturn=true
640
+ end
641
+ end
642
+ end
643
+ end
644
+ end
645
+ end
646
+ @driver.manage.timeouts.implicit_wait = @implicitWait
647
+ print "\n"
648
+ return blnReturn
649
+ end
650
+ # -----------------------------
651
+
652
+ # -----------------------------
653
+ # get_Profiles_ApexClassAccess
654
+ # => Returns an Array; [ApexClassAccess1, ApexClassAccess2]
655
+ #
656
+ def get_Profiles_ApexClassAccess
657
+ @driver.manage.timeouts.implicit_wait = 0
658
+ begin
659
+ aResponse=[]
660
+ if get_Profiles_CustomProfile_CheckboxValue
661
+ puts "Apex Class Access Row Count: #{get_Profiles_ApexClassAccess_table.size}"
662
+ get_Profiles_ApexClassAccess_table.each do |row|
663
+ # puts "Row Class Value: #{row.attribute("class")}"
664
+ aResponse.push(row.find_element(:xpath => "./th[1]/a").text) unless row.attribute('class')=='headerRow'
665
+ end
666
+ end
667
+
668
+ @driver.manage.timeouts.implicit_wait = @implicitWait
669
+ return aResponse
670
+ rescue
671
+ puts $!
672
+ puts $@
673
+ ensure
674
+ @driver.manage.timeouts.implicit_wait = @implicitWait
675
+ end
676
+ end
677
+ # -----------------------------
678
+
679
+ # -----------------------------
680
+ # set_Profiles_ApexClassAccess
681
+ # => hValues = Hash of the values to be set for the indicated Profile/Section
682
+ # => Returns true/false
683
+ #
684
+ def set_Profiles_ApexClassAccess(hValues)
685
+ @driver.manage.timeouts.implicit_wait = 0
686
+ blnReturn=false
687
+ begin
688
+ hValues.each do |value|
689
+ options=get_Profiles_ApexClassAccess_AvailableSelect
690
+ options.each do |option_s|
691
+ if option_s.text == value
692
+ option_s.click
693
+ click_btn_Profiles_ApexClassAccess_Add
694
+ blnReturn=true
695
+ break
696
+ end
697
+ end
698
+ end
699
+
700
+ @driver.manage.timeouts.implicit_wait = @implicitWait
701
+ return blnReturn
702
+ rescue
703
+ puts $!
704
+ puts $@
705
+ ensure
706
+ @driver.manage.timeouts.implicit_wait = @implicitWait
707
+ end
708
+ end
709
+ # -----------------------------
710
+
711
+ # -----------------------------
712
+ # get_Profiles_VisualforcePageAccess
713
+ # => Returns an Array; [VfPageAccess1, VfPageAccess2]
714
+ #
715
+ def get_Profiles_VisualforcePageAccess
716
+ @driver.manage.timeouts.implicit_wait = 0
717
+ begin
718
+ aResponse=[]
719
+ puts "Visualforce Page Access Row Count: #{get_Profiles_VisualforcePageAccess_table.size}"
720
+ get_Profiles_VisualforcePageAccess_table.each do |row|
721
+ aResponse.push(row.find_element(:xpath => "./th[1]/a").text) unless row.attribute('class')=='headerRow'
722
+ end
723
+
724
+ @driver.manage.timeouts.implicit_wait = @implicitWait
725
+ return aResponse
726
+ rescue
727
+ puts $!
728
+ puts $@
729
+ ensure
730
+ @driver.manage.timeouts.implicit_wait = @implicitWait
731
+ end
732
+ end
733
+ # -----------------------------
734
+
735
+ # -----------------------------
736
+ # set_Profiles_VisualforcePageAccess
737
+ # => hValues = Hash of the values to be set for the indicated Profile/Section
738
+ # => Returns true/false
739
+ #
740
+ def set_Profiles_VisualforcePageAccess(hValues)
741
+ @driver.manage.timeouts.implicit_wait = 0
742
+ blnReturn=false
743
+ begin
744
+ # -- Remove already 'enabled' VF Pages from hValues
745
+ hValues.each do |value|
746
+ options=get_Profile_VisualforcePageAccess_EnabledSelect
747
+ options.each do |option_es|
748
+ if option_es.text == value
749
+ hValues=hValues - [value]
750
+ break
751
+ end
752
+ end
753
+ end
754
+ puts "hValue Count after looking at enabled list: #{hValues.size}"
755
+
756
+ hValues.each do |value|
757
+ options=get_Profiles_ApexClassAccess_AvailableSelect
758
+ options.each do |option_s|
759
+ if option_s.text == value
760
+ option_s.click
761
+ click_btn_Profiles_ApexClassAccess_Add
762
+ blnReturn=true
763
+ break
764
+ end
765
+ end
766
+ end
767
+
768
+ @driver.manage.timeouts.implicit_wait = @implicitWait
769
+ return blnReturn
770
+ rescue
771
+ puts $!
772
+ puts $@
773
+ ensure
774
+ @driver.manage.timeouts.implicit_wait = @implicitWait
775
+ end
776
+ end
777
+ # -----------------------------
778
+
779
+ end
780
+ end