How to use get_info_dict method in autotest

Best Python code snippet using autotest_python

web_copy.py

Source:web_copy.py Github

copy

Full Screen

1## Selenium을 활용한 웹페이지 양식을 excel 에서 채워넣는 스크립트2## 텍스트 copy 및 select 바 선택만을 사용하였습니다.3from time import sleep4from distutils.log import info5from tkinter.tix import Tree6from matplotlib.pyplot import getp7from numpy import empty8import selenium9from selenium import webdriver10from selenium.webdriver import ActionChains11from selenium.webdriver.support import expected_conditions as EC12from selenium.webdriver.support.ui import WebDriverWait as wait13from selenium.webdriver.support.ui import Select14from selenium.webdriver.common.keys import Keys15from selenium.webdriver.common.by import By16import pandas as pd17from datetime import datetime18from getpass import getpass19import tkinter as tk20from tkinter import filedialog21from tkinter import messagebox22import openpyxl23# 엑셀데이터 알람24def alrt(name,infomiss,data=0):25 #print(data.isna().sum())26 print(name+"고객님의 "+infomiss+" 정보가 비어있습니다.")27 return "{infomiss}정보가 비어있습니다.".format(infomiss=infomiss)28# 데이터 처리29def process(name,sheet_name):30 info_dic = dict()31 y = df.loc[ df [ '성명' ] == name ]32 try:33 birth = ''.join(y['생년월일'])34 birth = datetime.strptime(birth,'%Y-%m-%d').date()35 today = datetime.now().date()36 year = today.year - birth.year37 if today.month < birth.month or (today.month == birth.month and today.day < birth.day):38 year-=139 info_dic=dict({40 '장기중기' : '☑ 장기' if '장기' in sheet_name else '☑ 중기',41 'N차' : sheet_name.split('-')[1][0:1],42 '성명' : ''.join(y['성명']),43 '생년월일' : ''.join(y['생년월일']) if y['생년월일'].isna().sum()==0 else alrt(name,'생년월일'),44 '성별' : ''.join(y['성별']) if y['성별'].isna().sum()==0 else alrt(name,'성별'),45 '소속' : ''.join(y['소속']) if y['소속'].isna().sum()==0 else alrt(name,'소속'),46 '나이' : year,47 '연락처' : ''.join(y['연락처']) if y['연락처'].isna().sum()==0 else alrt(name,'전화번호'),48 '이메일' : ''.join(y['E-mail 주소']) if y['E-mail 주소'].isna().sum()==0 else alrt(name,'이메일'),49 '기본주소' : ''.join(y['기본주소']) if y['기본주소'].isna().sum()==0 else alrt(name,'기본주소'),50 '군' : ''.join(y['군']) if y['군'].isna().sum()==0 else alrt(name,'군'),51 '계급' : ''.join(y['계급']) if y['계급'].isna().sum()==0 else alrt(name,'계급'),52 '병과' : ''.join(y['병과']) if y['병과'].isna().sum()==0 else alrt(name,'병과'),53 '군번' : ''.join(y['군번']) if y['군번'].isna().sum()==0 else alrt(name,'군번'),54 '전역예정일' : ''.join(y['전역(예정)일']) if y['전역(예정)일'].isna().sum()==0 else alrt(name,'전역예정일'),55 '복무기간_년' : ''.join(y['복무기간']).split(" ")[0].replace("년",'') if y['복무기간'].isna().sum()==0 else alrt(name,'복무기간_년'),56 '복무기간_월' : ''.join(y['복무기간']).split(" ")[1].replace("개월",'') if y['복무기간'].isna().sum()==0 else alrt(name,'복무기간_월'),57 '권역_영등포' : '√' if '영등포' == ''.join(y['센터']) else '',58 '권역_서울숲' : '√' if '서울' == ''.join(y['센터']) else '',59 '권역_수원' : '√' if '수원' == ''.join(y['센터']) else '',60 '권역_파주' : '√' if '파주' == ''.join(y['센터']) else '',61 '동의함' : '☑',62 '수신자' : ''.join(y['성명']) + " 선생님",63 '우편번호' : '00000'64 })65 66 except Exception as e:67 print("\n"+name+"고객님의 엑셀 정보획드에 실패하였습니다 에러코드 {e}".format(e=e))68 69 return info_dic70messagebox.showinfo("사용법", "엑셀을 선택하여 주세요!")71file_path_ex = filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx")])72wb = openpyxl.load_workbook(file_path_ex)73ws = wb.active74sheet_name = str(ws.title)75id = str(input('아이디를 입력하세요 : '))76pwd = getpass('비밀번호를 입력하세요 : ')77service_start = str(input('서비스 시작일자 : '))78service_end = str(input('서비스 종료일자 : '))79service_add = str(input('서비스 등록일자 : '))80while True:81 #1. 엑셀파일 열기82 df = pd.read_excel(r'{}'.format(file_path_ex), sheet_name=sheet_name,header=2)83 if '장기' in sheet_name:84 print("\n----장기고객입니다----")85 elif '중기' in sheet_name:86 print("\n----중기고객입니다----")87 print("\n----엑셀파일에 있는 이름들입니다----")88 print(df['성명'])89 print("----------------------------------\n")90 while True:91 name = str(input('처리하고자 하는 사람의 이름을 입력하세요 : '))92 if df['성명'].str.contains(name).any() :93 break94 else:95 print("이름을 다시 입력하세요 잘못입력했거나 excel 파일에 해당 이름이 없습니다.")96 #2. 사이트 접속97 URL = 'https://cloud.sscrm.co.kr/Login.aspx'98 options = webdriver.ChromeOptions()99 options.add_experimental_option("excludeSwitches", ["enable-logging"])100 driver = webdriver.Chrome(executable_path='chromedriver',options=options)101 driver.get(url=URL)102 tabs = driver.window_handles103 print(tabs)104 #3. 로그인작업105 driver.find_element_by_xpath('//*[@id="txtLoginID"]').send_keys('{id}'.format(id=id))106 driver.find_element_by_xpath('//*[@id="txtPassword"]').send_keys('{pwd}'.format(pwd=pwd))107 try:108 driver.find_element_by_xpath('//*[@id="btnLogin"]').click()109 except Exception as e:110 driver.find_element_by_xpath('//*[@id="Notice"]/div/div[3]/span[2]/input').click()111 driver.find_element_by_xpath('//*[@id="btnLogin"]').click()112 113 #4. 고객 정보 입력 이동114 driver.get(url="https://cloud.sscrm.co.kr/Pages__C002/CS/CSCI_List.aspx")115 driver.find_element_by_xpath('//*[@id="ucLeft_listCS12"]/a').click()116 #5. 고객 정보 입력 117 get_info_dict = process(name,sheet_name)118 if get_info_dict is not empty:119 driver.find_element_by_xpath("//*[@id='divRight']/div/table[2]/tbody/tr[1]/td[2]/img[1]").click()120 driver.switch_to.window(driver.window_handles[1])121 driver.find_element_by_xpath('/html/body/form/div[3]/table/tbody/tr/td/div/table[2]/tbody/tr/td[2]/input').send_keys("전역장병")122 driver.find_element_by_xpath('//*[@id="ContentPage_btnSearch"]').click()123 if '장기' in sheet_name:124 driver.find_element_by_xpath("//*[@id='ContentPage_gvList_btnClientNm_1']").click()125 else :126 driver.find_element_by_xpath("//*[@id='ContentPage_gvList_btnClientNm_0']").click()127 driver.switch_to.window(driver.window_handles[0])128 driver.find_element_by_xpath("//select[@name='ctl00$ContentPage$FLD_CTCCODE']/option[text()='파주지사']").click() # CTC129 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_CUSTNM"]').send_keys(get_info_dict['성명']) # 고객명130 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_EMAIL"]').send_keys(get_info_dict['이메일']) # 이메일131 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_MOBILE"]').send_keys(get_info_dict['연락처']) # 휴대폰132 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_BIRTHDAY"]').send_keys(get_info_dict['생년월일']) # 생년월일133 driver.find_element_by_xpath("//select[@name='ctl00$ContentPage$FLD_SEX']/option[text()='{sex}']".format(sex=get_info_dict['성별'])).click() # 성별134 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_WORKCOMPANYNAME"]').send_keys(get_info_dict['군'])135 driver.find_element_by_xpath("//select[@name='ctl00$ContentPage$FLD_CAREERGOALCODE']/option[text()='취업']").click() # 경력목표136 driver.find_element_by_xpath("//select[@name='ctl00$ContentPage$FLD_PROCESSSTATUSCODE']/option[text()='진행중']").click() # 진행상황137 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_SERVICEBEGINDATE"]').clear() # 서비스 시작일자 초기화138 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_SERVICEENDDATE"]').clear() # 서비스 종료일자 초기화139 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_SERVICEREGDATE"]').clear() # 서비스 등록일자 초기화140 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_SERVICEBEGINDATE"]').send_keys(service_start) # 서비스 시작일자141 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_SERVICEENDDATE"]').send_keys(service_end) # 서비스 종료일자142 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_SERVICEREGDATE"]').send_keys(service_add) # 서비스 등록일자143 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_ADDRESS1"]').send_keys('{addr}'.format(addr=get_info_dict['기본주소'])) # 주소144 if get_info_dict['군'] =='해병대':145 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_WORKRANK"]').send_keys('{army} {rank}'.format(army=get_info_dict['군'][:2],rank=get_info_dict['계급'])) # 직급계급146 else :147 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_WORKRANK"]').send_keys('{army} {rank}'.format(army=get_info_dict['군'][:1],rank=get_info_dict['계급'])) # 직급계급148 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_WORKRETIREDATE"]').send_keys('{}'.format(get_info_dict['전역예정일'])) # 퇴역일 149 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_ARMYWORKTYPE"]').send_keys('{armytype}'.format(armytype=get_info_dict['병과'])) # 병과150 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_WORKDEPARTMENT"]').send_keys('{armytype}'.format(armytype=get_info_dict['소속'])) # 부서151 driver.find_element_by_xpath('//*[@id="ContentPage_FLD_WORKYEAR"]').send_keys('{}년'.format(get_info_dict['복무기간_년'])) # 근무기간 년152 if get_info_dict['복무기간_월']!='0':153 driver.find_element_by_xpath("//select[@name='ctl00$ContentPage$FLD_WORKMONTH']/option[text()='{WORKMONTH}']".format(WORKMONTH=get_info_dict['복무기간_월'])).click() # 근무기간 월154 driver.find_element_by_xpath("//select[@name='ctl00$ContentPage$FLD_USEYN']/option[text()='사용가능']").click() # 커리어플러스사용여부155 else :156 messagebox.showinfo("사용법", "엑셀 데이터를 확인해주세요")157 driver.close()158 if input("종료하시겠습니까? (Y/N) : ") == 'Y':...

