Commit 37e5bfc2 authored by 章 登恒's avatar 章 登恒
Browse files

commit

parent f557de3c
...@@ -39,7 +39,7 @@ salesman = '杨春刚'#业务员名称 ...@@ -39,7 +39,7 @@ salesman = '杨春刚'#业务员名称
productcode = 10156326#商品编码 productcode = 10156326#商品编码
class LoginSys(): class LoginSys():#登录
def loginsys(self,url,usr,pwd): def loginsys(self,url,usr,pwd):
chrome.get(url) chrome.get(url)
sleep(2) sleep(2)
...@@ -57,8 +57,8 @@ class LoginSys(): ...@@ -57,8 +57,8 @@ class LoginSys():
# except: # except:
# continue # continue
class PurchaseOrder(): class PurchaseOrder():#普通采购单界面操作
def data_add(self): def data_add(self):#填写表单数据
chrome.implicitly_wait(10) chrome.implicitly_wait(10)
order_link = chrome.find_element_by_xpath('//span[text()="普通采购订单"]') order_link = chrome.find_element_by_xpath('//span[text()="普通采购订单"]')
chrome.execute_script("arguments[0].click();", order_link) chrome.execute_script("arguments[0].click();", order_link)
...@@ -151,9 +151,9 @@ class PurchaseOrder(): ...@@ -151,9 +151,9 @@ class PurchaseOrder():
sleep(1) sleep(1)
chrome.find_element_by_xpath('(//td[@colid="col_171" and @f="F_PURUNIT_TXT" and @i=%s])' % i).click() chrome.find_element_by_xpath('(//td[@colid="col_171" and @f="F_PURUNIT_TXT" and @i=%s])' % i).click()
sleep(1) sleep(1)
def return_pchno(self): def return_pchno(self):#返回采购单号
return orderno1 return orderno1
def closetab(self): def closetab(self):#关闭菜单
chrome.switch_to.default_content() chrome.switch_to.default_content()
sleep(1) sleep(1)
# chrome.switch_to.frame(chrome.find_element_by_xpath('(//iframe[@class="metro-main-frame"])[2]')) # chrome.switch_to.frame(chrome.find_element_by_xpath('(//iframe[@class="metro-main-frame"])[2]'))
...@@ -162,8 +162,7 @@ class PurchaseOrder(): ...@@ -162,8 +162,7 @@ class PurchaseOrder():
chrome.find_element_by_xpath('//span[@class="awsui-tabs-icon close"]').click() chrome.find_element_by_xpath('//span[@class="awsui-tabs-icon close"]').click()
sleep(1) sleep(1)
def button_click1(self,type=2): def button_click1(self,type=2):#保存/提交订单:type=1为保存,否则为提交
#type=1为保存,2为提交
if type == 1: if type == 1:
chrome.find_element_by_xpath('//span[text()="保存"]').click() chrome.find_element_by_xpath('//span[text()="保存"]').click()
sleep(1) sleep(1)
...@@ -178,7 +177,7 @@ class PurchaseOrder(): ...@@ -178,7 +177,7 @@ class PurchaseOrder():
print('订单提交成功') print('订单提交成功')
self.closetab() self.closetab()
def query_commit(self): def query_click(self):#查询出订单并点击
order_link = chrome.find_element_by_xpath('//span[text()="普通采购订单"]') order_link = chrome.find_element_by_xpath('//span[text()="普通采购订单"]')
chrome.execute_script("arguments[0].click();", order_link) chrome.execute_script("arguments[0].click();", order_link)
chrome.switch_to.frame(chrome.find_element_by_xpath('(//iframe[@class="metro-main-frame"])[2]')) chrome.switch_to.frame(chrome.find_element_by_xpath('(//iframe[@class="metro-main-frame"])[2]'))
...@@ -198,15 +197,15 @@ class PurchaseOrder(): ...@@ -198,15 +197,15 @@ class PurchaseOrder():
sleep(1) sleep(1)
chrome.switch_to.frame(chrome.find_element_by_xpath('//iframe[contains(@name,"awsui-dialog-iframe")]')) chrome.switch_to.frame(chrome.find_element_by_xpath('//iframe[contains(@name,"awsui-dialog-iframe")]'))
sleep(0.5) sleep(0.5)
def commit_order(self,type=2): def commit_order(self,type=2):#保存/提交订单:type=1为保存,否则为提交
#1为保存,否则为提交
self.query_commit() self.query_click()
locator = (By.XPATH, '//span[text()="提交"]') locator = (By.XPATH, '//span[text()="提交"]')
wait.until(ec.presence_of_element_located(locator)) wait.until(ec.presence_of_element_located(locator))
sleep(2) sleep(2)
# 审批/驳回订单 # 审批/驳回订单
self.button_click1(type) self.button_click1(type)
def switch_loggin(self,usr,pwd): def switch_loggin(self,usr,pwd):#切换登录
chrome.switch_to.default_content() chrome.switch_to.default_content()
sleep(0.5) sleep(0.5)
chrome.find_element_by_xpath('//span[text()="退出"]').click() chrome.find_element_by_xpath('//span[text()="退出"]').click()
...@@ -221,8 +220,7 @@ class PurchaseOrder(): ...@@ -221,8 +220,7 @@ class PurchaseOrder():
locator = (By.XPATH, '//span[text()="退出"]') locator = (By.XPATH, '//span[text()="退出"]')
wait.until(ec.presence_of_element_located(locator)) wait.until(ec.presence_of_element_located(locator))
def button_click2(self,type): def button_click2(self,type):#审批/驳回订单:type=1为审批/其余为驳回订单
#1为审批/其余为驳回订单
if type == 1: if type == 1:
chrome.find_element_by_xpath('//span[text()="审核通过"]').click() chrome.find_element_by_xpath('//span[text()="审核通过"]').click()
locator = (By.XPATH, '//textarea[@placeholder="意见留言"]') locator = (By.XPATH, '//textarea[@placeholder="意见留言"]')
...@@ -247,9 +245,8 @@ class PurchaseOrder(): ...@@ -247,9 +245,8 @@ class PurchaseOrder():
print('订单驳回成功') print('订单驳回成功')
self.closetab() self.closetab()
def approve_order(self,type=1): def approve_order(self,type=1):#审核/驳回订单:type=1为审核通过,否则为审核驳回
#type=1为审核通过,否则为审核驳回 self.query_click()
self.query_commit()
locator = (By.XPATH, '//span[text()="审核通过"]') locator = (By.XPATH, '//span[text()="审核通过"]')
wait.until(ec.presence_of_element_located(locator)) wait.until(ec.presence_of_element_located(locator))
sleep(2) sleep(2)
...@@ -266,7 +263,8 @@ if __name__ == '__main__': ...@@ -266,7 +263,8 @@ if __name__ == '__main__':
step2 = PurchaseOrder() step2 = PurchaseOrder()
step1.loginsys(SIT_URL,usr2,pwd2)#登录系统 step1.loginsys(SIT_URL,usr2,pwd2)#登录系统
step2.data_add()#填写表单数据 step2.data_add()#填写表单数据
step2.button_click1(1)#1为保存,否则为提交 step2.button_click1()#1为保存,否则为提交
# step2.commitorder(1)#1为保存,否则为提交 # step2.commitorder(1)#1为保存,否则为提交
step2.switch_loggin(usr1,pwd1)#切换登录 step2.switch_loggin(usr1,pwd1)#切换登录
step2.approve_order()#1为审核通过,否则为审核驳回 step2.approve_order()#1为审核通过,否则为审核驳回
\ No newline at end of file purchord = step2.return_pchno()#获取采购订单号
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment