示例#1
0
 def setUpClass(cls):
     Log = Logger()
     Log.info("========%s测试开始:========" % __class__.__name__)
     nowtime = time.strftime("%Y%m%d%H%M")
     driver = webdriver.Remote(appium_url, desired_caps)
     cls.nowtime=nowtime
     cls.Log=Log
     cls.driver=driver
     # 判断是否有弹窗,并关闭
     Main(driver).close_ad()
     Main(driver).close_update()
     Mine(driver).stay_location()
     Main(driver).into_Mainpage(1)
示例#2
0
 def test_rightAnswer(self):
     self.Log.info("[智能练习:偷窥答案全部做对]测试开始")
     while True:
         try:
             title = Question(self.driver).confirm_type()
             if "单" in title:
                 Question(self.driver).right_answer()
             elif "多" in title:
                 Question(self.driver).right_answer()
                 Move(self.driver).swipLeft()
             else:
                 Move(self.driver).swipLeft()
         except Exception as e:
             break
             self.driver.save_screenshot(Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime))
             raise e
     try:
         rate = int(Result(self.driver).get_rate())
         self.assertEqual(rate,100)
     except Exception as e:
         self.driver.save_screenshot(
             Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime))
         raise e
     else:
         self.Log.info("正确率是100%,[智能练习:偷窥答案全部做对]测试结束")
     finally:
         Main(self.driver).back()
示例#3
0
 def test_customAnswer(self):
     self.Log.info("[智能练习]测试开始")
     while True:
         try:
             title = Question(self.driver).confirm_type()
             if "单" in title:
                 Question(self.driver).single_choice("A")
             elif "多" in title:
                 Question(self.driver).multiple_choice(["A", "B"])
                 Move(self.driver).swipLeft()
             else:
                 Move(self.driver).swipLeft()
         except Exception as e:
             break
             self.driver.save_screenshot(Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime))
             raise e
     try:
         rate=Result(self.driver).get_rate()
     except Exception as e:
         self.driver.save_screenshot(
             Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime))
         raise e
     else:
         self.Log.info("进入测试结果页,[智能练习]测试结束,正确率为%s%%"%rate)
     finally:
         Main(self.driver).back()
示例#4
0
 def stay_location(self):
     try:
         WebDriverWait(self.driver, 5, 0.2).until(
             EC.visibility_of_element_located(
                 (By.ID, mine_username_location)))
     except:
         # Login(self.driver).account_login()
         Mine(self.driver).into_login()
         try:
             WebDriverWait(self.driver, 10, 0.2).until(
                 EC.visibility_of_element_located(
                     (By.ID, account_login_location)))
         except Exception as e:
             raise e
         else:
             self.driver.find_element_by_id(account_login_location).click()
         try:
             WebDriverWait(self.driver, 10, 0.2).until(
                 EC.visibility_of_element_located(
                     (By.ID, account_location)))
         except Exception as e:
             raise e
         else:
             # 判断是否有输入,有输入则清楚后输入
             self.driver.find_element_by_id(account_location).clear()
             self.driver.find_element_by_id(account_location).send_keys(
                 account)
             self.driver.find_element_by_id(password_location).clear()
             self.driver.find_element_by_id(password_location).send_keys(
                 password)
             self.driver.find_element_by_id(login_botton_location).click()
             Main(self.driver).close_update()
示例#5
0
 def submit(self):
     self.driver.find_element_by_id(submit_location).click()
     try:
         WebDriverWait(self.driver, 2, 0.2).until(EC.visibility_of_element_located((By.ID, confirm_window)))
     except:
         pass
     else:
         Main(self.driver).click_windows("确定")
示例#6
0
 def setUpClass(cls):
     Logger().info("========%s测试开始========" % __class__.__name__)
     nowtime = time.strftime("%Y%m%d%H%M")
     Log = Logger()
     driver = webdriver.Remote(appium_url, desired_caps)
     cls.nowtime = nowtime
     cls.Log = Log
     cls.driver = driver
     Main(driver).close_ad()
示例#7
0
 def test_everydayExercise_right(self):
     self.Log.info("[每日一练:偷窥答案全部做对]测试开始")
     Main(self.driver).into_Mainpage(1)
     Home(self.driver).shot_menu("每日一练")
     try:
         WebDriverWait(self.driver, 10, 0.5).until(
             EC.visibility_of_element_located((By.NAME, "再做一遍")))
     except:
         pass
     else:
         self.driver.find_element_by_name("再做一遍").click()
     while True:
         try:
             title = Question(self.driver).confirm_type()
             if "单" in title:
                 Question(self.driver).right_answer()
             elif "多" in title:
                 Question(self.driver).right_answer()
                 Move(self.driver).swipLeft()
             else:
                 Move(self.driver).swipLeft()
         except Exception as e:
             break
             self.driver.save_screenshot(
                 Project_path.Image_path + "%s_%s.png" %
                 (sys._getframe().f_code.co_name, self.nowtime))
             raise e
     try:
         rate = int(Result(self.driver).get_rate())
         self.assertEqual(rate, 100)
     except Exception as e:
         self.driver.save_screenshot(
             Project_path.Image_path + "%s_%s.png" %
             (sys._getframe().f_code.co_name, self.nowtime))
         raise e
     else:
         self.Log.info("正确率是100%,[每日一练:偷窥答案全部做对]测试结束")
     finally:
         Main(self.driver).back()
示例#8
0
 def test_seeAnswer(self):
     self.Log.info("偷窥答案测试开始")
     Question(self.driver).see_answer()
     try:
         self.assertIsNotNone(answer_location)
     except Exception as e:
         self.driver.save_screenshot(
             Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime))
         raise e
     else:
         self.Log.info("偷窥答案生效,测试结束")
     finally:
         Main(self.driver).back()
示例#9
0
 def test_everydayExercise(self):
     self.Log.info("[每日一练]测试开始")
     Main(self.driver).into_Mainpage(1)
     Home(self.driver).shot_menu("每日一练")
     try:
         WebDriverWait(self.driver, 5, 0.2).until(
             EC.visibility_of_element_located((By.NAME, "再做一遍")))
     except:
         pass
     else:
         self.driver.find_element_by_name("再做一遍").click()
     while True:
         try:
             title = Question(self.driver).confirm_type()
             if "单" in title:
                 Question(self.driver).single_choice("A")
             elif "多" in title:
                 Question(self.driver).multiple_choice(["A", "B"])
                 Move(self.driver).swipLeft()
             else:
                 Move(self.driver).swipLeft()
         except Exception as e:
             break
             self.driver.save_screenshot(
                 Project_path.Image_path + "%s_%s.png" %
                 (sys._getframe().f_code.co_name, self.nowtime))
             raise e
     try:
         rate = Result(self.driver).get_rate()
     except Exception as e:
         self.driver.save_screenshot(
             Project_path.Image_path + "%s_%s.png" %
             (sys._getframe().f_code.co_name, self.nowtime))
         raise e
     else:
         self.Log.info("进入测试结果页,[每日一练]测试结束,正确率为%s%%" % rate)
     finally:
         Main(self.driver).back()
示例#10
0
 def test_questionPage_submit(self):  #试题页面交卷按钮验证
     self.Log.info("试题页面交卷测试开始")
     Question(self.driver).single_choice("A")
     Question(self.driver).submit()
     try:
         rate = Result(self.driver).get_rate()
     except Exception as e:
         self.driver.save_screenshot(
             Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime))
         raise e
     else:
         self.Log.info("进入测试结果页,正确率为%s%%,[智能练习:答题卡页面交卷]测试结束" % rate )
     finally:
         Main(self.driver).back()
示例#11
0
 def test_share(self):
     self.Log.info("分享按钮测试开始")
     self.driver.find_element_by_id(share_location).click()
     try:
         self.assertIsNotNone(share_menu_location)
     except Exception as e:
         self.driver.save_screenshot(
             Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime))
         raise e
     else:
         self.Log.info("弹出分享菜单,测试结束")
     finally:
         self.driver.find_element_by_id(cancel_share_location).click()
         Main(self.driver).back()
示例#12
0
 def test_iscollect(self):
     self.Log.info("收藏试题测试开始")
     collect_name1=self.driver.find_element_by_id(collect_location).text
     Question(self.driver).collect()
     collect_name2=self.driver.find_element_by_id(collect_location).text
     try:
         self.assertNotEqual(collect_name1,collect_name2)
     except Exception as e:
         self.driver.save_screenshot(
             Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime))
         raise e
     else:
         self.Log.info("收藏按钮生效,测试结束")
     finally:
         Main(self.driver).back()
示例#13
0
 def account_login(self, account=account, password=password):
     self.into_account_login()
     try:
         WebDriverWait(self.driver, 10, 0.2).until(
             EC.visibility_of_element_located((By.ID, account_location)))
     except Exception as e:
         raise e
     else:
         #判断是否有输入,有输入则清楚后输入
         self.driver.find_element_by_id(account_location).clear()
         self.driver.find_element_by_id(account_location).send_keys(account)
         self.driver.find_element_by_id(password_location).clear()
         self.driver.find_element_by_id(password_location).send_keys(
             password)
         self.driver.find_element_by_id(login_botton_location).click()
     Main(self.driver).close_update()
示例#14
0
 def quit_account(self):
     try:
         WebDriverWait(self.driver, 5, 0.2).until(
             EC.visibility_of_element_located(
                 (By.ID, mine_username_location)))
     except Exception as e:
         raise e
     else:
         self.driver.find_element_by_id(mine_username_location).click()
         try:
             WebDriverWait(self.driver, 10, 0.2).until(
                 EC.visibility_of_element_located(
                     (By.ID, quit_login_button_location)))
         except Exception as e:
             raise e
         else:
             self.driver.find_element_by_id(
                 quit_login_button_location).click()
             Main(self.driver).click_windows("确定")
示例#15
0
 def __init__(self, driver):
     self.driver = driver
     Main(self.driver).into_Mainpage(1)
示例#16
0
 def __init__(self, driver):
     self.driver = driver
     try:
         Main(self.driver).into_Mainpage(4)
     except:
         pass
示例#17
0
 def setUp(self):
     Main(self.driver).close_ad()
     Main(self.driver).close_update()
     Mine(self.driver).stay_unlocation()