form_b.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. from time import sleep
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.common.keys import Keys
  4. class FormB:
  5. def __init__(self, driver, base_url):
  6. self.driver = driver
  7. self.base_url = base_url
  8. def curd(self):
  9. try:
  10. # 로그인
  11. self.driver.get(self.base_url + '/user-login')
  12. id_box = self.driver.find_element(By.NAME, 'email')
  13. pw_box = self.driver.find_element(By.NAME, 'password')
  14. id_box.clear()
  15. pw_box.clear()
  16. id_box.send_keys('kimhi65@naver.com')
  17. pw_box.send_keys('China13579')
  18. self.driver.find_element(By.CSS_SELECTOR, '.login-form').submit()
  19. # 발주 등록 페이지 이동
  20. self.driver.get(
  21. self.base_url + '/dabory/erp/purchase/porder?bpa=eyJtZW51X25hbWUiOiJcdWJjMWNcdWM4ZmMgXHViNGYxXHViODVkIiwibWVudV9jb2RlIjoiMDMzMDAwIiwiZGlzYWJsZV9sX21lbnUiOiIwIiwiZW5hYmxlX3JfbWVudSI6IjAiLCJwZXJtaXNzaW9uIjp7ImlzX215bWVudSI6IjAiLCJpc19saXN0IjoiMSIsImlzX3JlYWQiOiIxIiwiaXNfY3JlYXRlIjoiMSIsImlzX3VwZGF0ZSI6IjEiLCJpc19kZWxldGUiOiIxIiwiaXNfbmV3dGFiIjoiMCJ9LCJwYWdlX3VyaSI6IlwvZGFib3J5XC9lcnBcL3B1cmNoYXNlXC9wb3JkZXIiLCJwYXJhX25hbWUiOiJcL2Zvcm0tYlwvcHVyY2hcL3BvcmRlciIsInRoZW1lX2RpciI6IiIsIm1haW5fYXBwX2lkIjowLCJndWVzdF9hcHBfaWQiOjB9')
  22. sleep(1)
  23. # 발주 등록
  24. self.create()
  25. print('create 성공')
  26. sleep(3)
  27. # 발주 수정
  28. self.update()
  29. print('update 성공')
  30. sleep(3)
  31. # 발주 읽기
  32. self.read()
  33. print('read 성공')
  34. sleep(3)
  35. # 발주 삭제
  36. self.delete()
  37. print('delete 성공')
  38. # 테스트 완료 후 크롬 바주 종료
  39. sleep(3)
  40. self.driver.close()
  41. except Exception as error:
  42. # error 종류 출력
  43. print(error)
  44. self.driver.close()
  45. def create(self):
  46. # Head
  47. self.driver.find_element(By.ID, 'auto-slip-no-btn').click()
  48. self.driver.find_element(By.CLASS_NAME, 'company-modal-btn').click()
  49. self.driver.find_element(By.XPATH, '//*[@id="table-body"]/tr[1]/td[2]/a').click()
  50. sleep(1)
  51. save_act_btn = self.driver.find_element(By.CSS_SELECTOR, '.porder-act.save-button')
  52. self.driver.execute_script("arguments[0].click();", save_act_btn)
  53. # Body
  54. sleep(1)
  55. save_bd_act_btn = self.driver.find_element(By.CSS_SELECTOR, ".porder-bd-act[data-value='add']")
  56. self.driver.execute_script("arguments[0].click();", save_bd_act_btn)
  57. self.driver.find_element(By.ID, 'item-code-0').send_keys(Keys.RETURN)
  58. self.driver.find_element(By.XPATH, '//*[@id="table-body"]/tr[1]/td[3]/a').click()
  59. sleep(1)
  60. supply_amt_txt = self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[9]/input')
  61. supply_amt_txt.clear()
  62. supply_amt_txt.send_keys('1000')
  63. self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[16]/input').send_keys(Keys.RETURN)
  64. def update(self):
  65. # self.driver.find_element(By.ID, 'up-btn').click()
  66. bd_cursor = self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[1]/input')
  67. self.driver.execute_script("arguments[0].click();", bd_cursor)
  68. sleep(1)
  69. supply_amt_txt = self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[9]/input')
  70. supply_amt_txt.clear()
  71. supply_amt_txt.send_keys('2000')
  72. self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[16]/input').send_keys(Keys.RETURN)
  73. def read(self):
  74. self.driver.find_element(By.XPATH, '/html/body/div[2]/div[2]/div[19]/div[2]/div/div/div/div[1]/button[3]').click()
  75. sleep(1)
  76. self.driver.find_element(By.XPATH, '//*[@id="table-body"]/tr[1]/td[2]/a').click()
  77. def delete(self):
  78. # Body 삭제
  79. bd_cursor = self.driver.find_element(By.XPATH, '//*[@id="porder-table-body"]/tr/td[2]/input')
  80. self.driver.execute_script("arguments[0].click();", bd_cursor)
  81. sleep(1)
  82. self.driver.find_element(By.CSS_SELECTOR, ".card-body .dropdown-toggle").click()
  83. self.driver.find_element(By.CSS_SELECTOR, ".card-body li[data-value='multi-delete']").click()
  84. sleep(1)
  85. self.driver.find_element(By.CSS_SELECTOR, ".swal2-confirm").click()
  86. # Head 삭제
  87. self.driver.find_element(By.CSS_SELECTOR, ".row .text-right .btn-group .dropdown-toggle").click()
  88. self.driver.find_element(By.CSS_SELECTOR, ".row .text-right .dropdown-menu li[data-value='delete']").click()
  89. sleep(1)
  90. self.driver.find_element(By.CSS_SELECTOR, ".swal2-confirm").click()