-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentry_provider.py
94 lines (71 loc) · 2.94 KB
/
sentry_provider.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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import platform
import os
import time
class SentryProvider:
LOGIN_URL="https://sentry.io/auth/login/"
INVITE_URL="https://sentry.io/settings/pt-jurnal-consulting-indonesia/members/"
def __init__(self, email):
self.email = email
def onboard(self):
driver = self.setup_driver()
print("\n- Start onboarding Sentry")
try:
self.sign_in(driver)
self.invite_user(driver)
self.check_invitation(driver)
print("- Finish onboarding Sentry")
except Exception as e:
print("- Error " + str(e))
finally:
driver.close()
def sign_in(self, driver):
driver.get(self.LOGIN_URL)
print("- Sign In Sentry")
username_input = driver.find_element_by_name("username")
username_input.send_keys(os.environ["SENTRY_USERNAME"].strip())
print("- Filling username")
password_input = driver.find_element_by_name("password")
password_input.send_keys(os.environ["SENTRY_PASSWORD"].strip())
print("- Filling password")
driver.find_element_by_xpath('//button[text()="Continue"]').click()
print("- Submit login form")
def invite_user(self, driver):
self.delay(2)
driver.get(self.INVITE_URL)
print("- Visit invite page")
self.delay(3)
driver.find_element_by_xpath('//span[contains(text(), "Invite Members")]').click()
self.delay(1)
email_input = driver.find_element_by_xpath("//input[@aria-activedescendant='react-select-2--value']")
email_input.send_keys(self.email)
print("- Invite email " + self.email)
driver.find_element_by_xpath('//p[contains(text(), "Invite new members by email to join your organization.")]').click()
self.delay(2)
driver.find_element_by_xpath('//span[contains(text(), "Send invite")]').click()
print("- Submit invite form")
def check_invitation(self, driver):
self.delay(3)
driver.find_element_by_xpath("//strong[contains(text(), '1 invite')]")
print("- Check invitation success")
def delay(self, second):
time.sleep(second)
def setup_driver(self):
# setup headless and chromedriver
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_driver = os.getcwd() + "/chromedriver" + self.driver_os()
# setup selenium driver using chrome
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)
return driver
def driver_os(self):
os_type = platform.system()
if os_type == "Linux":
return "_linux"
elif os_type == "Darwin":
return "_mac"
else:
return ""