コード例 #1
0
class SearchPanelPage(Base):
    def __init__(self, driver):
        self.base = Base(driver)

    # 点击搜索历史热词(默认点击第一个)   ---wmw
    def clickSearchHistory(self):
        if self.base.elementIsExit(SEARCHPANEL_SEARCHHISTORY):
            self.base.clickByElement(SEARCHPANEL_SEARCHHISTORY, "搜索历史热词")
            sleep(2)
        else:
            self.assertFalse(SEARCHPANEL_SEARCHHISTORY)

    # 点击换一换   ---wmw
    def clickAnotherChange(self):
        if self.base.elementIsExit(SEARCHPANEL_ANOTHERCHANGE):
            self.base.clickByElement(SEARCHPANEL_ANOTHERCHANGE, "换一换")
        else:
            self.assertFalse(SEARCHPANEL_ANOTHERCHANGE)

    # 点击输入框工具条前缀词“www.”——LYX
    def clickInputPanelPrefixes(self):
        if self.base.elementIsExit(INPUTPANEL_PROMPT):
            self.base.clickByElement(INPUTPANEL_PROMPT, "输入框前缀词www.")
        else:
            self.assertFalse(INPUTPANEL_PROMPT)

    # 长按地址栏中的“www.”——LYX
    def long_clickSearchPanel(self):
        if self.base.elementIsExit(SEARCHPANEL_WEBSITE):
            self.base.long_clickByElement(SEARCHPANEL_WEBSITE, "地址栏文字www")
        else:
            self.assertFalse(SEARCHPANEL_WEBSITE)

    # 拖动输入框中的工具条——LYX
    def swipe_InputPanel(self):
        if self.base.elementIsExit(INPUTPANEL_SWIPE):
            self.base.swipeByElement(INPUTPANEL_SWIPE, "向左拖动工具条", "left", 200)
        else:
            self.assertFalse(INPUTPANEL_SWIPE)

    # 获取第一个搜索热词    ---wmw
    def clickHotWords(self):
        if self.base.elementIsExit(SEARCHPANEL_SEARCH):
            return self.base.elementText(SEARCHPANEL_HOTWORDS, "第一个搜索热词")
        else:
            self.assertFalse(SEARCHPANEL_SEARCH)

    # 点击清空    ---wmw
    def clickEmpty(self):
        if self.base.elementIsExit(SEARCHPANEL_EMPTY):
            self.base.clickByElement(SEARCHPANEL_EMPTY, "清空")
        else:
            self.assertFalse(SEARCHPANEL_EMPTY)

    # 点击搜索框——LYX
    def clickSearchPanel(self):
        if self.base.elementIsExit(SEARCHPANEL_WEBSITE):
            self.base.clickByElement(SEARCHPANEL_WEBSITE, "搜索框")
        else:
            self.assertFalse(SEARCHPANEL_WEBSITE)

    # 点击搜索框联想词——LYX
    def clickAutomatedWord(self):
        if self.base.elementIsExit(AUTOMATED_WORD):
            self.base.clickByElement(AUTOMATED_WORD, "搜索框联想词")
        else:
            self.assertFalse(AUTOMATED_WORD)

    # 点击地址栏清空按钮——LYX
    def clearSearchPanel(self):
        if self.base.elementIsExit(SEARCHPANEL_CLEAR):
            self.base.clickByElement(SEARCHPANEL_CLEAR, "地址栏清空按钮")
        else:
            self.assertFalse(SEARCHPANEL_CLEAR)

    # 点击清空搜索历史——LYX
    def clearSearchHistory(self):
        if self.base.elementIsExit(CLEARSEARCHHISTORY):
            self.base.clickByElement(CLEARSEARCHHISTORY, "地址栏清空按钮")
        else:
            self.assertFalse(CLEARSEARCHHISTORY)

    # 地址栏输入百度——LYX
    def inputBaidu(self):
        if self.base.elementIsExit(SEARCHPANEL_WEBSITE):
            self.base.elementSetText(SEARCHPANEL_WEBSITE, "m.baidu.com",
                                     "百度网址")
        else:
            self.assertFalse(SEARCHPANEL_WEBSITE)

    # 点击搜索框右侧的搜索/进入按钮——LYX
    def clickSearchInto(self):
        if self.base.elementIsExit(SEARCHPANEL_OPEN):
            self.base.clickByElement(SEARCHPANEL_OPEN, "搜索框右侧进入按钮")
        else:
            self.assertFalse(SEARCHPANEL_OPEN)

    # 搜索框输入m.80txt.com  --wmw
    def inputNumber(self):
        if self.base.elementIsExit(SEARCHPANEL_TEXT):
            self.base.elementSetText(SEARCHPANEL_TEXT, "m.80txt.la",
                                     "搜索框输入m.80txt.com")
        else:
            self.assertFalse(SEARCHPANEL_TEXT)

    # 滑动百度页面——LYX
    def swipeBaidu(self):
        if self.base.elementIsExit(BAIDU_LOGO):
            self.base.swipeByElement(BAIDU_LOGO, '滑动百度页面', 'up')
        else:
            self.assertFalse(BAIDU_LOGO)

    # 点击百度页面收起的地址栏——LYX
    def clickwebsite(self):
        if self.base.elementIsExit(WEBSITE_PACKUP):
            self.base.clickByElement(WEBSITE_PACKUP, "百度页面收起的地址栏")
        else:
            self.assertFalse(WEBSITE_PACKUP)

    # 长按搜索历史中的百度网址——LYX
    def long_clickSearchHistory(self):
        if self.base.elementIsExit(BAIDU_WEBSITE):
            self.base.long_clickByElement(BAIDU_WEBSITE, "搜索历史中的百度网址")
        else:
            self.assertFalse(BAIDU_WEBSITE)

    # 点击搜索历史中的删除按钮——LYX
    def delete_SearchHistory(self):
        if self.base.elementIsExit(DELETESEARCHHISTORY):
            self.base.clickByElement(DELETESEARCHHISTORY, "搜索历史中的删除按钮")
        else:
            self.base.assertFalse(DELETESEARCHHISTORY)

    # 地址栏输入主题美化跳转地址——LYX
    def inputCustomize(self):
        if self.base.elementIsExit(SEARCHPANEL_WEBSITE):
            self.base.elementSetText(SEARCHPANEL_WEBSITE, CUSTOMIZE_ADDRESS,
                                     "百度网址")
        else:
            self.assertFalse(SEARCHPANEL_WEBSITE)

    # 点击主题美化跳转提示,允许按钮——LYX
    def skipCustomize(self):
        if self.base.elementIsExit(CUSTOMIZE_SKIP, 2):
            self.base.clickByElement(CUSTOMIZE_SKIP, "允许跳转至主题美化")
        else:
            self.base.assertFalse(CUSTOMIZE_SKIP)

    # 获取搜索框文本    ---wmw
    def clickSearchText(self):
        if self.base.elementIsExit(SEARCHPANEL_OPEN):
            return self.base.elementText(SEARCHPANEL_TEXT, "获取搜索框文本")
        else:
            self.base.assertFalse(CUSTOMIZE_SKIP)

    # 点击某个元素多次 —— LJX
    def clickMoreRefresh(self, element, times):
        if self.base.elementIsExit(element):
            for i in range(1, times):
                self.base.clickByElement(element,
                                         '第{}次点击{}按钮'.format(i, element))
        else:
            self.base.assertFalse(element)
コード例 #2
0
class HomePage(Base):

    def __init__(self, driver):
        self.base = Base(driver)

    # 点击导航栏中“更多”按钮
    def clickBusinessMore(self):
        if self.base.elementIsExit(HOME_BUSINESS_MORE_TEXT):
            self.base.clickByElementIdAndText(HOME_BUSINESS_ID, HOME_BUSINESS_MORE_TEXT, "导航栏-》更多")
        else:
            self.assertFalse(HOME_BUSINESS_MORE_TEXT)

    # 点击工具栏中more菜单
    def clickMore(self):
        if self.base.elementIsExit(HOME_MORE):
            self.base.clickByElement(HOME_MORE, '浏览器首页more菜单')
        else:
            self.assertFalse(HOME_MORE)

    # 点击工具栏中home菜单
    def clickHome(self):
        if self.base.elementIsExit(HOME_HOME):
            self.base.clickByElement(HOME_HOME, '浏览器首页home菜单')
        else:
            self.assertFalse(HOME_HOME)


    # 根据传参确认是否需要点击home按钮
    def clickHomeOnPage(self, page):
        if page == HOME_PAGE and self.base.elementIsExit(SAVED_PAGE):
            self.clickHome()
        elif page == MYCOLLECTION and self.base.elementIsExit(ARTICLE_ID):
            self.clickHome()
        else:
            pass

    # 点击首页搜索框——LYX
    def clickHomeSearch(self):
        if self.base.elementIsExit(HOME_SEARCH):
            self.base.clickByElement(HOME_SEARCH,'首页搜索框')
        else:
            self.assertFalse(HOME_SEARCH)

    # 点击资讯information   ----wmw
    def clickInformation(self):
        if self.base.elementIsExit(HOME_INFORMATION):
            self.base.clickByElement(HOME_INFORMATION,'资讯')
        else:
            self.assertFalse(HOME_INFORMATION)

    # 点击资讯广告   ----wmw
    def clickAdvertisement(self):
        if self.base.elementIsExit(HOME_ADVERTISEMENT):
            self.base.clickByElement(HOME_ADVERTISEMENT,'资讯流广告')
        else:
            self.assertFalse(HOME_ADVERTISEMENT)

    # 点击安居客首页新房入口——LYX
    def clickNewHouse(self):
        if self.base.elementIsExit(NEWHOUSE):
            self.base.clickByElement(NEWHOUSE,'安居客首页新房入口')
        else:
            self.assertFalse(NEWHOUSE)

    # 从屏幕边缘右滑手势后退——LYX
    def right_swipe(self):
        sleep(1)
        self.base.swipeByElement(RIGHTSWIPE_COORDINATE,"屏幕边缘右滑")

    # 从屏幕边缘左滑手势前进——LYX
    def left_swipe(self):
        sleep(1)
        self.base.swipeByElement(LEFTSWIPE_COORDINATE,"屏幕边缘左滑")

    # 提取首页12个导航位的名称——LYX
    def get_HomeBusiness(self):
        HOME_BUSINESS_NAME = []
        for i in range(12):
            text = self.base.elementText(HOME_BUSINESS_ID,"首页导航栏",i)
            HOME_BUSINESS_NAME.append(text)
        return HOME_BUSINESS_NAME

    # 点击安居客首页新房入口——LYX
    def clickNewHouse(self):
        if self.base.elementIsExit(NEWHOUSE):
            self.base.clickByElement(NEWHOUSE,'安居客首页新房入口')
        else:
            self.assertFalse(NEWHOUSE)

    # 点击小说精选页的推荐小说——LYX
    def clickTv_Novel(self):
        if self.base.elementIsExit(TV_NOVEL):
            self.base.clickByElement(TV_NOVEL,'小说详情页的推荐小说')
        else:
            self.assertFalse(TV_NOVEL)

    # 点击小说详情页的免费阅读——LYX
    def clickFreeRead(self):
        if self.base.elementIsExit(FREE_READ):
            self.base.clickByElement(FREE_READ,'小说详情页的免费阅读')
        else:
            self.assertFalse(FREE_READ)