123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- from time import sleep
- from selenium.webdriver.common.by import By
- from selenium.webdriver.common.keys import Keys
- class FormB:
- def __init__(self, driver, base_url):
- self.driver = driver
- self.base_url = base_url
- def curd(self):
- try:
- # 로그인
- self.driver.get(self.base_url + '/user-login')
- id_box = self.driver.find_element(By.NAME, 'email')
- pw_box = self.driver.find_element(By.NAME, 'password')
- id_box.clear()
- pw_box.clear()
- id_box.send_keys('kimhi65@naver.com')
- pw_box.send_keys('China13579')
- self.driver.find_element(By.CSS_SELECTOR, '.login-form').submit()
- # 발주 등록 페이지 이동
- self.driver.get(
- self.base_url + '/dabory/erp/purchase/porder?bpa=eyJtZW51X25hbWUiOiJcdWJjMWNcdWM4ZmMgXHViNGYxXHViODVkIiwibWVudV9jb2RlIjoiMDMzMDAwIiwiZGlzYWJsZV9sX21lbnUiOiIwIiwiZW5hYmxlX3JfbWVudSI6IjAiLCJwZXJtaXNzaW9uIjp7ImlzX215bWVudSI6IjAiLCJpc19saXN0IjoiMSIsImlzX3JlYWQiOiIxIiwiaXNfY3JlYXRlIjoiMSIsImlzX3VwZGF0ZSI6IjEiLCJpc19kZWxldGUiOiIxIiwiaXNfbmV3dGFiIjoiMCJ9LCJwYWdlX3VyaSI6IlwvZGFib3J5XC9lcnBcL3B1cmNoYXNlXC9wb3JkZXIiLCJwYXJhX25hbWUiOiJcL2Zvcm0tYlwvcHVyY2hcL3BvcmRlciIsInRoZW1lX2RpciI6IiIsIm1haW5fYXBwX2lkIjowLCJndWVzdF9hcHBfaWQiOjB9')
- sleep(1)
- # 발주 등록
- self.create()
- print('create 성공')
- sleep(3)
- # 발주 수정
- self.update()
- print('update 성공')
- sleep(3)
- # 발주 읽기
- self.read()
- print('read 성공')
- sleep(3)
- # 발주 삭제
- self.delete()
- print('delete 성공')
- # 테스트 완료 후 크롬 바주 종료
- sleep(3)
- self.driver.close()
- except Exception as error:
- # error 종류 출력
- print(error)
- self.driver.close()
- def create(self):
- # Head
- self.driver.find_element(By.ID, 'auto-slip-no-btn').click()
- self.driver.find_element(By.CLASS_NAME, 'company-modal-btn').click()
- self.driver.find_element(By.XPATH, '//*[@id="table-body"]/tr[1]/td[2]/a').click()
- sleep(1)
- save_act_btn = self.driver.find_element(By.CSS_SELECTOR, '.porder-act.save-button')
- self.driver.execute_script("arguments[0].click();", save_act_btn)
- # Body
- sleep(1)
- save_bd_act_btn = self.driver.find_element(By.CSS_SELECTOR, ".porder-bd-act[data-value='add']")
- self.driver.execute_script("arguments[0].click();", save_bd_act_btn)
- self.driver.find_element(By.ID, 'item-code-0').send_keys(Keys.RETURN)
- self.driver.find_element(By.XPATH, '//*[@id="table-body"]/tr[1]/td[3]/a').click()
- sleep(1)
- supply_amt_txt = self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[9]/input')
- supply_amt_txt.clear()
- supply_amt_txt.send_keys('1000')
- self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[16]/input').send_keys(Keys.RETURN)
- def update(self):
- # self.driver.find_element(By.ID, 'up-btn').click()
- bd_cursor = self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[1]/input')
- self.driver.execute_script("arguments[0].click();", bd_cursor)
- sleep(1)
- supply_amt_txt = self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[9]/input')
- supply_amt_txt.clear()
- supply_amt_txt.send_keys('2000')
- self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[16]/input').send_keys(Keys.RETURN)
- def read(self):
- self.driver.find_element(By.XPATH, '/html/body/div[2]/div[2]/div[19]/div[2]/div/div/div/div[1]/button[3]').click()
- sleep(1)
- self.driver.find_element(By.XPATH, '//*[@id="table-body"]/tr[1]/td[2]/a').click()
- def delete(self):
- # Body 삭제
- bd_cursor = self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[2]/input')
- self.driver.execute_script("arguments[0].click();", bd_cursor)
- sleep(1)
- self.driver.find_element(By.CSS_SELECTOR, ".card-body .dropdown-toggle").click()
- self.driver.find_element(By.CSS_SELECTOR, ".card-body li[data-value='multi-delete']").click()
- sleep(1)
- self.driver.find_element(By.CSS_SELECTOR, ".swal2-confirm").click()
- # Head 삭제
- self.driver.find_element(By.CSS_SELECTOR, ".row .text-right .btn-group .dropdown-toggle").click()
- self.driver.find_element(By.CSS_SELECTOR, ".row .text-right .dropdown-menu li[data-value='delete']").click()
- sleep(1)
- self.driver.find_element(By.CSS_SELECTOR, ".swal2-confirm").click()
|