12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- from time import sleep
- from selenium.webdriver.common.by import By
- class FormA:
- 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/master-data/item?bpa=eyJtZW51X25hbWUiOiJcdWMwYzFcdWQ0ODggXHViNGYxXHViODVkIiwibWVudV9jb2RlIjoiMDIxMDAwIiwiZGlzYWJsZV9sX21lbnUiOiIwIiwiZW5hYmxlX3JfbWVudSI6IjAiLCJwZXJtaXNzaW9uIjp7ImlzX215bWVudSI6IjAiLCJpc19saXN0IjoiMSIsImlzX3JlYWQiOiIxIiwiaXNfY3JlYXRlIjoiMSIsImlzX3VwZGF0ZSI6IjEiLCJpc19kZWxldGUiOiIxIiwiaXNfbmV3dGFiIjoiMCJ9LCJwYWdlX3VyaSI6IlwvZGFib3J5XC9lcnBcL21hc3Rlci1kYXRhXC9pdGVtIiwicGFyYV9uYW1lIjoiXC9mb3JtLWFcL2l0ZW0iLCJ0aGVtZV9kaXIiOiIiLCJtYWluX2FwcF9pZCI6MCwiZ3Vlc3RfYXBwX2lkIjowfQ==')
- sleep(5)
- # 상품 등록
- self.create()
- print('create 성공')
- sleep(1)
- # 상품 수정
- self.update()
- print('update 성공')
- sleep(1)
- # 상품 읽기
- self.read( 'TEST-01')
- print('read 성공')
- sleep(1)
- # 상품 삭제
- self.delete()
- print('delete 성공')
- # 테스트 완료 후 크롬 바로 종료
- sleep(3)
- self.driver.close()
- except Exception as error:
- # error 종류 출력
- print(error)
- self.driver.close()
- def create(self):
- self.driver.find_element(By.ID, 'item-code-txt').send_keys('TEST-01')
- self.driver.find_element(By.ID, 'item-name-txt').send_keys('TEST-01')
- self.driver.find_element(By.ID, 'sub-name-txt').send_keys('TEST-01')
- self.driver.find_element(By.ID, 'sales-prc-txt').send_keys('5000')
- self.driver.find_element(By.ID, 'purch-prc-txt').send_keys('5000')
- sleep(1)
- save_act_btn = self.driver.find_element(By.CSS_SELECTOR, '.item-act.save-button')
- self.driver.execute_script("arguments[0].click();", save_act_btn)
- def update(self):
- item_name_txt = self.driver.find_element(By.ID, 'item-name-txt')
- item_name_txt.clear()
- item_name_txt.send_keys('TEST-01 UPDATE')
- sleep(1)
- save_act_btn = self.driver.find_element(By.CSS_SELECTOR, '.item-act.save-button')
- self.driver.execute_script("arguments[0].click();", save_act_btn)
- def read(self, search_txt):
- self.driver.find_element(By.ID, 'item-modal-btn').click()
- item_code_txt = self.driver.find_element(By.CSS_SELECTOR, '#modal-item .item-code.filter')
- item_code_txt.clear()
- item_code_txt.send_keys(search_txt)
- self.driver.find_element(By.CSS_SELECTOR, '#modal-item .modal-search').click()
- sleep(1)
- self.driver.find_element(By.XPATH, '//*[@id="table-body"]/tr[1]/td[3]/a').click()
- def delete(self):
- self.driver.find_element(By.CSS_SELECTOR, "#item-btn-group .dropdown-toggle").click()
- self.driver.find_element(By.CSS_SELECTOR, "#item-btn-group li[data-value='del']").click()
- sleep(1)
- self.driver.find_element(By.CSS_SELECTOR, ".swal2-confirm").click()
|