-
Notifications
You must be signed in to change notification settings - Fork 369
/
setup_dev_org.py
executable file
·148 lines (129 loc) · 6.3 KB
/
setup_dev_org.py
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/python
import os
import time
import ConfigParser
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.common.action_chains import ActionChains
from getpass import getpass
npsp_user = None
npsp_pass = None
def main():
global npsp_user
npsp_user = raw_input('Dev Org Username: ')
global npsp_pass
npsp_pass = getpass('Dev Org Password: ')
config_file = os.path.dirname(os.path.abspath(__file__)) + '/cumulus.cfg'
global config
config = ConfigParser.ConfigParser()
config.readfp(open(config_file))
# Setup selenium session
wd = WebDriver()
wd.implicitly_wait(60)
# Initial login
wd.get("https://login.salesforce.com/")
login(wd)
# Setup an Opportunity Record Type
create_sales_process(wd)
create_opp_record_type(wd)
# Install NPSP Packages
install_pkg_contactsandorganizations(wd)
#install_pkg_households(wd)
install_pkg_relationships(wd)
install_pkg_affiliations(wd)
install_pkg_recurringdonations(wd)
# Action methods
def login(wd):
wd.find_element_by_id("username").click()
wd.find_element_by_id("username").clear()
wd.find_element_by_id("username").send_keys(npsp_user)
wd.find_element_by_id("password").click()
wd.find_element_by_id("password").clear()
wd.find_element_by_id("password").send_keys(npsp_pass)
wd.find_element_by_id("Login").click()
def create_sales_process(wd):
wd.find_element_by_id("userNavLabel").click()
wd.find_element_by_link_text("Setup").click()
wd.find_element_by_css_selector("#Customize_icon > img.setupImage").click()
wd.find_element_by_css_selector("#Opportunity_icon > img.setupImage").click()
wd.find_element_by_id("OpportunityProcess_font").click()
wd.find_element_by_name("new").click()
wd.find_element_by_id("p3").click()
wd.find_element_by_id("p3").clear()
wd.find_element_by_id("p3").send_keys("Default")
wd.find_element_by_id("p4").click()
wd.find_element_by_css_selector("#bottomButtonRow > input[name=\"save\"]").click()
wd.find_element_by_name("save").click()
def create_opp_record_type(wd):
wd.find_element_by_id("OpportunityRecords_font").click()
wd.find_element_by_name("new").click()
wd.find_element_by_id("p2").click()
wd.find_element_by_id("p2").clear()
wd.find_element_by_id("p2").send_keys("Default")
wd.find_element_by_id("p52").click()
if not wd.find_element_by_xpath("//table[@class='detailList']//select[normalize-space(.)='--None--Default']//option[text()='Default']").is_selected():
wd.find_element_by_xpath("//table[@class='detailList']//select[normalize-space(.)='--None--Default']//option[text()='Default']").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_name("save").click()
if not wd.find_element_by_xpath("//div[@class='pbWizardBody']/table[1]/tbody/tr[1]/td[2]/select//option[text()='Opportunity Layout']").is_selected():
wd.find_element_by_xpath("//div[@class='pbWizardBody']/table[1]/tbody/tr[1]/td[2]/select//option[text()='Opportunity Layout']").click()
wd.find_element_by_css_selector("div.pbWizardBody").click()
wd.find_element_by_name("save").click()
def install_pkg_contactsandorganizations(wd):
wd.get(config.get('npe01','install_url'))
#login(wd)
wd.find_element_by_id("InstallPackagePage:InstallPackageForm:InstallBtn").click()
wd.find_element_by_css_selector("label").click()
if not wd.find_element_by_id("simpleDialog0checkbox").is_selected():
wd.find_element_by_id("simpleDialog0checkbox").click()
wd.find_element_by_id("simpleDialog0button0").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_xpath("//table[@class='selectSecurity']//label[.='*Grant access to all users']").click()
wd.find_element_by_id("p201FULL").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_name("save").click()
def install_pkg_households(wd):
wd.get(config.get('npo2','install_url'))
#login(wd)
wd.find_element_by_id("InstallPackagePage:InstallPackageForm:InstallBtn").click()
wd.find_element_by_xpath("//div[@id='simpleDialog0Content']/table/tbody/tr/td[2]/div").click()
if not wd.find_element_by_id("simpleDialog0checkbox").is_selected():
wd.find_element_by_id("simpleDialog0checkbox").click()
wd.find_element_by_id("simpleDialog0button0").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_xpath("//table[@class='selectSecurity']//label[.='*Grant access to all users']").click()
wd.find_element_by_id("p201FULL").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_name("save").click()
def install_pkg_relationships(wd):
wd.get(config.get('npe4','install_url'))
#login(wd)
wd.find_element_by_id("InstallPackagePage:InstallPackageForm:InstallBtn").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_xpath("//table[@class='selectSecurity']//label[.='*Grant access to all users']").click()
wd.find_element_by_id("p201FULL").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_name("save").click()
def install_pkg_affiliations(wd):
wd.get(config.get('npe5','install_url'))
#login(wd)
wd.find_element_by_id("InstallPackagePage:InstallPackageForm:InstallBtn").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_xpath("//table[@class='selectSecurity']//label[.='*Grant access to all users']").click()
wd.find_element_by_id("p201FULL").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_name("save").click()
def install_pkg_recurringdonations(wd):
wd.get(config.get('npe03','install_url'))
#login(wd)
wd.find_element_by_id("InstallPackagePage:InstallPackageForm:InstallBtn").click()
#wd.find_element_by_css_selector("label").click()
#if not wd.find_element_by_id("simpleDialog0checkbox").is_selected():
# wd.find_element_by_id("simpleDialog0checkbox").click()
#wd.find_element_by_id("simpleDialog0button0").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_xpath("//table[@class='selectSecurity']//label[.='*Grant access to all users']").click()
wd.find_element_by_id("p201FULL").click()
wd.find_element_by_name("goNext").click()
wd.find_element_by_name("save").click()
if __name__ == '__main__':
main()