Full Screen

Full Screen

dijkstras_testing.py

Source:dijkstras_testing.py Github

copy

Full Screen

...33 if not edge_weight:34 edge_weight = edge_weights.get((node2,node1))35 return edge_weight36# Sets attributes for nodes, including names37def get_info_dict(node):38 info_dict = {0: {'name': 'Hassyampa'},39 1: {'name': 'Subway'},40 2: {'name': 'R1'},41 3: {'name': 'Adelphi Commons'},42 4: {'name': 'Starbucks'},43 5: {'name': 'R2'},44 6: {'name': 'Vista Del Sol'},45 7: {'name': 'Papa Johns'},46 8: {'name': 'R6'},47 9: {'name': 'R3'},48 10: {'name': 'Barrett'},49 11: {'name': 'R7'},50 12: {'name': 'R5'},51 13: {'name': 'McDonalds'},52 14: {'name': 'R4'},53 15: {'name': 'Taco Bell'},54 16: {'name': 'Tooker House'},55 17: {'name': 'Sonora'}, 56 } 57 return info_dict[node]58#code for heuristic attribute if required 59def get_heuristic(node_x, node_y):60 pass61# Code from networkx that creates the graph62G = nx.Graph()63G.add_nodes_from([(0, get_info_dict(0)), 64 (1, get_info_dict(1)), 65 (2, get_info_dict(2)), 66 (3, get_info_dict(3)),67 (4, get_info_dict(4)),68 (5, get_info_dict(5)),69 (6, get_info_dict(6)),70 (7, get_info_dict(7)),71 (8, get_info_dict(8)),72 (9, get_info_dict(9)),73 (10, get_info_dict(10)),74 (11, get_info_dict(11)),75 (12, get_info_dict(12)),76 (13, get_info_dict(13)),77 (14, get_info_dict(14)),78 (15, get_info_dict(15)),79 (16, get_info_dict(16)),80 (17, get_info_dict(17)),81 ])82e = [(0, 1, get_dist_metric(0,1)), 83 (0, 2, get_dist_metric(0,2)), 84 (0, 5, get_dist_metric(0,5)), 85 (2, 3, get_dist_metric(2,3)), 86 (2, 4, get_dist_metric(2,4)), 87 (2,6, get_dist_metric(2,6)), 88 (1,2, get_dist_metric(1,2)), 89 (4,6,get_dist_metric(4,6)), 90 (1,9,get_dist_metric(1,9)), 91 (3,17,get_dist_metric(3,17)), 92 (5,8,get_dist_metric(5,8)), 93 (5,10,get_dist_metric(5,10)), 94 (5,7,get_dist_metric(5,7)), ...

