Exemplo n.º 1
0
 def jiekeyuwenselect(self):
     sleep(2)
     self.login_down = LoginDown(self.driver)
     self.login_down.unloginloginfirst()
     sleep(3)
     print('执行滑动屏幕开始')
     self.swipe = Swipe(self.driver)
     self.swipe.swipe_up()
     print('执行滑动屏幕结束')
     sleep(1)
     self.index_handle = IndexHandle(self.driver)
     self.index_handle.click_coursereadstatus()
     sleep(1)
     self.index_handle.click_jiekestatus()
     sleep(1)
     self.index_handle.click_coursesubject()
     sleep(1)
     self.index_handle.click_subject()
     sleep(1)
     self.index_page = IndexPage(self.driver)
     try:
         self.index_page.get_course_element()
         return True
     except:
         return False
class ClassdetailBusiness:
    def __init__(self, driver):
        self.driver = driver

    def getcourseelement(self):
        try:
            self.index_page = IndexPage(self.driver)
            sleep(3)
            self.index_page.get_course_element()
            print('查询到课程')
            return True
        except:
            print('未查询到课程')
            return False

    def classdetailselect(self):
        if self.getcourseelement():
            self.index_handle = IndexHandle(self.driver)
            self.index_handle.click_course()
            print('执行完成点击课程')
            sleep(2)
            self.classdaylist_page = ClassdaylistPage(self.driver)
            #elements = self.classdaylist_page.get_classdayviewgroup_elements()
            classdaystatus = self.classdaylist_page.get_coursedaystatus_elements(
            )[0].text
            #if len(elements) == 11 and classdaystatus ==  "已下课":
            if classdaystatus == "已下课":
                return True
        else:
            return False
 def submitsuggestion(self):
     dir = self.createdir.createcasedir("submitsuggestion")
     logging.info('----用例submitsuggestion执行开始----')
     try:
         self.index_handle = IndexHandle(self.driver)
         self.index_handle.click_lowerbannerme()
         self.me_handle = MeHandle(self.driver)
         self.me_page = MePage(self.driver)
         # self.me_page.get_suggestion_element()
         self.me_handle.click_suggestion()
         self.suggestion_page = SuggestionPage(self.driver)
         self.suggestion_page.get_return_element()
         self.suggestion_handle = SuggestionHandle(self.driver)
         self.suggestion_handle.send_suggestion("这里是意见反馈内容,高思内部员工测试~")
         self.suggestion_handle.click_submitbutton()
         self.driver.get_screenshot_as_file(dir + '/' + self.username +
                                            'submitsuggestion.png')
         self.suggestion_page.get_editsuggestion_element()
         #self.suggestion_page.get_toast_element("提交成功")
         self.me_page.get_touxiang_element()
         logging.info('----用例submitsuggestion执行结果True,执行结束----')
         return True
     except:
         self.driver.get_screenshot_as_file(dir + '/' + self.username +
                                            'submitsuggestion.png')
         self.restart.restartandroid()
         logging.info("----用例submitsuggestion执行结果False,执行结束----")
         return False
 def selcetpersonalinfo(self):
     logging.info('----用例selcetpersonalinfo执行开始----')
     dir = self.createdir.createcasedir("selcetpersonalinfo")
     logging.info("检查登录状态,如未登录先登录")
     self.login_down=LoginDown(self.driver)
     self.login_down.unloginloginfirst()
     try:
         logging.info("从学习页面查看个人资料动作开始")
         self.index_handle = IndexHandle(self.driver)
         self.index_handle.click_lowerbannerme()
         self.me_handle = MeHandle(self.driver)
         self.me_handle.click_touxiang()
         self.personalinfo_handle = PersonalinfoHandle(self.driver)
         self.personalinfo_page = PersonalinfoPage(self.driver)
         self.personalinfo_page.get_name_element()
         self.driver.get_screenshot_as_file(dir + '/' + self.username + 'selcetpersonalinfo.png')
         self.personalinfo_handle.click_returelogin()
         logging.info("从学习页面查看个人资料返回我的页面,动作结束")
         logging.info("----用例selcetpersonalinfo执行结果True,执行结束----")
         return True
     except:
         self.driver.get_screenshot_as_file(dir + '/' + self.username + 'selcetpersonalinfo.png')
         #self.driver.startActivity("com.gaosi.student", "com.gaosi.student.ui.loading.SplashingActivity")
         self.restart.restartandroid()
         logging.info("----用例selcetpersonalinfo执行结果False,执行结束----")
         return False
class JinbiBusiness:
    def __init__(self, driver, createdir, username):
        self.driver = driver
        self.username = username
        self.createdir = createdir
        self.restart=RestartApp()

    def selcetjinbiinfo(self):
        logging.info('----用例selcetjinbiinfo执行开始----')
        dir = self.createdir.createcasedir("selcetjinbiinfo")
        # logging.info("检查登录状态,如未登录先登录")
        # self.login_down=LoginDown(self.driver)
        # self.login_down.unloginloginfirst()
        try:
            logging.info("从学习页面查看金币动作开始")
            self.index_handle = IndexHandle(self.driver)
            self.index_handle.click_lowerbannerme()
            self.me_handle = MeHandle(self.driver)
            self.me_handle.click_jinbi()
            self.jinbi_handle = JinbiHandle(self.driver)
            self.jinbi_page = JinbiPage(self.driver)
            self.jinbi_page.get_return_element()
            self.driver.get_screenshot_as_file(dir + '/' + self.username + 'selcetpersonalinfo.png')
            self.jinbi_handle.click_returelogin()
            self.me_page=MePage(self.driver)
            self.me_page.get_touxiang_element()
            logging.info("从学习页面查看金币返回我的页面,动作结束")
            logging.info("----用例selcetjinbiinfo执行结果True,执行结束----")
            return True
        except:
            self.driver.get_screenshot_as_file(dir + '/' + self.username + 'selcetpersonalinfo.png')
            #self.driver.startActivity("com.gaosi.student", "com.gaosi.student.ui.loading.SplashingActivity")
            self.restart.restartandroid()
            logging.info("----用例selcetjinbiinfo执行结果False,执行结束----")
            return False
Exemplo n.º 6
0
 def __init__(self, driver):
     self.driver = driver
     self.classdaydetail_handle = Classdaydetail_Handle(self.driver)
     self.classdaydetail_page = ClassdaydetailPage(self.driver)
     self.coursematerial_handle = CoursematerialHandle(self.driver)
     self.classdaylist_handle = Classdaylist_Handle(self.driver)
     self.index_handle = IndexHandle(self.driver)
 def classdetailselect(self):
     if self.getcourseelement():
         self.index_handle = IndexHandle(self.driver)
         self.index_handle.click_course()
         print('执行完成点击课程')
         sleep(2)
         self.classdaylist_page = ClassdaylistPage(self.driver)
         #elements = self.classdaylist_page.get_classdayviewgroup_elements()
         classdaystatus = self.classdaylist_page.get_coursedaystatus_elements(
         )[0].text
         #if len(elements) == 11 and classdaystatus ==  "已下课":
         if classdaystatus == "已下课":
             return True
     else:
         return False
class Downentersetpage:
    def __init__(self, driver):
        self.driver = driver

    #检查是否在set页面
    def checksetpage(self):
        try:
            self.set_page = SetPage(self.driver)
            self.set_page.get_deletecache_element()
            return True
        except:
            return False

    #如果不在set页面,进入set页面
    def downentersetpage(self):
        if self.checksetpage() is False:
            self.index_handle = IndexHandle(self.driver)
            self.index_handle.click_lowerbannerme()
            self.me_handle = MeHandle(self.driver)
            self.me_handle.click_set()
 def logoutlogin(self):
     logging.info('----用例logoutlogin执行开始----')
     dir = self.createdir.createcasedir("logoutlogin")
     logging.info('从学习页面开始退出登录页面动作开始')
     self.index_handle=IndexHandle(self.driver)
     self.index_handle.click_lowerbannerme()
     self.me_handle=MeHandle(self.driver)
     self.me_handle.click_set()
     self.set_handel=SetHandle(self.driver)
     self.set_handel.click_cancellogin()
     self.surelogout_handel=SurelogoutHandle(self.driver)
     self.surelogout_handel.click_oklogoutlogin()
     self.yanzhengmalogin_page=Yanzhengmalogin_Page(self.driver)
     logging.info('从学习页面开始退出登录页面动作结束')
     try:
         self.yanzhengmalogin_page.get_password_login_element()
         self.driver.get_screenshot_as_file(dir + '/'+self.username+'logoutlogin.png')
         logging.info('----用例logoutlogin执行结果True,执行结束----')
         return True
     except:
         self.driver.get_screenshot_as_file(dir + '/'+self.username+'logoutlogin.png')
         logging.info('----用例logoutlogin执行结果False,执行结束----')
         return False
Exemplo n.º 10
0
class PtswBuiness(object):
    def __init__(self, driver):
        self.swdj = SwdjHandle(driver)
        self.index = IndexHandle(driver)
        self.driver = driver

    def ptsw_save(self, bt, file_path, action, **form):
        #点击普通收文
        self.index.click_ptsw()
        #切换窗口
        windows = self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        #填写收文单
        self.swdj.fill_in_form(bt, **form)
        #填写处室信息
        self.swdj.fill_dept(True)
        #上传附件
        self.swdj.upload_file(file_path)
        time.sleep(2)
        if action == "save":
            self.swdj.save()
        elif action == "send":
            self.swdj.send()
        self.driver.switch_to.window(windows[0])

    def test(self):
        return False

    def check(self, bt, btlx):
        #拼接标题
        if 'psj' == btlx:
            bt1 = "批示件:" + bt
        elif 'nbd' == btlx:
            bt1 = "拟办单1:" + bt
        self.index.click_lwycl()
        #locator = (By.CLASS_NAME, "aty-tabs-tab")
        #WebDriverWait(self.driver, 10, 2).until(EC.presence_of_element_located(locator))
        time.sleep(2)
        self.index.click_cgx()
        path = "//div[starts-with(@class,'aty-tabs-content')]/div[2]/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[4]/div"
        locator = (By.XPATH, path)
        wait = WebDriverWait(self.driver, 6, 2)
        element = wait.until(EC.presence_of_element_located(locator))
        if element.text == bt1:
            return True
        else:
            return False
Exemplo n.º 11
0
 def css_test(self):
     driver = BrowserDriver(object).open_browser(
         "Chrome", "http://172.23.22.179:8080/yclpt")
     #driver = BrowserDriver(object).open_browser("home", "http://172.23.22.179:8080/yclpt")
     driver.maximize_window()
     LoginBusiness(driver).login_base("songll", "12345678Aa")
     driver.implicitly_wait(10)
     IndexHandle(driver).click_ptsw()
     c = driver.current_window_handle
     windows = driver.window_handles
     print(c)
     print(windows)
     driver.switch_to.window(windows[-1])
     print(driver.current_window_handle)
     print(driver.title)
     #js = 'swdjVo.cbt=1231321'
     #driver.execute_script(js)
     #time.sleep(2)
     #css = 'css selector'
     #FindElement(driver, "SwdjElement").get_element("swh").click()
     #time.sleep(1)
     # msg = driver.find_element_by_xpath('//ul[@class="aty-select-dropdown-list"][2]')
     #FindElement(driver, "SwdjElement").get_element("swhlist").click()
     msg = FindElement(driver, "SwdjElement").get_element("yysx")
     #time.sleep(2)
     #msg = driver.find_element_by_xpath('//ul[@class="aty-select-dropdown-list"][2]')
     #FindElement(driver, "SwdjElement").get_element("mjlist").click()
     #FindElement(driver, "SwdjElement").get_element("swh").click()
     #FindElement(driver, "SwdjElement").get_element("swhlist").click()
     #FindElement(driver, "SwdjElement").get_element("lwdw").send_keys("上海")
     #time.sleep(3)
     #FindElement(driver, "SwdjElement").get_element("lwdwlist").click()
     #msg = driver.find_element_by_xpath("//div[contains(@class,'lwdw')]/ul/li[1]")
     #FindElement(driver, "SwdjElement").get_element("mj").click()
     #time.sleep(1)
     #msg = driver.find_element_by_xpath("//div[contains(@class,'lwdw')]/ul/li[1]")
     #msg = FindElement(driver, "SwdjElement").get_element("mjlist")
     print(msg)
     time.sleep(3)
Exemplo n.º 12
0
 def __init__(self, driver):
     self.swdj = SwdjHandle(driver)
     self.index = IndexHandle(driver)
     self.driver = driver
 def downentersetpage(self):
     if self.checksetpage() is False:
         self.index_handle = IndexHandle(self.driver)
         self.index_handle.click_lowerbannerme()
         self.me_handle = MeHandle(self.driver)
         self.me_handle.click_set()
class LoginBusiness:
    def __init__(self,driver,createdir,username,pwd,errorpwd):
        self.driver=driver
        self.createdir = createdir
        self.get_userinfopublic=Getuserinfopublic()
        self.username=username
        self.pwd=pwd
        self.errorpwd=errorpwd




    # 登陆失败
    def login_mobileorpassword_error(self):
        logging.info('----用例login_mobileorpassword_error执行开始----')
        dir = self.createdir.createcasedir("login_mobileorpassword_error")
        print("创建的目录为" + dir)
        #验证码登陆页面,点击密码登陆
        self.yanzhengmalogin_handle = YanzhengmaloginHandle(self.driver)
        self.yanzhengmalogin_handle.click_passwordlogin()
        #登陆页面输入错误的密码
        self.login_handle = LoginHandle(self.driver)
        #WebDriverWait(self.driver,30, poll_frequency=0.1, ignored_exceptions=None).until(EC.presence_of_element_located((By.ID,'com.gaosi.student:id/et_login_phone')))
        self.login_page = LoginPage(self.driver)
        self.login_page.get_username_element()
        logging.info('获取密码登录页面元素')
        self.login_handle.send_username(self.username)
        self.login_handle.send_password(self.errorpwd)
        #self.driver.keyevent(4)
        self.login_handle.click_login()
        try:
            self.login_page.get_toast_element('手机号或密码错误,请重新输入')
            self.driver.get_screenshot_as_file(dir + '/'+self.username+'login_mobileorpassword_error.png')
            logging.info('----用例login_mobileorpassword_error执行结果True,执行结束----')
            return  True
        except:
            self.driver.get_screenshot_as_file(dir + '/'+self.username+'login_mobileorpassword_error.png')
            logging.info('----用例login_mobileorpassword_error执行结果Flase,执行结束----')
            return  False

    # 登录成功
    def login_pass(self):
        logging.info('----用例login_pass执行开始----')
        dir = self.createdir.createcasedir("login_pass")
        self.login_handle = LoginHandle(self.driver)
        self.login_handle.send_username(self.username)
        self.login_handle.send_password(self.pwd)
        #self.driver.keyevent(4)
        self.login_handle.click_login()
        logging.info('用户名密码登录动作完成')
        #检查是否登录成功
        self.check_enterindex=CheckenterIndex(self.driver)
        if self.check_enterindex.checkenterindex() is True:
            self.driver.get_screenshot_as_file(dir + '/' + self.username + 'login_pass.png')
            logging.info('----用例login_pass执行结果True,执行结束----')
            return True
        else:
            self.driver.get_screenshot_as_file(dir + '/' + self.username + 'login_pass.png')
            logging.info('----用例login_pass执行结果Flase,执行结束----')
            return False

    #退出登陆
    def logoutlogin(self):
        logging.info('----用例logoutlogin执行开始----')
        dir = self.createdir.createcasedir("logoutlogin")
        logging.info('从学习页面开始退出登录页面动作开始')
        self.index_handle=IndexHandle(self.driver)
        self.index_handle.click_lowerbannerme()
        self.me_handle=MeHandle(self.driver)
        self.me_handle.click_set()
        self.set_handel=SetHandle(self.driver)
        self.set_handel.click_cancellogin()
        self.surelogout_handel=SurelogoutHandle(self.driver)
        self.surelogout_handel.click_oklogoutlogin()
        self.yanzhengmalogin_page=Yanzhengmalogin_Page(self.driver)
        logging.info('从学习页面开始退出登录页面动作结束')
        try:
            self.yanzhengmalogin_page.get_password_login_element()
            self.driver.get_screenshot_as_file(dir + '/'+self.username+'logoutlogin.png')
            logging.info('----用例logoutlogin执行结果True,执行结束----')
            return True
        except:
            self.driver.get_screenshot_as_file(dir + '/'+self.username+'logoutlogin.png')
            logging.info('----用例logoutlogin执行结果False,执行结束----')
            return False
Exemplo n.º 15
0
class ClassdaydetailBusiness:
    def __init__(self, driver):
        self.driver = driver
        self.classdaydetail_handle = Classdaydetail_Handle(self.driver)
        self.classdaydetail_page = ClassdaydetailPage(self.driver)
        self.coursematerial_handle = CoursematerialHandle(self.driver)
        self.classdaylist_handle = Classdaylist_Handle(self.driver)
        self.index_handle = IndexHandle(self.driver)

    # 检查直播状态
    def checklivestatus(self):
        self.classdaylist_handle.click_classdaylist()
        sleep(2)
        try:
            self.classdaydetail_page.get_playbackstatus_element()
            return True
        except:
            return False

    #检查禾教元素展示
    def checkhejiaoshow(self):
        sleep(1)
        hejiaomain = self.classdaydetail_page.get_studytasks_element()[0].text
        hejiaomaintitle = self.classdaydetail_page.get_studytaskstitle_element(
        )[0].text
        print("禾教入口" + hejiaomain)
        print("禾教标题" + hejiaomaintitle)
        if hejiaomain == "去练习" and hejiaomaintitle == "英语口语":
            return True
        else:
            return False

    # 点击第一个自我巩固任务,检查老师评语是否正确
    def checkteacherremark(self):
        self.classdaydetail_handle.clickonlinestudytasks()
        sleep(2)
        self.correctresult_page = CorrectresultPage(self.driver)
        teacherremark = self.correctresult_page.get_teacherremark_element(
        ).text
        if teacherremark == "很好":
            return True
        else:
            return False

    #返回课节详情页,点击课程资料,检查内容
    def checklivematerial(self):
        self.correctresult_handle = CorrectresultHandle(self.driver)
        self.correctresult_handle.click_returnbutton()
        sleep(2)
        self.swipe = Swipe(self.driver)
        self.swipe.swipe_up()
        sleep(2)
        self.classdaydetail_handle.clickcoursematerial()
        sleep(2)
        self.coursematerial_handle.click_pdfmaterial()
        sleep(8)
        self.pdfpreview_page = PdfpreviewPage(self.driver)
        try:
            self.pdfpreview_page.get_pdfpreview_element()
            return True
        except:
            return False

    #从预览pdf页面逐步返回到首页
    def returnindex(self):
        self.pdfpreview_handle = PdfpreviewHandle(self.driver)
        sleep(2)
        self.pdfpreview_handle.click_returnbutton()
        sleep(3)
        self.coursematerial_handle.click_returnbutton()
        sleep(3)
        self.classdaydetail_handle.click_returnbutton()
        sleep(3)
        self.classdaylist_handle.click_returnbutton()
        sleep(3)

    #检查专题课页面元素是否存在
    def zhuanticourseelementcheck(self):
        self.zhuanticourse_page = ZhuantiCoursePage(self.driver)

        len = self.zhuanticourse_page.get_zhuanticoursesubjectchoose_elements()
        if len == 1:
            return True
        elif len == 0:
            return False

    def zhuanticoursetaskcheck(self):
        self.returnindex()
        self.index_handle.click_course1()
        sleep(3)
        self.classdaylist_handle.click_classdaylist3()
        sleep(3)
        self.classdaydetail_handle.clickzhuanticoursetasks()
        sleep(15)
        #手动按压屏幕操作
        TouchAction(self.driver).press(x=200, y=200).release().perform()
        sleep(1)
        try:
            if self.zhuanticourseelementcheck():
                self.driver.keyevent(4)
                sleep(2)
                print("发现题目,返回True,Pass")
                return True
            else:
                self.zhuanticourse_handle = ZhuanticourseHandle(self.driver)
                self.zhuanticourse_handle.click_returnbutton()
                sleep(2)
                print("发现页面返回元素,返回True,Pass")
                return True
        except:
            print("专题课用例失败")
            return False

        #自我巩固任务检查
    def selfreinforcementtaskscheck(self):
        self.classdaydetail_handle.clickselfreinforcementtasks()
        sleep(2)
        try:
            self.selfreinforcement_page = SelfreinforcementPage(self.driver)
            self.selfreinforcement_page.get_selfreinforcementjifen_elements()
            self.selfreinforcement_handle = SelfreinforcementHandle(
                self.driver)
            self.selfreinforcement_handle.click_returnbutton()
            sleep(2)
            return True
        except:
            return False