-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_user.py
112 lines (94 loc) · 3.31 KB
/
create_user.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
import sys
from selene.browsers import BrowserName
from selene.api import *
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
import traceback
from time import sleep
import ssl
import datetime
import schedule
#各種パロメータの設定
users = [
"userA",
"userB"
]
names = [
"username A",
"username B",
]
def main():
try:
#setupu
config.browser_name = BrowserName.CHROME
chrome_option = webdriver.ChromeOptions()
chrome_option.add_argument("--disable-gpu")
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_option)
browser.set_driver(driver)
#access
browser.open_url("https://redmine_link")
#login
element = driver.find_element(By.CLASS_NAME,"login")
element.click()
element = driver.find_element(By.ID,"username")
element.clear()
element.send_keys("admin")
element = driver.find_element(By.ID,"password")
element.clear()
element.send_keys("ttkh0218")
element = driver.find_element(By.ID,"login-submit")
element.click()
print("ログイン完了")
sleep(5)
element = driver.find_element(By.CLASS_NAME,"administration")
element.click()
sleep(1)
element = driver.find_element(By.XPATH,"/html/body/div[1]/div[2]/div[1]/div[3]/div[2]/div[1]/div[2]/ul/li[2]/a")
element.click()
sleep(1)
element = driver.find_element(By.XPATH,"/html/body/div[1]/div[2]/div[1]/div[3]/div[2]/div[1]/a")
element.click()
sleep(1)
#input user information
for i,d in enumerate(users):
#user id
element = driver.find_element(By.ID,"user_login")
element.clear()
print(users[i])
element.send_keys(users[i])
#name
name = names[i]
print(name)
name_dic= name.split(" ")
first_name = name_dic[0]
last_name = name_dic[1]
element = driver.find_element(By.ID, "user_firstname")
element.clear()
element.send_keys(first_name)
element = driver.find_element(By.ID, "user_lastname")
element.clear()
element.send_keys(last_name)
element = driver.find_element(By.ID, "user_mail")
element.clear()
element.send_keys(users[i] + "@g.nihon-u.ac.jp")
element = driver.find_element(By.ID, "user_language")
Select(element).select_by_value("ja")
element.click()
#password
element = driver.find_element(By.ID, "user_password")
element.clear()
element.send_keys(users[i])
element = driver.find_element(By.ID, "user_password_confirmation")
element.clear()
element.send_keys(users[i])
#create_user_to_next
element = driver.find_element(By.XPATH,"/html/body/div[1]/div[2]/div[1]/div[3]/div[2]/form/p[2]/input[2]")
element.click()
sleep(1)
browser.quit()
except:
print(traceback.format_exc())
browser.quit()
main()