Full Screen

Full Screen

query.py

Source:query.py Github

copy

Full Screen

2import numpy as np3from scipy.stats import norm4from active_reward_learning.util.helpers import get_array_from_scalar5from active_reward_learning.util.video import save_video6def get_info_dict(info):7 return tuple(info)8class QueryBase:9 def __init__(self):10 self.info = None11 def _asdict(self):12 raise NotImplementedError()13class LinearQuery(QueryBase):14 def __init__(self, gp_repr_list, linear_combination, reward, info):15 self.gp_repr_list = get_array_from_scalar(gp_repr_list)16 self.linear_combination = get_array_from_scalar(linear_combination)17 self.reward_ = reward18 self.info = info19 @property20 def reward(self):21 return self.reward_22 def __hash__(self):23 l = (24 tuple(25 [26 gp_repr.tostring()27 if isinstance(gp_repr, np.ndarray)28 else str(gp_repr)29 for gp_repr in self.gp_repr_list30 ]31 ),32 tuple(33 [34 a.tostring() if isinstance(a, np.ndarray) else str(a)35 for a in self.linear_combination36 ]37 ),38 self.reward,39 get_info_dict(self.info),40 )41 return hash(l)42 def _asdict(self):43 return {44 "gp_repr_list": [list(gp_repr) for gp_repr in self.gp_repr_list],45 "reward": float(self.reward),46 "info": get_info_dict(self.info),47 }48 def __eq__(self, other):49 return self.__hash__() == hash(other)50 def to_file(self, path, filename="query.txt"):51 file_path = os.path.join(path, filename)52 s = (53 str(self.gp_repr_list)54 + "\n\n"55 + str(self.linear_combination)56 + "n\n"57 + str(self.reward_)58 )59 with open(file_path, "w"):60 print(s)61 return file_path62class PointQuery(LinearQuery):63 def __init__(self, gp_repr, reward, info):64 self.gp_repr = get_array_from_scalar(gp_repr)65 super().__init__([gp_repr], [1], reward, info)66 def __hash__(self):67 l = (68 self.gp_repr.tostring(),69 self.reward,70 get_info_dict(self.info),71 )72 return hash(l)73 def _asdict(self):74 return {75 "gp_repr": self.gp_repr.tolist(),76 "reward": float(self.reward),77 "info": get_info_dict(self.info),78 }79 def __eq__(self, other):80 return self.__hash__() == hash(other)81class TrajectoryQuery(LinearQuery):82 def __init__(self, gp_repr_list, reward_list, info, rgb_arrays=None):83 reward = sum(reward_list)84 self.reward_list = reward_list85 self.rgb_arrays = rgb_arrays86 super().__init__(gp_repr_list, [1] * len(gp_repr_list), reward, info)87 def to_file(self, path, filename="query.gif"):88 if self.rgb_arrays is None:89 filename += ".txt"90 return super().to_file(path, filename=filename)91 else:92 file_path = os.path.join(path, filename)93 save_video(self.rgb_arrays, file_path, fps=5)94 return file_path95class ComparisonQueryLinear(LinearQuery):96 def __init__(97 self, gp_repr1, gp_repr2, reward1, reward2, info, response="bernoulli", **kwargs98 ):99 gp_repr_list = [gp_repr1, gp_repr2]100 linear_combination = [1, -1]101 super().__init__(gp_repr_list, linear_combination, 0, info)102 self.gp_repr1 = gp_repr_list[0]103 self.gp_repr2 = gp_repr_list[1]104 self.reward1 = reward1105 self.reward2 = reward2106 self.response = response107 if response == "difference":108 self.p = None109 elif response == "bernoulli":110 assert 0 <= reward1 <= 1, reward1111 assert 0 <= reward2 <= 1, reward2112 self.p = (1 + reward1 - reward2) / 2113 elif response == "deterministic":114 self.p = 1 if reward1 > reward2 else 0115 elif response == "probit":116 if "sigma" in kwargs:117 self.sigma = kwargs["sigma"]118 else:119 self.sigma = 1120 self.p = norm.cdf((reward1 - reward2) / (np.sqrt(2) * self.sigma))121 @property122 def reward(self):123 if self.p is None:124 return self.reward1 - self.reward2125 else:126 return np.random.choice([-1, 1], p=[1 - self.p, self.p])127 def __hash__(self):128 l = (129 self.gp_repr1.tostring(),130 self.gp_repr2.tostring(),131 self.reward1,132 self.reward2,133 get_info_dict(self.info),134 self.response,135 )136 return hash(l)137class StateQuery(PointQuery):138 def __init__(self, state, gp_repr, reward, info, obs=None):139 info["state"] = state140 info["obs"] = obs141 super().__init__(gp_repr, reward, info)142class StateComparisonQueryLinear(ComparisonQueryLinear):143 def __init__(144 self, gp_repr1, gp_repr2, reward1, reward2, info, response="bernoulli"145 ):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful