Selenium automation script development (Example 2: directory listing review, published, claim, claim review)

Import Pyse lib.pyse from 
'' 'is actually PageObject
a page to be operable on an abstract class method to abstract page element

' ''

# landing page
class the BasePage (Object):
DEF the __init __ (Self):
self.pyse Pyse = ( 'Chrome')

DEF Open (Self):
self.pyse.open ( 'http://43.254.154.254:12333/sxgl') # project addresses

DEF quit (Self):
self.pyse.quit ()


class the LoginPage (the BasePage):
DEF sendUsername (Self):
tmp = 'CSS => loginCode #' # user ID
self.pyse.type (tmp, 'ADMIN')

DEF sendPasswd (Self):
CSS = 'CSS => # loginPassword' # password ID
self.pyse.type (CSS, '123')

DEF clickLogin (Self):
css = 'css => # submitButton ' # submit button
self.pyse.click (CSS)

DEF checklogin (Self, name): # login page check method: to see whether certain elements of the page after a successful login can be positioned to such as only the exit button only after a successful login
tmp0 = 'CSS => [src = "systemIndex.do"]'
self.pyse.switch_to_frame (tmp0)
tmp = 'CSS => A [Lay-href = "getMenuList.do ? 402881b25e4f9859015e4fabd3ef000c permission = "] '
return self.pyse.wait_and_save_exception (tmp, name)


# directory listing module
class MlqdPage (the LoginPage):
DEF clickMlqd (Self):
tmp =' CSS => A [Lay-href =" getMenuList.do ? 402881b25e4f9859015e4fabd3ef000c permission = "] '
self.pyse.click (tmp)
# 1 directory listing review.
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)
# Directory listing audit action page
class Qdinfo (QdshPage): # Fill bug information page of the class
def qdsh (self): # belongs module, from the parent point to lower a, parent positioning unique in tmp12 will be the only acquisition to
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 ') # review
tmp2 =' xpath => // div [@ id = "manage"] / div [@ class = "layui BTN--layer "] / A [@ class =" layui-Layer-btn2 "] '
self.pyse.click (tmp2) # successful audit
self.pyse.switch_to_frame_out ()
TMP3 = 'CSS => #_ ButtonOK_1'
self.pyse.click (tmp3) # retreated to review the list of page

# 2 directory list released.
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 [the above mentioned id =" 402881b25e4f9859015e4fb387500019 "] '
# Print (self.pyse.wait_and_save_exception (tmp,' published directory listing '))
Self .pyse.click (TMP1)
# release button clicks
DEF fbsh (Self):
TMP1 = 'CSS => [the above mentioned 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)
# Directory publishing operation page
# class bug information to fill the page
def qdfbsh (self): # belongs module, from the parent point to lower a, parent unique positioning, unique in tmp12 will get to
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 ') # released
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) # OK, back to the release list page

# 3 directory listing claimed.
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 [the above mentioned id =" 2c287bb6669f70d601669fc7f3ca0019 "] '
# Print (self.pyse.wait_and_save_exception (tmp,' directory Listing claim ') )
self.pyse.click (TMP1)
# unclaimed button clicks
DEF rlsh (Self):
TMP1 = 'CSS => [the above mentioned 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)
Catalog # Claim operating page
# fill bug class information page
def qdrlsh (self): # module belongs, from the lower parent point a, the only parent positioned, will be unique in tmp12 acquired
self.pyse.switch_to_frame_out ()
TMP1 = 'CSS => #_ ButtonOK_0'
self.pyse.click (TMP1) # unclaimed
TMP2 = 'CSS => #_ ButtonOK_0'
self.pyse.click (TMP2) # back directory unclaimed list page

# 4. directory listing unclaimed audit
def Qdrlshclick (Self):
self.pyse.switch_to_frame_out ()
TMP0 = 'CSS => [the src = "getMenuList.do?permission=402881b25e4f9859015e4fabd3ef000c"]'
self.pyse.switch_to_frame (TMP0)
TMP1 = 'CSS => # menu_list> UL> li [the above mentioned id = "2c287bb6669fe72601669feb31700006"] '
# Print (self.pyse.wait_and_save_exception (tmp,' directory listing unclaimed '))
Self.pyse.click (TMP1)
# Review button click claimed
DEF rlshan (Self):
TMP1 = 'CSS => [the above mentioned 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 of)

class information page # fill bug
def qdrlshym (self): # module belongs, from the lower parent point a, the only parent positioned, will be unique in tmp12 acquired
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') # Claim audit
= TMP2 'XPath => // div [@ ID = "Manage"] / div [@ class = "layui-BTN-Layer"] / A [@ class = "layui-Layer-btn2"]'
self.pyse. the Click (TMP2)
self.pyse.switch_to_frame_out ()
tmp3 = 'CSS => #_ ButtonOK_1'
self.pyse.click (tmp3) # back to claim the review list page

class page (Qdinfo):
Pass

IF __name__ == '__main__':
Page = Page ()
page.open ()
page.sendUsername ()
page.sendPasswd ()
page.clickLogin ()
Print (page.checkLogin ( 'login failed'))
page.clickMlqd ()
page.Qdshclick ()
Page. bzsh ()
page.qdsh ()
# list of directories published
page.Qdfbclick()
page.fbsh ()
page.qdfbsh ()
# catalog claimed
page.Qdrlclick ()
page.rlsh ()
page.qdrlsh ()
# catalog unclaimed audit
page.Qdrlshclick ()
page.rlshan ()
page.qdrlshym ()




Guess you like

Origin www.cnblogs.com/zhaoxueying/p/11412140.html