Commit 985cda35 by linguangwei

添加三个case:检测设备/检查更新/退出登录

parent 55370257
...@@ -21,7 +21,11 @@ def year_to_minute(): ...@@ -21,7 +21,11 @@ def year_to_minute():
def month_day(): def month_day():
return time.localtime().tm_mday today_day = time.localtime().tm_mday
if today_day < 10:
return "0" + str(today_day)
else:
return today_day
def month_not_today(para): def month_not_today(para):
......
from src.pageobject.basepage import Page
from selenium.webdriver.common.by import By
# 主页面-侧边bar
class MainSideBarPage(Page):
# 元素集
# 设置按钮
set_btn = (By.XPATH, "//div[@class='setting']//span[1]")
# 检测设备按钮
test_equipment_btn = (By.XPATH, "//span[text()='设备检测']")
# 检查更新按钮
check_update_btn = (By.XPATH, "//span[text()='检查更新']")
# 退出登录按钮
logout_btn = (By.XPATH, "//span[text()='退出登录']")
# 帮助按钮
help_btn = (By.XPATH, "//div[@class='setting']//span[2]")
# 切换窗口元素
# 设备检测标题
test_equipment_title = (By.XPATH, "//div[text()='设备检测']")
# 关闭检测设备窗口
close_equipment_window = (By.XPATH, "//span[text()='完 成']")
# 测试扬声器按钮窗口
test_speaker_btn = (By.XPATH, "//button[@class='ant-btn speakerBtn']")
# 检查更新为最新版本时
check_update_word = (By.XPATH, "//span[text()='好']")
# 检查更新为非最新版本时
# 校验元素
# 退出登录后的元素
login_title = (By.XPATH, "//div[text()='小麦企学院(讲师版)']")
def __init__(self, driver):
Page.__init__(self, driver)
# 点击设置按钮
def click_set_btn(self):
self.click(self.set_btn)
# 点击检测设备按钮
def click_test_equipment_btn(self):
self.click(self.test_equipment_btn)
# 点击关闭检测设备窗口
def click_close_equipment_window(self):
self.click(self.close_equipment_window)
# 点击检查更新按钮
def click_check_update_btn(self):
self.click(self.check_update_btn)
# 点击关闭检查更新窗口
def click_close_update_window(self):
self.click(self.check_update_word)
# 点击退出登录按钮
def click_logout_btn(self):
self.click(self.logout_btn)
# 点击帮助按钮
def click_help_btn(self):
self.click(self.help_btn)
import allure
import pytest
from src.framework.logger import Logger
from src.pageobject.mainsidebarpage import MainSideBarPage
from src.framework.appDriver import get_app_driver
from config import readConfig
class TestMainPage(object):
cloud_class_location = readConfig.test_location()
driver = get_app_driver(cloud_class_location)
Main_Side_Bar_Page = MainSideBarPage(driver=driver)
sleep_time = 1
@pytest.fixture(scope="module", autouse=True)
def before_test(self):
self.logger = Logger('main side bar page').getlog()
self.Main_Side_Bar_Page.login()
self.Main_Side_Bar_Page.sleep(self.sleep_time)
yield self.driver
self.driver.quit()
@allure.title("测试设备检测")
@allure.description("如果测试当前用例的时候存在其他客户端浏览器,可能会测试不通过")
@pytest.mark.run(order=1)
def testEquipment(self):
self.Main_Side_Bar_Page.click_set_btn()
self.Main_Side_Bar_Page.sleep(self.sleep_time)
self.Main_Side_Bar_Page.click_test_equipment_btn()
self.Main_Side_Bar_Page.change_window(self.Main_Side_Bar_Page.test_equipment_title)
assert self.Main_Side_Bar_Page.ifElementExist(self.Main_Side_Bar_Page.test_equipment_title)
self.Main_Side_Bar_Page.click_close_equipment_window()
@allure.title("测试检查更新")
@pytest.mark.run(order=2)
def testCheckUpdate(self):
self.Main_Side_Bar_Page.change_window(self.Main_Side_Bar_Page.check_update_btn)
self.Main_Side_Bar_Page.click_check_update_btn()
self.Main_Side_Bar_Page.sleep(self.sleep_time)
assert self.Main_Side_Bar_Page.ifElementExist(self.Main_Side_Bar_Page.check_update_word)
self.Main_Side_Bar_Page.sleep(self.sleep_time)
self.Main_Side_Bar_Page.click_close_update_window()
@allure.title("测试退出登录")
@pytest.mark.run(order=3)
def testLogout(self):
self.Main_Side_Bar_Page.click_set_btn()
self.Main_Side_Bar_Page.click_logout_btn()
assert self.Main_Side_Bar_Page.ifElementExist(self.Main_Side_Bar_Page.login_title)
if __name__ == '__main__':
pytest.main(["-v"])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment