-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenu.py
72 lines (61 loc) · 2.38 KB
/
openu.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
#!/usr/bin/env python
# coding=utf-8
# import pprint
import csv
import click
# import requests
import datetime as datetime
# from bs4 import BeautifulSoup
# from splinter import Browser
import time
# import re
# import copy
import os
import json
# import pickle
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import ElementNotVisibleException
from selenium.common.exceptions import StaleElementReferenceException
from selenium.common.exceptions import WebDriverException
from selenium.common.exceptions import TimeoutException
# from requests.exceptions import ConnectionError
# from requests.exceptions import ChunkedEncodingError
# from requests.exceptions import ReadTimeout
# from selenium.webdriver import ChromeOptions
SCROLL_PAUSE_TIME = 3
@click.command()
# @click.option('--org', default='db8417df-3379-45a4-a684-376923e19c58')
# @click.option('--u', default='867ab46b-4106-49b8-ab73-b642421a4406')
@click.option('--u', default='gamesunion')
# @click.option('--days', default=1, type=int)
# @click.option('--session_id', default='2171486e6c13b61ad78b34a59f337ab0')
# def collector(secrets, url, session_id):
def openu(u):
with open('secrets.json') as f:
data = json.load(f)
print('Secrets... {}'.format(data))
org_url = 'https://www.tenjin.com/dashboard/admin/organizations'
url = '/'.join([org_url, data[u]['org']])
driver = webdriver.Chrome('/Users/yuleng/wxbot/chromedriver')
driver.get(url)
username = driver.find_element_by_id(data['tenjin']['login_id'])
username.send_keys(data['tenjin']['login'])
password = driver.find_element_by_id(data['tenjin']['password_id'])
password.send_keys(data['tenjin']['password'])
btn = driver.find_element_by_id(data['tenjin']['login_btn_id'])
btn.click()
time.sleep(3)
# impersonate_url = 'https://www.tenjin.com/dashboard/admin/users/{}/become'.format(u)
impersonate_btn = driver.find_element_by_css_selector(data['impersonate_css'])
impersonate_btn.click()
# driver.get(impersonate_url)
input("Press Enter to continue...")
driver.close()
return
if __name__ == '__main__':
openu()
# https://www.tenjin.com/dashboard/admin/organizations/db8417df-3379-45a4-a684-376923e19c58