Modify create_user and add_user_profile functions
This commit is contained in:
parent
f3da8d34b3
commit
9db4fda87d
|
@ -8,55 +8,66 @@ from common_functions_60 import *
|
|||
import random, time
|
||||
import string
|
||||
|
||||
def add_user_profile(driver,user_name,profile,group):
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_id("text-filter_search").clear()
|
||||
driver.find_element_by_id("text-filter_search").send_keys(user_name)
|
||||
driver.find_element_by_id("submit-search").click()
|
||||
driver.find_element_by_xpath('//*[@id="table3-0-6"]/a[2]').click()
|
||||
Select(driver.find_element_by_id("assign_profile")).select_by_visible_text(profile)
|
||||
|
||||
if group == "All":
|
||||
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(group)
|
||||
else:
|
||||
#TODO This will not work when choosing a group within a group within another group
|
||||
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(" "+group)
|
||||
def add_user_profile(driver,user_name,profile,group,tags=[]):
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_css_selector("b").click()
|
||||
driver.find_element_by_id("text-filter_search").clear()
|
||||
driver.find_element_by_id("text-filter_search").send_keys(user_name)
|
||||
driver.find_element_by_id("submit-search").click()
|
||||
driver.find_element_by_xpath('//*[@id="table3-0-6"]/a[2]').click()
|
||||
Select(driver.find_element_by_id("assign_profile")).select_by_visible_text(profile)
|
||||
|
||||
#driver.find_element_by_id("image-add2").click()
|
||||
driver.find_element_by_xpath('//*[@name="add"]').click()
|
||||
if group == "All":
|
||||
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(group)
|
||||
else:
|
||||
#TODO This will not work when choosing a group within a group within another group
|
||||
Select(driver.find_element_by_id("assign_group")).select_by_visible_text(" "+group)
|
||||
|
||||
#driver.find_element_by_id("image-add2").click()
|
||||
|
||||
for tag in tags:
|
||||
Select(driver.find_element_by_id("assign_tags")).select_by_visible_text(tag)
|
||||
|
||||
#If we do not provide tags, we NEED to leave "Any" selected, otherwise we need to deselect it.
|
||||
if tags != []:
|
||||
Select(driver.find_element_by_id("assign_tags")).deselect_by_visible_text("Any")
|
||||
|
||||
driver.find_element_by_xpath('//*[@name="add"]').click()
|
||||
|
||||
|
||||
|
||||
def create_user(driver,user_name,userpwd,email=None,profile_list=None,is_admin=False):
|
||||
|
||||
u"""
|
||||
Profile list es una LISTA de TUPLAS:
|
||||
l = [("Chief Operator","All"),("Read Operator","Servers")]
|
||||
"""
|
||||
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_name("id_user").clear()
|
||||
driver.find_element_by_name("id_user").send_keys(user_name)
|
||||
driver.find_element_by_name("password_new").clear()
|
||||
driver.find_element_by_name("password_new").send_keys(userpwd)
|
||||
driver.find_element_by_name("password_confirm").clear()
|
||||
driver.find_element_by_name("password_confirm").send_keys(userpwd)
|
||||
driver.find_element_by_name("email").clear()
|
||||
u"""
|
||||
Profile list es una LISTA de TUPLAS:
|
||||
l = [("Chief Operator","All",[]),("Read Operator","Servers",["tag1","tag2"])]
|
||||
"""
|
||||
|
||||
if is_admin == True:
|
||||
driver.find_element_by_id('radiobtn0001').click()
|
||||
click_menu_element(driver,"Users management")
|
||||
driver.find_element_by_id("submit-crt").click()
|
||||
driver.find_element_by_name("id_user").clear()
|
||||
driver.find_element_by_name("id_user").send_keys(user_name)
|
||||
driver.find_element_by_name("password_new").clear()
|
||||
driver.find_element_by_name("password_new").send_keys(userpwd)
|
||||
driver.find_element_by_name("password_confirm").clear()
|
||||
driver.find_element_by_name("password_confirm").send_keys(userpwd)
|
||||
driver.find_element_by_name("email").clear()
|
||||
|
||||
if is_admin == False:
|
||||
driver.find_element_by_id('radiobtn0002').click()
|
||||
if is_admin == True:
|
||||
driver.find_element_by_id('radiobtn0001').click()
|
||||
|
||||
if email != None:
|
||||
driver.find_element_by_name("email").clear()
|
||||
driver.find_element_by_name("email").send_keys(email)
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
if is_admin == False:
|
||||
driver.find_element_by_id('radiobtn0002').click()
|
||||
|
||||
if profile_list != None:
|
||||
for profile_name,group_name in profile_list:
|
||||
add_user_profile(driver,user_name,profile_name,group_name)
|
||||
if email != None:
|
||||
driver.find_element_by_name("email").clear()
|
||||
driver.find_element_by_name("email").send_keys(email)
|
||||
driver.find_element_by_id("submit-crtbutton").click()
|
||||
|
||||
if profile_list != None:
|
||||
for profile_name,group_name,tag_list in profile_list:
|
||||
add_user_profile(driver,user_name,profile_name,group_name,tags=tag_list)
|
||||
|
||||
|
||||
def search_user(driver,user_name):
|
||||
|
|
Loading…
Reference in New Issue