Commit 4afd9523 by linguangwei

添加时间轴case

parent 19ead183
from src.pageobject.basepage import Page
from selenium.webdriver.common.by import By
# 主页面-时间bar
class MainBarPage(Page):
# 元素集
# 未选择的日期
day_unselected = (By.XPATH, "//div[@class='day']")
# 已被选择的日期-星期
day_selected_week = (By.XPATH, "//div[@class='day selected']/p[1]")
# 已被选择的日期-月份日期
day_selected_month = (By.XPATH, "//div[@class='day selected']/p[2]")
# 上周
last_week = (By.XPATH, "//div[@class='calendar_Time_week']/div[1]/span[@class='icon iconfont']")
# 下周
next_week = (By.XPATH, "//div[@class='calendar_Time_week']/div[3]/span[@class='icon iconfont']")
def __init__(self, driver):
Page.__init__(self, driver)
# 获取选择日期的星期几
def week_day_text(self):
return self.get_text(self.day_selected_week)
# 获取选择日期的月份-日期
def month_day_text(self):
return self.get_text(self.day_selected_month)
# 点击相邻日期
def click_other_day(self):
self.click(self.day_unselected)
# 点击上周
def click_last_week(self):
self.click(self.last_week)
# 点击下周
def click_next_week(self):
self.click(self.next_week)
import time
import allure
import pytest
from src.framework.logger import Logger
from src.framework.common import week_day, month_day, month_not_today
from src.pageobject.mainbarpage import MainBarPage
from src.framework.appDriver import get_app_driver
from config import readConfig
class TestMainPage(object):
@pytest.fixture(scope="module", autouse=True)
def before_test(self):
print("before_test")
self.logger = Logger('main bar page').getlog()
self.cloud_class_location = readConfig.test_location()
return self.cloud_class_location
@pytest.fixture(scope="function", autouse=True)
def before_test_case(self, before_test):
print("before_test_case")
# 指定客户端的本地路径,在/config/config.ini配置
self.cloud_class_location = before_test
self.sleep_time = 2
self.driver = get_app_driver(self.cloud_class_location)
self.main_bar_page = MainBarPage(driver=self.driver)
self.main_bar_page.login()
yield self.driver
self.driver.quit()
@allure.title("校验今日选择日期是否正确")
@pytest.mark.run(order=1)
def test_IfTrueSelectedDay(self):
self.main_bar_page.sleep(self.sleep_time)
assert self.main_bar_page.month_day_text() == str(month_day())
assert self.main_bar_page.week_day_text() == readConfig.test_day_exchange()[str(week_day())]
@allure.title("点击已选择相邻第一个的未选择日期")
def test_SelectOtherDay(self):
if week_day() != 6:
first_day = month_not_today(-week_day()-1).strftime("%d")
else:
first_day = month_not_today().strftime("%d")
self.main_bar_page.click_other_day()
assert self.main_bar_page.month_day_text() == first_day
@allure.title("点击上周")
def test_SelectOtherDay(self):
first_day = month_not_today(-7).strftime("%d")
self.main_bar_page.click_last_week()
assert self.main_bar_page.month_day_text() == first_day
@allure.title("点击下周")
def test_SelectOtherDay(self):
first_day = month_not_today(7).strftime("%d")
self.main_bar_page.click_next_week()
assert self.main_bar_page.month_day_text() == first_day
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