标签:oid level primary submit iframe 信息 evel print save
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=402881f95b4b1209015b4c0d15080157"]‘
return self.pyse.wait_and_save_exception(tmp,name)
#基础支撑
class JczcPage(LoginPage):
def clickJczc(self):
tmp = ‘css=>a[lay-href="getMenuList.do?permission=402881f95b4b1209015b4c0d15080157"]‘
self.pyse.click(tmp)
#区划管理
class QhglPage(JczcPage):
def Qhclick(self):
self.pyse.switch_to_frame_out()
tmp0=‘css=>[src="getMenuList.do?permission=402881f95b4b1209015b4c0d15080157"]‘
self.pyse.switch_to_frame(tmp0)
tmp=‘css=>#menu_list>ul>li[id="402881f95b4b1209015b4c11f9cd0178"]‘
# print(self.pyse.wait_and_save_exception(tmp,‘区划管理‘))
self.pyse.click(tmp)
#增加按钮
def zengjia(self):
tmp0=‘css=>[id="menu_list_item_ifram"]‘
self.pyse.switch_to_frame(tmp0)
tmp2=‘xpath=>//div[@class="select_area clearfix"]/div[@class="select_area_left"]/div[@class="zTreeDemoBackground left"]/ul[@id="districtTree"]‘ \
‘/li[@id="districtTree_1"]/a[@id="districtTree_1_a"]/span[@id="districtTree_1_span"]‘
self.pyse.click(tmp2)
tmp3=‘xpath=>//iframe[@id="distList"]‘
self.pyse.switch_to_frame(tmp3)
tmp4=‘xpath=>//form[@id="queryForm"]/div[@class="btn-group col-md-3 col-sm-4"]/a[@class="btn btn-primary"][2]‘
self.pyse.click(tmp4)
# 区划管理页面
class Qhinfo(QhglPage): # 填bug信息页面的类
def qhsu(self): # 所属模块,从父级指向下级a,父级定位唯一,在tmp12中会唯一获取到
self.pyse.switch_to_frame_out()
tmp0 = ‘css=>#_DialogFrame_0‘
self.pyse.switch_to_frame(tmp0)
tmp1= ‘css=>#name‘#区划名称
self.pyse.type(tmp1, ‘学校‘)
tmp2 = ‘css=>#code‘#区划代码
self.pyse.type(tmp2, ‘874596‘)
tmp3 = ‘css=>#levelDictOid‘#级别
self.pyse.select_by_value(tmp3, ‘402881fa56e8b41c0156e8ba5e33000a‘) # 地级市、自治州、地区、盟
tmp4= ‘css=>#sort‘#排序号
self.pyse.type(tmp4, ‘45‘)
tmp5= ‘css=>#financeDivisionCode‘ # 财政区划内码
self.pyse.type(tmp5, ‘632105‘)
tmp6= ‘css=>div>a[class="layui-layer-btn2"]‘
self.pyse.click(tmp6)
self.pyse.switch_to_frame_out()
tmp7= ‘css=>#_ButtonOK_1‘
self.pyse.click(tmp7)
#跳到区划管理页面
def checkQhinfo(self,name):
self.pyse.switch_to_frame_out()
tmp0 = ‘css=>[src="getMenuList.do?permission=402881f95b4b1209015b4c0d15080157"]‘
self.pyse.switch_to_frame(tmp0)
tmp = ‘css=>#menu_list>ul>li[id="402881f95b4b1209015b4c11f9cd0178"]‘
return self.pyse.wait_and_save_exception(tmp,name)
class Page(Qhinfo):
pass
if __name__ == ‘__main__‘:
page = Page()
page.open()
page.sendUsername()
page.sendPasswd()
page.clickLogin()
print(page.checkLogin(‘登录失败了‘))
page.clickJczc()
page.Qhclick()
page.zengjia()
page.qhsu()
print(page.checkQhinfo(‘保存失败了‘))
标签:oid level primary submit iframe 信息 evel print save
原文地址:https://www.cnblogs.com/zhaoxueying/p/11412135.html