码迷,mamicode.com
首页 > 其他好文 > 详细

自动化selenium脚本开发(示例2:目录清单审核、发布、认领、认领审核)

时间:2019-08-26 14:56:14      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:pull   审核   ret   模块   shp   p12   dial   sep   visible   

from  lib.pyse  import  Pyse
‘‘‘pageobject实际上就是
将一个页面 抽象成一个类 页面上可操作的元素 抽象成方法

‘‘‘

#登陆页面
class BasePage(object):
def __init__(self):
self.pyse = Pyse(‘chrome‘)

def open(self):
self.pyse.open(‘http://43.254.154.254:12333/sxgl‘) #项目地址

def quit(self):
self.pyse.quit()


class LoginPage(BasePage):
def sendUsername(self):
tmp = ‘css=>#loginCode‘ #用户id
self.pyse.type(tmp, ‘admin‘)

def sendPasswd(self):
css = ‘css=>#loginPassword‘ #密码id
self.pyse.type(css, ‘123‘)

def clickLogin(self):
css = ‘css=>#submitButton‘ #提交按钮
self.pyse.click(css)

def checkLogin(self,name): #登录页面校验的方法:看登录成功之后的页面的某个元素是否能定位到,比如只有登录成功之后才有退出按钮
tmp0=‘css=>[src="systemIndex.do"]‘
self.pyse.switch_to_frame(tmp0)
tmp=‘css=>a[lay-href="getMenuList.do?permission=402881b25e4f9859015e4fabd3ef000c"]‘
return self.pyse.wait_and_save_exception(tmp,name)


#目录清单模块
class MlqdPage(LoginPage):
def clickMlqd(self):
tmp = ‘css=>a[lay-href="getMenuList.do?permission=402881b25e4f9859015e4fabd3ef000c"]‘
self.pyse.click(tmp)
#1.目录清单审核
class QdshPage(MlqdPage):
def Qdshclick(self):
self.pyse.switch_to_frame_out()
tmp0=‘css=>[src="getMenuList.do?permission=402881b25e4f9859015e4fabd3ef000c"]‘
self.pyse.switch_to_frame(tmp0)
tmp=‘css=>#menu_list>ul>li[id="402881b25e4f9859015e4fae4583000d"]‘
# print(self.pyse.wait_and_save_exception(tmp,‘目录清单审核‘))
self.pyse.click(tmp)
#编制审核按钮点击
def bzsh(self):
tmp1=‘css=>[id="menu_list_item_ifram"]‘
self.pyse.switch_to_frame(tmp1)
tmp2=‘xpath=>//div[@class="select_result_list"]/table[@class="table table-bordered"]/tbody/tr[2]/td[@class="visible"]/div[@class="use use_two green_use1"]‘ \
‘/i[@class="icontype type_examine"]‘
self.pyse.click(tmp2)
# 目录清单审核操作页面
class Qdinfo(QdshPage): # 填bug信息页面的类
def qdsh(self): # 所属模块,从父级指向下级a,父级定位唯一,在tmp12中会唯一获取到
self.pyse.switch_to_frame_out()
tmp0 = ‘css=>#_DialogFrame_0‘
self.pyse.switch_to_frame(tmp0)
tmp1=‘xpath=>//html/body[@class="body-backg"]/div[@class="select_result_list"]/div[@class="pull-wrap pb0"]/form[@id="form1"]/table[2]‘ \
‘/tbody[1]/tr[2]/td[2]//textarea[@id="auditOption"]‘
self.pyse.type(tmp1, ‘1‘)#审核
tmp2= ‘xpath=>//div[@id="manage"]/div[@class="layui-layer-btn"]/a[@class="layui-layer-btn2"]‘
self.pyse.click(tmp2)#审核成功
self.pyse.switch_to_frame_out()
tmp3 = ‘css=>#_ButtonOK_1‘
self.pyse.click(tmp3)#退到审核列表页面

#2.目录清单发布
def Qdfbclick(self):
self.pyse.switch_to_frame_out()
tmp0=‘css=>[src="getMenuList.do?permission=402881b25e4f9859015e4fabd3ef000c"]‘
self.pyse.switch_to_frame(tmp0)
tmp1=‘css=>#menu_list>ul>li[id="402881b25e4f9859015e4fb387500019"]‘
# print(self.pyse.wait_and_save_exception(tmp,‘目录清单发布‘))
self.pyse.click(tmp1)
#发布按钮点击
def fbsh(self):
tmp1=‘css=>[id="menu_list_item_ifram"]‘
self.pyse.switch_to_frame(tmp1)
temp2=‘xpath=>//div[@class="select_result_list"]/table[@id="tableList"]/tbody/tr[2]/td[9]/div[1]//i[2]‘
self.pyse.click(temp2)
#目录发布操作页面
# 填bug信息页面的类
def qdfbsh(self): # 所属模块,从父级指向下级a,父级定位唯一,在tmp12中会唯一获取到
self.pyse.switch_to_frame_out()
tmp0 = ‘css=>#_DialogFrame_0‘
self.pyse.switch_to_frame(tmp0)
tmp1=‘xpath=>//html/body[@class="body-backg"]/div[@class="select_result_list"]/div[@class="pull-wrap pb0"]/form[@id="form1"]/table[2]‘ \
‘/tbody[1]/tr[2]/td[2]//textarea[@id="auditOption"]‘
self.pyse.type(tmp1, ‘1‘)#发布
tmp2= ‘xpath=>//div[@id="manage"]/div[@class="layui-layer-btn"]/a[@class="layui-layer-btn2"]‘
self.pyse.click(tmp2)
self.pyse.switch_to_frame_out()
tmp3 = ‘css=>#_ButtonOK_1‘
self.pyse.click(tmp3)#确定,回到发布列表页面

#3.目录清单认领
def Qdrlclick(self):
self.pyse.switch_to_frame_out()
tmp0=‘css=>[src="getMenuList.do?permission=402881b25e4f9859015e4fabd3ef000c"]‘
self.pyse.switch_to_frame(tmp0)
tmp1=‘css=>#menu_list>ul>li[id="2c287bb6669f70d601669fc7f3ca0019"]‘
# print(self.pyse.wait_and_save_exception(tmp,‘目录清单认领‘))
self.pyse.click(tmp1)
#认领按钮点击
def rlsh(self):
tmp1=‘css=>[id="menu_list_item_ifram"]‘
self.pyse.switch_to_frame(tmp1)
temp2=‘xpath=>//div[@class="select_result_list"]/table[@id="tableList"]/tbody/tr[2]/td[7]/div[1]/i[1]‘
self.pyse.click(temp2)
#目录认领操作页面
# 填bug信息页面的类
def qdrlsh(self): # 所属模块,从父级指向下级a,父级定位唯一,在tmp12中会唯一获取到
self.pyse.switch_to_frame_out()
tmp1 = ‘css=>#_ButtonOK_0‘
self.pyse.click(tmp1)#认领
tmp2 = ‘css=>#_ButtonOK_0‘
self.pyse.click(tmp2)#回到目录认领列表页面

#4.目录清单认领审核
def Qdrlshclick(self):
self.pyse.switch_to_frame_out()
tmp0=‘css=>[src="getMenuList.do?permission=402881b25e4f9859015e4fabd3ef000c"]‘
self.pyse.switch_to_frame(tmp0)
tmp1=‘css=>#menu_list>ul>li[id="2c287bb6669fe72601669feb31700006"]‘
# print(self.pyse.wait_and_save_exception(tmp,‘目录清单认领‘))
self.pyse.click(tmp1)
#认领审核按钮点击
def rlshan(self):
tmp1=‘css=>[id="menu_list_item_ifram"]‘
self.pyse.switch_to_frame(tmp1)
temp2=‘xpath=>//div[@class="select_result_list"]/table[@id="tableList"]/tbody/tr[2]/td[9]/div[1]/i[1]‘
self.pyse.click(temp2)

# 填bug信息页面的类
def qdrlshym(self): # 所属模块,从父级指向下级a,父级定位唯一,在tmp12中会唯一获取到
self.pyse.switch_to_frame_out()
tmp0 = ‘css=>#_DialogFrame_0‘
self.pyse.switch_to_frame(tmp0)
tmp1 = ‘xpath=>//html/body/div[@class="select_result_list"]/div[@class="pull-wrap"]/form[@id="form1"]/table[2]/tbody[1]/tr[3]/td[2]/textarea[@id="remark"]‘
self.pyse.type(tmp1, ‘1‘)#认领审核
tmp2 = ‘xpath=>//div[@id="manage"]/div[@class="layui-layer-btn"]/a[@class="layui-layer-btn2"]‘
self.pyse.click(tmp2)
self.pyse.switch_to_frame_out()
tmp3 = ‘css=>#_ButtonOK_1‘
self.pyse.click(tmp3)#回到认领审核列表页面

class Page(Qdinfo):
pass

if __name__ == ‘__main__‘:
page = Page()
page.open()
page.sendUsername()
page.sendPasswd()
page.clickLogin()
print(page.checkLogin(‘登录失败了‘))
page.clickMlqd()
page.Qdshclick()
page.bzsh()
page.qdsh()
#目录清单发布
page.Qdfbclick()
page.fbsh()
page.qdfbsh()
#目录认领
page.Qdrlclick()
page.rlsh()
page.qdrlsh()
#目录认领审核
page.Qdrlshclick()
page.rlshan()
page.qdrlshym()




自动化selenium脚本开发(示例2:目录清单审核、发布、认领、认领审核)

标签:pull   审核   ret   模块   shp   p12   dial   sep   visible   

原文地址:https://www.cnblogs.com/zhaoxueying/p/11412140.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!