Advertisement
Guest User

Untitled

a guest
Aug 4th, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.36 KB | None | 0 0
  1. """
  2. .|'''| '||\ /||`.|'''| '||\ /||`.|''''|,'||'''|.'|| ||`'|| '||''''|
  3. || ||\\.//|| || ||\\.//|| || || || || || || || || .
  4. `|'''|, || || `|'''|, || || || || || || || || || ||'''|
  5. . || || || . || || || || || || || || || || ||
  6. |...|'.|| ||. |...|' .|| ||.`|....|'.||...|' `|...|' .||...|.||....|
  7.  
  8.  
  9. || .''',
  10. '|| | |
  11. \\ // || | |
  12. \\// || | |
  13. \/...||...`,,,'
  14.  
  15.  
  16. (Font: 'fender')
  17. This module is to be used to interact with the Zimmer Biomet Surgery Management System
  18. This module is coded entirely using Python 3.5 and Anaconda
  19. and edited using Spyder2/Spyder3. This program is Developed and created by Ian Doarn
  20.  
  21. This is being developed on a consistant bases!
  22.  
  23. WARNING!
  24. PLEASE Do not make edits to any of the code in this file unless you know 100% what you are doing.
  25. Breaking this module will cause a complete break of the physical application.
  26.  
  27. Requests for features must be sent to Ian Doarn
  28.  
  29. Ian.Doarn@zimmerbiomet,com
  30. ian.doarn@zbsaleslogistics.com
  31.  
  32. """
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. #import all needed modules
  40. import logging
  41. from sys import stderr, stdout
  42. import xlrd
  43. import os
  44. import ctypes
  45. from selenium import webdriver
  46. from selenium.webdriver.common.keys import Keys
  47. from selenium import *
  48. from selenium.webdriver.common.action_chains import ActionChains
  49. from selenium.webdriver.common.by import By
  50. from selenium.webdriver.support.ui import WebDriverWait
  51. from selenium.webdriver.support import expected_conditions as EC
  52. from selenium.common.exceptions import NoSuchElementException
  53. from datetime import date
  54. from datetime import timedelta
  55. import time
  56. from time import sleep
  57. def yesterday():
  58. # Get today.
  59. today = date.today()
  60. # Subtract timedelta of 1 day.
  61. yesterday = today - timedelta(days=1)
  62. return yesterday
  63. from tkinter import *
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. #start logging module this will record all actions and record them for debugging purposes!
  74.  
  75. #Start classes
  76. #define variables to call for automation process
  77. #this will help run faster so the code is shorter in the main sections
  78. """
  79. Used to read cells from an excel file one at a time
  80.  
  81. Use:
  82. 1) Call the class with new()
  83. 2) Call new.var() to clear variables and start at top of document
  84. 3) Call new.stp() to begin process
  85. 4) Call new.nextp() until finished
  86. """
  87.  
  88.  
  89. #########################################################################
  90. #########################################################################
  91. class GLOBAL_BEGIN(object):
  92.  
  93. def __init__(self):
  94. self.SMS = calls_sms()
  95.  
  96. #########################################################################
  97. #########################################################################
  98.  
  99. # main class for SMS interaction
  100. class calls_sms():
  101.  
  102. def __init__(self, logger=None): #sets variables up and inital value NULL
  103. self.w = None
  104. self.variable = None
  105. self.value = None
  106. self.default_int = 0 #
  107. self.default_string = None #These are for empty feilds
  108. self.default = None #
  109. self.w = 2
  110. #open EXCEL
  111. self.file_location = os.path.expanduser(os.sep.join(["~","Desktop","mutate.xls"])) #finds home directorry
  112. self.workbook = xlrd.open_workbook(self.file_location)
  113. self.sheet = self.workbook.sheet_by_index(0)
  114. logging.basicConfig(filename='server-sms_automation.err.log',level=logging.DEBUG)
  115. self.logging = logging
  116. self.logging.debug('Program launched @ '+str(date.today())+'')
  117. self.logging.debug('===========================================')
  118. calls_sms.beginprod(self)
  119. calls_sms.nextp(self) #called here first to avoid None or column header as input
  120.  
  121.  
  122.  
  123. def output_file(self):
  124. f = open("mutate_output.txt","a")
  125. f.write(str(self.text))
  126. self.text = None
  127. f.close()
  128.  
  129. def session_output_file(self):
  130. f = open("session_log.txt","a")
  131. f.write(str(self.text))
  132. self.text = None
  133. f.close()
  134.  
  135.  
  136. def slay(self):
  137. self.driver.quit()
  138. self.slaystring = 'Disconnected from Session '+str(date.today())+''
  139. self.logging.debug('Disconnecting from Session '+str(date.today())+'')
  140. self.text ='Disconnecting from Session '+str(date.today())+'\n'
  141. calls_sms.session_output_file(self)
  142.  
  143. def beginprod(self):
  144. self.w = 2
  145. calls_sms.stp(self)
  146. self.logging.debug('Openning EXCEL file')
  147.  
  148. def stp(self):
  149. for row in range(self.sheet.nrows):
  150. row = self.sheet.row_values(self.w)
  151. self.variabledashed = row[6]
  152. self.variable = row[7] #Product number
  153. self.edi = row[8] #EDI number
  154. self.partdesc = row[9] #description
  155. self.lotnumber = row[10] #lot number
  156. self.serial = row[11] #serial
  157. self.casenumber = row[12]
  158. self.logging.debug('new product#: '+str(self.variable)+'')
  159.  
  160.  
  161. def nextp(self):
  162. self.w += 1
  163. calls_sms.stp(self)
  164.  
  165. def emptyexcelvars(self):
  166. self.variabledashed = None #Product number
  167. self.variable = None #EDI number
  168. self.partdesc = None #Description
  169. self.lotnumber = None #lot number
  170. self.serialnumber = None #serialized number
  171. self.casenumber = None #Case number
  172. self.logging.debug('Variables emptied')
  173.  
  174. # #attempt #2 use this when a csv file is your only option
  175. # def dic(self):
  176. # self.dic = self.d.get('val')
  177. # self.a = self.dic.get('a'+str(self.w)+'')
  178. # self.dicentry = str(self.a)
  179. #
  180. # def nextdic(self):
  181. # self.w += 1
  182.  
  183.  
  184.  
  185. #abbreviations for later use
  186. def var(self): #must be called var, driver is not defined till launch call
  187. self.xpath = self.driver.find_element_by_xpath
  188. self.classname = self.driver.find_element_by_class_name
  189. self.css = self.driver.find_element_by_css_selector
  190.  
  191.  
  192.  
  193. #Open IE driver and new IE window
  194. def launch(self):
  195. self.text = 'Program launched @ '+str(date.today())+'\n'
  196. calls_sms.session_output_file(self)
  197. self.launchstring = 'Launching Webdriver.IE'
  198. self.driver = webdriver.Chrome()
  199. self.driver.get("https://www.zimmersms.com/")
  200. self.logging.debug('Connected to SMS on '+str(date.today())+'')
  201. self.launchstring = 'Connected to SMS on '+str(date.today())+''
  202.  
  203. #Open IE driver and new IE window in SMS Test inviorment
  204. def launch_qa(self):
  205. self.text = 'QA Program launched @ '+str(date.today())+'\n'
  206. calls_sms.session_output_file(self)
  207. self.launchstring = 'Launching Webdriver.IE'
  208. self.driver = webdriver.Chrome()
  209. self.driver.get("http://qa.zimmersms.com/")
  210. self.logging.debug('Connected to SMS QA on '+str(date.today())+'')
  211. self.launchstring = 'Connected to SMS QA on '+str(date.today())+''
  212.  
  213. def login(self):
  214. self.username = self.classname("GJCH5BMD1C")
  215. self.password = self.xpath("//input[@type='password']")
  216. try:
  217. self.username.send_keys("doarni")
  218. self.password.send_keys("Zimmer1")
  219. self.log_in = self.xpath("//*[@class='GJCH5BMI-C']").click()
  220. self.logging.debug('Connected to SMS @ '+str(date.today())+' User: doarni')
  221. except:
  222. os.system('python sms_generic_err.py')
  223. self.logging.debug('FAILED LOGIN '+str(date.today())+' User: doarni')
  224. self.text = 'FAILED LOGIN '+str(date.today())+' User: doarni\n'
  225. calls_sms.session_output_file(self)
  226. pass
  227. time.sleep(3)
  228. self.loginstringsuccess = 'Successfully Logged In'
  229. calls_sms.check_site(self)
  230.  
  231. """
  232. ```````````````
  233. Addaptive Wait Functions
  234. ```````````````
  235. Since SMS loads elements dynamically, customized wait functions need to be created.
  236. Hopefully these can eliminated time.sleep and add a large level of flexablility
  237.  
  238. Useage:
  239. Set up the classname wait as loop = "classname" and then call the function self.wait_for_class(loop)
  240.  
  241. set up the css wait as loop = "tbody tr td div.GJCH5BMN2C" and call the function self.wait_for_css(loop)
  242.  
  243. set up the xpath wait as loop = "//div[@class='GJCH5BMHEF' and text()=' Stock ']" and call the function self.wait_for_xpath(loop)
  244.  
  245. SMS does not have ID's defined.
  246. """
  247.  
  248. def wait_for_class(self, loop):
  249. for x in range(0, 21):
  250. try:
  251. self.classname(loop)
  252. break
  253. except NoSuchElementException:
  254. time.sleep(1)
  255. if x == 20:
  256. print('timed out...')
  257. break
  258. break
  259.  
  260. def wait_for_css(self, loop):
  261. for x in range(0, 21):
  262. try:
  263. self.css(loop)
  264. break
  265. except NoSuchElementException:
  266. time.sleep(1)
  267. if x == 20:
  268. print('timed out...')
  269. break
  270. break
  271.  
  272. def wait_for_xpath(self, loop):
  273. for x in range(0, 21):
  274. try:
  275. self.xpath(loop)
  276. break
  277. except NoSuchElementException:
  278. time.sleep(1)
  279. if x == 20:
  280. print('timed out...')
  281. break
  282. break
  283.  
  284. def wait_for_css_paybackline(self, loop):
  285. for x in range(0, 10):
  286. try:
  287. self.css(loop)
  288. break
  289. except NoSuchElementException:
  290. time.sleep(1)
  291. if x == 20:
  292. print('timed out...')
  293. break
  294. break
  295.  
  296. """
  297. #defing buttons/tab navigation for various screens
  298. """
  299. """
  300. #Stock tab screen
  301.  
  302. These are the various functions and subfunctions to use the stock tab.
  303. You be propted to select the stock tab when you start an assignment
  304. Special logic will be written later to read the table and read across it
  305.  
  306. NEVER USE DYNAMIC VARIABLES IN PYTHON!
  307. DON'T YOU DARE!
  308. """
  309. def stock_tab(self):
  310. #Only call when on stock tab
  311. try:
  312. loop = "//div[@class='GJCH5BMHEF' and text()=' Stock ']"
  313. self.wait_for_xpath(loop)
  314. self.stock = self.xpath(loop).click()
  315. except:
  316. try:
  317. loop = "//div[@class='GJCH5BMHEF' and text()='Stock ']"
  318. self.wait_for_xpath(loop)
  319. self.stock = self.xpath(loop).click()
  320. except:
  321. os.system('python sms_generic_err.py')
  322. pass
  323.  
  324. def stock_tab_prd_select(self):
  325. #opens prod chooser
  326. loop = "//span[@class='GJCH5BMKU' and text()='Select']"
  327. self.wait_for_xpath(loop)
  328. self.stockselect = self.xpath(loop).click()
  329.  
  330. def stock_searchbtn(self):
  331. loop = "//*[@class='GJCH5BMJV']"
  332. self.wait_for_xpath(loop)
  333. self.stocksearch = self.xpath(loop)
  334. self.stocksearch.click()
  335.  
  336. def stock_tab_prd_clear(self):
  337. #clears product
  338. loop = "//span[@class='GJCH5BMKU' and text()='Clear']"
  339. self.wait_for_xpath(loop)
  340. self.stockclear = self.xpath(loop).click()
  341.  
  342. def stock_resetbtn(self):
  343. #stock reset button
  344. loop = "//span[@class='GJCH5BMKU' and text()='Reset']"
  345. self.wait_for_xpath(loop)
  346. self.stockreset = self.xpath(loop).click()
  347.  
  348. #Stock Tab Ribbion Links
  349.  
  350. def stock_getlabels(self):
  351. #Get Labels
  352. self.getlabels = self.xpath("//span[@class='GJCH5BMKU' and text()='Get Labels']").click()
  353.  
  354. def stock_AutoSourceInvalidKits(self):
  355. #Auto Source Invlaid Kits
  356. self.AutoSourceInvalidKits = self.xpath("//span[@class='GJCH5BMKU' and text()='Auto Source Invalid Kits']").click()
  357.  
  358. def stock_transfer(self):
  359. # Transfer
  360. self.transf_stocktab = self.xpath("//span[@class='GJCH5BMKU' and text()='Transfer']").click()
  361.  
  362. def stock_sourcetoorder(self):
  363. #source to order
  364. self.sorucetoorder = self.xpath("//span[@class='GJCH5BMKU' and text()='Source To Order']").click()
  365.  
  366. def stock_rewritelot(self):
  367. #rewrite lot
  368. self.rewritelot = self.xpath("//span[@class='GJCH5BMKU' and text()='Rewrite Lot']").click()
  369.  
  370. def stock_mutate(self):
  371. #Mutate Stock to territory
  372. self.mutate = self.xpath("//span[@class='GJCH5BMKU' and text()='Mutate']").click()
  373.  
  374. def quanitiy_mutate(self):
  375. self.actions = None
  376. self.quanitiy_mutate = self.xpath("//div[@class='GJCH5BMN2C']/div[2]/div/table/tbody/tr[1]/td/table/tbody/tr[2]/td[2]")
  377. self.quanitiy_mutate.click()
  378. self.actions = ActionChains(self.driver)
  379. self.clickinto = self.actions.move_to_element(self.quanitiy_mutate).send_keys('1').perform()
  380. self.actions = None #MUST BE CLEAR FOR THIS FUNCTION TO WORK!
  381.  
  382. def allavail(self):
  383. self.allavail = self.css("html body div.gwt-PopupPanel div.popupContent div div table tbody tr td div.GJCH5BMN2C div.GJCH5BML2C div table tbody tr td.GJCH5BMIQD table tbody tr td.GJCH5BMCS div.GJCH5BMMVC span.GJCH5BMPVC").click()
  384.  
  385. def notestring(self):
  386. self.actions = None
  387. self.notestring = self.xpath("//div[@class='GJCH5BMN2C']/div[2]/div/table/tbody/tr[1]/td/table/tbody/tr[4]/td[2]")
  388. self.notestring.click()
  389. self.actions = ActionChains(self.driver)
  390. self.clickinto = self.actions.move_to_element(self.notestring).send_keys('Mutated by bot '+str(date.today())).perform()
  391. self.actions = None #MUST BE CLEAR FOR THIS FUNCTION TO WORK!
  392.  
  393. def mutate_cancel(self):
  394. self.mutuate_cancel = self.css("html body div.gwt-PopupPanel div.popupContent div div table tbody tr td div.GJCH5BMN2C div.GJCH5BML2C div table tbody tr td.GJCH5BMJQD table tbody tr td.GJCH5BMKQD span.GJCH5BMFYC div.GJCH5BMI-C div.GJCH5BMJYC.GJCH5BMGYC").click()
  395.  
  396. def mutate_save(self):
  397. self.mutate_save = self.css("html body div.gwt-PopupPanel div.popupContent div div table tbody tr td div.GJCH5BMN2C div.GJCH5BML2C div table tbody tr td.GJCH5BMJQD table tbody tr td span.GJCH5BMJ-C div.GJCH5BMM0C div.GJCH5BMN-C.GJCH5BMK-C").click()
  398.  
  399.  
  400. #Stock Menu Interaction
  401.  
  402. """
  403. Click check boxes
  404. """
  405. def box_biometonly(self):
  406. self.biometonly = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(1) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  407. def box_explode(self):
  408. self.explode = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(1) > div:nth-child(4) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  409. def box_DC(self):
  410. self.DC = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(1) > div:nth-child(9) > div.GJCH5BMNV > table > tbody > tr:nth-child(1) > td.GJCH5BMBS > div > span").click()
  411. def box_Site(self):
  412. self.Site = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(1) > div:nth-child(9) > div.GJCH5BMNV > table > tbody > tr:nth-child(2) > td.GJCH5BMBS > div > span").click()
  413. def box_Account(self):
  414. self.Account = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(1) > div:nth-child(9) > div.GJCH5BMNV > table > tbody > tr:nth-child(3) > td.GJCH5BMBS > div > span").click()
  415. def box_Rep(self):
  416. self.Rep = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(1) > div:nth-child(9) > div.GJCH5BMNV > table > tbody > tr:nth-child(4) > td.GJCH5BMBS > div > span").click()
  417. def box_Team(self):
  418. self.Team = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(1) > div:nth-child(9) > div.GJCH5BMNV > table > tbody > tr:nth-child(5) > td.GJCH5BMBS > div > span").click()
  419. def box_Piece(self):
  420. self.Piece = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(2) > div.GJCH5BMNV > table > tbody > tr:nth-child(1) > td.GJCH5BMBS > div > span").click()
  421. def box_Kit(self):
  422. self.Kit = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(2) > div.GJCH5BMNV > table > tbody > tr:nth-child(2) > td.GJCH5BMBS > div > span").click()
  423. def box_Invalid_Kit(self):
  424. self.Invalid_Kit = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(2) > div.GJCH5BMNV > table > tbody > tr:nth-child(3) > td.GJCH5BMBS > div > span").click()
  425. def box_Component(self):
  426. self.Component = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(2) > div.GJCH5BMNV > table > tbody > tr:nth-child(4) > td.GJCH5BMBS > div > span").click()
  427. def box_ZDI(self):
  428. self.ZDI = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr:nth-child(1) > td.GJCH5BMBS > div > span").click()
  429. def box_Conisgnment(self):
  430. self.Consignment = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr:nth-child(2) > td.GJCH5BMBS > div > span").click()
  431. def box_Loaner_Pool(self):
  432. self.Loaner_Pool = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr:nth-child(3) > td.GJCH5BMBS > div > span").click()
  433. def box_Loaner_Pool_NS(self):
  434. self.Loaner_Pool_NS = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr:nth-child(4) > td.GJCH5BMBS > div > span").click()
  435. def box_Central_Inventory(self):
  436. self.Central_Inventory = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr:nth-child(5) > td.GJCH5BMBS > div > span").click()
  437. def box_Trauma_Shared_pool(self):
  438. self.Trauma_Shared_Pool = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr:nth-child(6) > td.GJCH5BMBS > div > span").click()
  439. def box_Institute(self):
  440. self.Institute = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr:nth-child(7) > td.GJCH5BMBS > div > span").click()
  441. def box_Distributor(self):
  442. self.Distributor_Owned = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(3) > div.GJCH5BMNV > table > tbody > tr:nth-child(8) > td.GJCH5BMBS > div > span").click()
  443. def box_Bin(self):
  444. self.Bin = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(4) > div.GJCH5BMNV > table > tbody > tr:nth-child(1) > td.GJCH5BMBS > div > span").click()
  445. def box_Loan(self):
  446. self.Loan = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(4) > div.GJCH5BMNV > table > tbody > tr:nth-child(2) > td.GJCH5BMBS > div > span").click()
  447. def box_Package(self):
  448. self.Package = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(4) > div.GJCH5BMNV > table > tbody > tr:nth-child(3) > td.GJCH5BMBS > div > span").click()
  449. def box_ZSMS_Hold(self):
  450. self.ZSMS_Hold = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(6) > div.GJCH5BMNV > table > tbody > tr:nth-child(1) > td.GJCH5BMBS > div > span").click()
  451. def box_Missing_Exp(self):
  452. self.Missing_Exp = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(7) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  453. def box_Sterile(self):
  454. self.Sterile = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(8) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  455. def box_Lot_rewrite(self):
  456. self.Lot_rewrite = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(9) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  457. def box_Transfer_into_Kits(self):
  458. self.Transfer_into_kits = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(10) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  459. def box_Transfer_outof_kits(self):
  460. self.Transfer_outof_kits = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(11) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  461. def box_Empty_kits(self):
  462. self.Empty_Kits = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(12) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  463. def box_Avail_Altered(self):
  464. self.Avail_Altered = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div:nth-child(2) > div:nth-child(13) > div.GJCH5BMNV > table > tbody > tr > td.GJCH5BMBS > div > span").click()
  465.  
  466.  
  467. # Table Parsing v1 For indepth analysis
  468. def tableparsing(self): #Parses the table and reads each row
  469. y = 1
  470. while y < 100:
  471. try:
  472. self.tabelrowcurr = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]")
  473. i = 2
  474. x = 0
  475. print('Reading row '+str(y)+' Part Number: '+str(self.variable))
  476. self.logging.debug('Parsing Table @ row '+str(y)+' Part Number: '+str(self.variable))
  477. while i < 6:
  478. if i == 5:
  479. self.cellcontainerlocation = None
  480. self.tablerowcontainer = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[5]/div/table/tbody/tr/td[1]")
  481. self.cellcontainer = self.tablerowcontainer.get_attribute('innerHTML')
  482. self.tablerowcontainerlocation = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[5]/div/table/tbody/tr/td[2]/span")
  483. self.cellcontainerlocation = self.tablerowcontainerlocation.get_attribute('innerHTML')
  484. if "PKG" in self.cellcontainer:
  485. self.cellcontainer = None
  486. self.tablerowcontainer = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[5]/div/table/tbody/tr/td[2]/span")
  487. self.cellcontainer = self.tablerowcontainer.get_attribute('innerHTML')
  488. print(self.cellcontainer)
  489. self.cellcontainer = None
  490. self.cellcontainerlocation = None
  491. continue
  492. else:
  493. print(self.cellcontainer +' '+ self.cellcontainerlocation)
  494. self.cellcontainer = None
  495. self.cellcontainerlocation = None
  496. i += 1
  497. continue
  498. if i == 6:
  499. self.tablesite = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr[1]/td[6]/div/table/tbody/tr/td[1]")
  500. self.cellsite = self.tablesite.get_attribute('innerHTML')
  501. self.tablelocation = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr[1]/td[6]/div/table/tbody/tr/td[2]/span")
  502. self.celllocation = self.tablelocation.get_attribute('innerHTML')
  503. print(self.cellsite +' '+ self.celllocation)
  504. self.cellsite = None
  505. self.celllocation = None
  506. i += 1
  507. continue
  508. while x < 1:
  509. self.tablerowspan = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[2]/span")
  510. self.cell2 = self.tablerowspan.get_attribute('innerHTML')
  511. print(self.cell2)
  512. self.cell2 = None
  513. x += 1
  514. i += 1
  515. self.tablerow = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td["+str(i)+"]/div")
  516. self.cell = self.tablerow.get_attribute('innerHTML')
  517. print(self.cell)
  518. self.cell = None
  519. i += 1
  520. print('')
  521. except:
  522. try:
  523. self.clicknext = self.xpath("//td[@class=GJCH5BMNXD']/table/tbody/tr/td[3]").click()
  524. continue
  525. except:
  526. print('End of Records')
  527. print('Going to next product')
  528. break
  529. y += 1
  530.  
  531. # Table Parsing v2 For faster processes
  532.  
  533. def table_static_read(self): #Parses the table and reads each row
  534. y = 1
  535. while y < 101:
  536. time.sleep(0.5)
  537. self.tabelrowcurr = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]")
  538. print('Reading row '+str(y)+' Part Number: '+str(self.variable))
  539. self.table_product_number = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[2]/span").get_attribute('innerHTML')
  540. print(self.table_product_number)
  541. self.table_description = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[3]/div").get_attribute('innerHTML')
  542. print(self.table_description)
  543. self.table_Lot_serial = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[4]/div").get_attribute('innerHTML')
  544. print(self.table_Lot_serial)
  545. self.table_container = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[5]/div/table/tbody/tr/td[2]/span").get_attribute('innerHTML')
  546. print(self.table_container)
  547. self.table_container_location = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[5]/div/table/tbody/tr/td[1]").get_attribute('innerHTML')
  548. print(self.table_container_location)
  549. self.table_site = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[6]/div/table/tbody/tr/td[1]").get_attribute('innerHTML')
  550. print(self.table_site)
  551. self.table_location = self.xpath("//table[@class='GJCH5BMKM']/tbody/tr["+str(y)+"]/td[6]/div/table/tbody/tr/td[2]/span").get_attribute('innerHTML')
  552. print(self.table_location)
  553. if str(int(self.lotnumber)) in str(self.table_Lot_serial):
  554. if 'CANCELED' in str(self.table_container):
  555. print('Case Canceled/Closed for: '+str(self.variable)+' Lot #: '+str(self.lotnumber)+'')
  556. # self.text = 'Case Canceled/Closed for: '+str(self.variable)+' Lot #: '+str(self.lotnumber)+'\n'
  557. # calls_sms.output_file(self)
  558. break
  559. if 'COMPLETE' in str(self.table_container):
  560. print('found match')
  561. self.table_container_element = self.xpath("//span[@class='GJCH5BMKU' and text()='"+str(self.table_container)+"']").click()
  562. time.sleep(2)
  563. try:
  564. loop = "body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(8) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > table > tbody > tr > td.GJCH5BMH0E > div:nth-child(1) > div.GJCH5BMI1E > table > tbody > tr > td > table > tbody > tr:nth-child(5) > td.GJCH5BMM1E > table > tbody > tr > td:nth-child(1) > span"
  565. self.wait_for_css_paybackline(loop)
  566. self.paybackline = self.css(loop)
  567. except NoSuchElementException:
  568. print(str(date.today())+' no payback orders for: '+str(self.variable)+' Lot #: '+str(self.lotnumber)+' Case #: '+str(self.casenumber)+'')
  569. self.text ='no payback orders for: '+str(self.variable)+' Lot #: '+str(self.lotnumber)+' Case #: '+str(self.casenumber)+'\n'
  570. calls_sms.output_file(self)
  571. time.sleep(0.5)
  572. self.driver.execute_script("window.history.go(-1)")
  573. break
  574. calls_sms.openpayback(self)
  575. time.sleep(1)
  576. break
  577. else:
  578. y += 1
  579. continue
  580. y += 1
  581. continue
  582. try:
  583. self.clicknext = self.xpath("//td[@class='GJCH5BMNXD']/table/tbody/tr/td[3]").click()
  584. y = 0
  585. continue
  586. except:
  587. print('End of Records / No Records Found')
  588. print('Going to next product')
  589. self.text = 'End of Records / No Records Found, Going to next product\n'
  590. calls_sms.output_file(self)
  591. break
  592.  
  593. #order page
  594.  
  595. def openpayback(self):
  596. x = 1
  597. i = 0
  598. j = 0
  599. qtyopen = 0
  600. totitems = 0
  601. loop = "body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(9) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > table > tbody > tr > td.GJCH5BMH0E > div:nth-child(1) > div.GJCH5BMO0E > table > tbody > tr > td.GJCH5BMN0E"
  602. self.wait_for_css(loop)
  603. while x < 10:
  604. self.paybackline = None
  605. try:
  606. self.paybackline = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(8) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > table > tbody > tr > td.GJCH5BMH0E > div:nth-child(1) > div.GJCH5BMI1E > table > tbody > tr > td > table > tbody > tr:nth-child(5) > td.GJCH5BMM1E > table > tbody > tr > td:nth-child("+str(x)+") > span")
  607. self.paybackstring = self.paybackline.get_attribute('innerHTML')
  608. if '(Approved)' in str(self.paybackstring):
  609. print(str(self.paybackstring)+' valid')
  610. self.driver.implicitly_wait(3)
  611. loop = "body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(8) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > table > tbody > tr > td.GJCH5BMH0E > div:nth-child(1) > div.GJCH5BMI1E > table > tbody > tr > td > table > tbody > tr:nth-child(5) > td.GJCH5BMM1E > table > tbody > tr > td:nth-child("+str(x)+") > span"
  612. self.wait_for_css(loop)
  613. self.paybackline = self.css(loop).click()
  614. k = 1
  615. time.sleep(3)
  616. while k < 21:
  617. try:
  618. self.ordertableprod = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(5) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div.GJCH5BMDUH > div > div.GJCH5BMOUD > div > div > div:nth-child(2) > div.GJCH5BMFM > div > table > tbody > tr:nth-child("+str(k)+") > td:nth-child(3) > span").get_attribute('innerHTML')
  619. print('Product # '+str(self.ordertableprod))
  620. self.order_qty_open = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(5) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div.GJCH5BMDUH > div > div.GJCH5BMOUD > div > div > div:nth-child(2) > div.GJCH5BMFM > div > table > tbody > tr:nth-child("+str(k)+") > td:nth-child(7) > div").get_attribute('innerHTML')
  621. print('order_qty_open ='+str(self.order_qty_open)+'')
  622. if str(self.variable) == str(self.ordertableprod):
  623. print('found item')
  624. if int(float(str(self.order_qty_open))) > 1: # if grater than 1 reduce by 1 and do not close
  625. print('order_qty_open = '+str(self.order_qty_open)+'')
  626. qtyopen += int(float(str(self.order_qty_open)))
  627. totitems += int(float(str(self.order_qty_open)))
  628. self.lineinto = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(5) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div.GJCH5BMDUH > div > div.GJCH5BMOUD > div > div > div:nth-child(2) > div.GJCH5BMFM > div > table > tbody > tr:nth-child("+str(k)+") > td:nth-child(2) > span").click()
  629. time.sleep(2)
  630. self.modify = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(2) > div > table > tbody > tr > td.GJCH5BMETF > table > tbody > tr > td.GJCH5BMDTF > span").click()
  631. calls_sms.mutation_modifyline(self)
  632. time.sleep(2)
  633. self.modify_cancel = self.css("body > div.gwt-PopupPanel > div > div > div > table > tbody > tr > td > div > div.GJCH5BML2C > div > table > tbody > tr:nth-child(2) > td > table > tbody > tr > td.GJCH5BMIED > span > div > div.GJCH5BMJYC.GJCH5BMGYC").click()
  634. """the below line of code physically modifies the line, do not uncomment unless in QA or program is 100% working"""
  635. # self.modify_save = self.css("body > div.gwt-PopupPanel > div > div > div > table > tbody > tr > td > div > div.GJCH5BML2C > div > table > tbody > tr:nth-child(2) > td > table > tbody > tr > td:nth-child(2) > span > div > div.GJCH5BMN-C.GJCH5BMK-C").click()
  636. # time.sleep(2)
  637. self.driver.execute_script("window.history.go(-1)")
  638. raise NoSuchElementException
  639. break
  640. elif int(float(str(self.order_qty_open))) == 1: # if equal to 1 / close line
  641. qtyopen += 1
  642. self.lineinto = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(5) > div > div:nth-child(2) > div > div:nth-child(3) > div > div > div > div.GJCH5BMDUH > div > div.GJCH5BMOUD > div > div > div:nth-child(2) > div.GJCH5BMFM > div > table > tbody > tr:nth-child("+str(k)+") > td:nth-child(2) > span").click()
  643. """the below line of code physically closes the line, do not uncomment unless in QA or program is 100% working"""
  644. # self.closeline = self.css("body > div:nth-child(8) > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(6) > div > div:nth-child(2) > div > div:nth-child(2) > div > table > tbody > tr > td.GJCH5BMETF > table > tbody > tr > td:nth-child(2) > span").click()
  645. time.sleep(2)
  646. self.driver.execute_script("window.history.go(-1)")
  647. raise NoSuchElementException
  648. break
  649. k = 21
  650. except NoSuchElementException:
  651. print('Total items on order = '+str(totitems)+', total qty open = '+str(qtyopen)+'')
  652. totitems = 0
  653. qtyopen = 0
  654. self.driver.execute_script("window.history.go(-1)")
  655. time.sleep(1)
  656. break
  657. totitems += 1
  658. k += 1
  659. j += 1
  660. x += 2
  661. continue
  662. elif '(Closed)' in str(self.paybackstring):
  663. print(str(self.paybackstring)+' not valid')
  664. i += 1
  665. x += 2
  666. continue
  667. except NoSuchElementException:
  668. print('no remaining payback order for: '+str(self.variable)+' Lot #: '+str(self.lotnumber)+' Case #: '+str(self.casenumber)+'')
  669. print('Found '+str(i+j)+' order(s), '+str(j)+' Approved, '+str(i)+' Closed')
  670. # self.text = 'no remaining payback order for: '+str(self.variable)+' Lot #: '+str(self.lotnumber)+' Case #: '+str(self.casenumber)+'\n'
  671. # calls_sms.output_file(self)
  672. # self.text = 'Found '+str(i+j)+' order(s), '+str(j)+' Approved, '+str(i)+' Closed\n'
  673. # calls_sms.output_file(self)
  674. self.driver.implicitly_wait(2)
  675. self.driver.execute_script("window.history.go(-1)")
  676. break
  677.  
  678. def mutation_modifyline(self): # modifies the payback line item QTY open by 1
  679. qty = int(float(str(self.order_qty_open))) - 1
  680. self.actions = ActionChains(self.driver)
  681. self.modify_box = self.css("body > div.gwt-PopupPanel > div > div > div > table > tbody > tr > td > div > div.GJCH5BML2C > div > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td.GJCH5BMCS > input")
  682. self.modify_box.click()
  683. self.modify_box_sendkey = self.actions.move_to_element(self.modify_box).send_keys(str(qty)).perform()
  684. print('Item '+str(self.variable)+' at QTY Open '+str(self.order_qty_open)+' reduced by `1` to new QTY of '+str(qty)+' and has been modified')
  685. self.actions = None #MUST BE CLEAR FOR THIS FUNCTION TO WORK!
  686.  
  687. def mutation_err_nopaybck(self):
  688. self.mutation_nopaybckstring = 'no payback order for: '+str(self.variable)+' Lot #: '+str(self.lotnumber)+''
  689. def mutation_err_caseerr(self):
  690. self.mutation_caseerrstring = 'Case Canceled/Closed for: '+str(self.variable)+' Lot #: '+str(self.lotnumber)+''
  691.  
  692. #Product Chooser
  693.  
  694. def prod_choose_searchbar(self):
  695. #finds the searchbox and clicks
  696. self.actions = ActionChains(self.driver)
  697. try:
  698. loop = ".GJCH5BMASD"
  699. self.wait_for_css(loop)
  700. self.search = self.css(loop)
  701. self.search.click()
  702. self.clickinto = self.actions.move_to_element(self.search).send_keys(str(self.variable) + Keys.RETURN).perform()
  703. except NoSuchElementException:
  704. #os.system('python sms_err_select_inv.py')
  705. os.system('python sms_generic_err.py')
  706. self.logging.debug('Error Occured '+str(date.today())+' prod_choose_searchbar NoSuchElementException')
  707. try:
  708. calls_sms.stock_tab(self)
  709. calls_sms.prod_choose_searchbar(self)
  710. except:
  711. os.system('python sms_generic_err.py')
  712. pass
  713. self.actions = None #MUST BE CLEAR FOR THIS FUNCTION TO WORK!
  714.  
  715. def prod_choose_clicksearch(self):
  716. try:
  717. loop = "//td[@class='GJCH5BMPR']/span/div[2]"
  718. self.wait_for_xpath(loop)
  719. self.clicksearch = self.xpath(loop).click()
  720. except:
  721. loop = "body > div.GJCH5BMMRD > div > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(2) > div > div:nth-child(2) > div > table > tbody > tr:nth-child(1) > td.GJCH5BMPR > span"
  722. self.wait_for_css(loop)
  723. self.css(loop).click()
  724.  
  725. def prod_choose_clickadd(self):
  726. time.sleep(1)
  727. loop = "body > div.GJCH5BMMRD > div > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(4) > div > div:nth-child(2) > div > div:nth-child(3) > div > div:nth-child(3) > div > div > table > tbody > tr > td.GJCH5BMHM.GJCH5BMEO.GJCH5BMAP.GJCH5BMMM > div > table > tbody > tr > td > table > tbody > tr > td.GJCH5BMCHI > span"
  728. self.wait_for_css(loop)
  729. self.clickadd = self.css(loop).click()
  730.  
  731. def prod_choose_clickfinish(self):
  732. loop = "//div[@class='GJCH5BMJYC GJCH5BMGYC' and text()='Finish']"
  733. self.wait_for_xpath(loop)
  734. self.clickfinish = self.xpath(loop).click()
  735.  
  736.  
  737.  
  738. def user_ask_invtab():
  739. os.system('python sms_err_select_inv.py')
  740. def user_ask_ciinsight():
  741. os.system('python sms_err_select_ciinsight.py')
  742.  
  743. def check_site(self):
  744. self.inventory_connection = self.css("html body div div div.GJCH5BMPV div div div div div.GJCH5BMFX div.GJCH5BMHX table.GJCH5BMGX tbody tr td.GJCH5BMCX table tbody tr td.GJCH5BMOW span.GJCH5BMKU").get_attribute('innerHTML')
  745. ctypes.windll.user32.MessageBoxW(0, 'You are connected to '+str(self.inventory_connection)+'', 'Notice!', 1)
  746.  
  747.  
  748. def mutation(self):
  749. os.system("cls")
  750. i = 0
  751. print('Mutating stock')
  752. while i < 30:
  753. try:
  754. calls_sms.stock_tab_prd_select(self)
  755. except:
  756. try:
  757. calls_sms.stock_tab(self)
  758. calls_sms.stock_tab_prd_select(self)
  759. except:
  760. self.driver.execute_script("window.history.go(-1)")
  761. calls_sms.stock_tab(self)
  762. calls_sms.stock_tab_prd_select(self)
  763. calls_sms.prod_choose_searchbar(self)
  764. time.sleep(1)
  765. calls_sms.prod_choose_clickadd(self)
  766. calls_sms.prod_choose_clickfinish(self)
  767. calls_sms.stock_searchbtn(self)
  768. print('Parsing Table for data')
  769. calls_sms.table_static_read(self)
  770. calls_sms.nextp(self)
  771. if str(self.variable) == 'end':
  772. print('Finished Parsing')
  773. self.logging.debug('Finished Parsing')
  774. elif i == 30:
  775. print('Finished Parsing')
  776. self.logging.debug('Finished Parsing')
  777. else:
  778. continue
  779. i += 1
  780. #########################################################################
  781. #########################################################################
  782. class assignments():
  783.  
  784. def __init__(self):
  785. self.SMS = calls_sms()
  786. self.SYS = os.system
  787. self.sleep = time.sleep
  788. self.st = 0
  789. logging.basicConfig(filename='server-sms_automation.err.log',level=logging.DEBUG)
  790. self.logging = logging
  791.  
  792.  
  793. def login_to_sms(self): #will have username and password GUI
  794. #basic login structure
  795. self.SMS.launch()
  796. self.SMS.driver.implicitly_wait(3)
  797. self.SMS.var()
  798. self.SMS.login()
  799. time.sleep(3)
  800. #self.SMS.check_site()
  801. self.SYS('python sms_err_select_inv.py')
  802. self.sleep(self.st)
  803. #########################################################################
  804. #########################################################################
  805. """
  806. Test interactions down here!
  807.  
  808. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement