# -*- coding: utf-8 -*- # @Author : wrx from time import sleep import allure import pytest from public.models.read_yaml_data import read_yamlData from public.page_obj.login import Login loginData = read_yamlData(r"\testcase\testdata\login_data.yaml") webElement = read_yamlData(r"\public\webElement\cpip.yaml") loginFailData = loginData[0:3] loginSuccessData = loginData[3:] @allure.feature("测试登录模块") class Test_login: """ 登录测试 """ def setup(self): self.loginPage = Login() def teardown(self): self.loginPage.get_driver().quit() @allure.story('登录失败测试用例') @pytest.mark.parametrize("loginData", loginFailData) def test_login_failure(self, loginData): with allure.step("开始登录"):
# -*- coding: utf-8 -*- # @Author : wrx from time import sleep import allure import pytest from public.models.myunit import MyUnit from public.models.read_yaml_data import read_yamlData menuData1 = read_yamlData(r"\testcase\testdata\menu_data.yaml") menuData2 = read_yamlData(r"\testcase\testdata\menu_data2.yaml") isLogout = ["LogoutN", "LogoutY"] @allure.feature("首页测试用例") class Test_mainPage(MyUnit): """ 用例描述:处方点评首页 """ @allure.story("测试菜单点击1") @pytest.mark.parametrize("menu", menuData1) def test_intoMenu(self, menu): pytest.assume( self.main.into_menu(*menu.split('-')) == menuData1[menu], "") @allure.story("测试菜单点击2") @pytest.mark.parametrize("menu", menuData2) def test_intoMenu2(self, menu): pytest.assume( self.main.into_menu(*menu.split('-')) == menuData1[menu], "")
# -*- coding: utf-8 -*- # @Author : wrx from selenium.webdriver.common.by import By from public.models.read_yaml_data import read_yamlData from public.page_obj.basePage import BasePage from public.page_obj.moreConditionPage import MoreConditionsPage webElement = read_yamlData(r"\public\webElement\addPlan.yaml") class MzPlanPage(BasePage): """ 新增计划页面 """ def inputPlanName(self, name): """ 输入计划名称 :param name: :return: """ self.find(webElement["计划名称"]).send_keys(name) def inputPlanDescription(self, description): """ 输入计划描述 :param description: :return: """ self.find(webElement["计划描述"]).send_keys(description)
# -*- coding: utf-8 -*- # @Author : wrx import time from selenium.webdriver.common.keys import Keys from public.page_obj.basePage import BasePage from public.models.read_yaml_data import read_yamlData from public.page_obj.station import Station webElement = read_yamlData(r"\public\webElement\login.yaml") class Login(BasePage): """ 用户登录页 """ _base_url = "http://172.16.0.166:8034/index.html" def login(self, username, password): self.find(webElement["UserName"]).clear() self.find(webElement["UserName"]).send_keys(username) self.find(webElement["PassWord"]).clear() self.find(webElement["PassWord"]).send_keys(password) # time.sleep(3) # self.find(webElement["Login"]).click() self.find(webElement["PassWord"]).send_keys(Keys.ENTER) return Station(self._driver) if __name__ == '__main__':
# -*- coding: utf-8 -*- # @Author : wrx from time import sleep from selenium.webdriver.common.action_chains import ActionChains from public.models.read_yaml_data import read_yamlData from public.page_obj.basePage import BasePage webElement = read_yamlData(r"\public\webElement\cpip.yaml") class Station(BasePage): """ 临床药师智慧平台页面 """ # _base_url = "http://172.16.0.166:8034/index.html#/loginStation" def module_click(self, module): """ 点击进入处方点评/用户管理模块 :return: """ global element actions = ActionChains(self._driver) if module == '处方点评': element = self.find(webElement["cfdpModule"]) actions.move_to_element(element).perform() element.click() sleep(2) from public.page_obj.main import Main return Main(self._driver)
# -*- coding: utf-8 -*- # @Author : wrx import allure import pytest from public.models.myunit import MyUnit from public.models.read_yaml_data import read_yamlData from public.page_obj.dpjhPage import DpjhPage plan_type = [1, 2] planName = ["天上人间", "抗菌药物点评"] my_plan = read_yamlData(r"\testcase\testdata\myplan.yaml") look_name = read_yamlData(r"\testcase\testdata\planName.yaml") @allure.feature("点评计划列表页测试用例") class Test_dpjh(MyUnit): def setup(self): self.dpjhPage = DpjhPage(self.main.get_driver()) self.dpjhPage.at_page() @allure.story("新增计划") @pytest.mark.dependency(name="add") @pytest.mark.parametrize("planDetail", my_plan) def test_add_mzPlan(self, planDetail): self.dpjhPage.edit_new_mzPlan(planDetail) assert self.dpjhPage.is_exist_plan( my_plan[planDetail]["计划名称"]), "新建计划失败" @allure.story("计划搜索")
# -*- coding: utf-8 -*- # @Author : wrx import allure import pytest from public.models.read_yaml_data import read_yamlData from public.page_obj.login import Login from public.page_obj.main import Main webElement = read_yamlData(r"\public\webElement\index.yaml") webElement2 = read_yamlData(r"\public\webElement\xtgl.yaml") webElement3 = read_yamlData(r"\public\webElement\login.yaml") moduleData = read_yamlData(r"\testcase\testdata\module_data.yaml") isLogout = ["LogoutN", "LogoutY"] @allure.feature("临床药师智慧平台测试用例") class Test_Station: """ 临床药师智慧平台 """ def setup(self): self.stationPage = Login().login("admin", "123") def teardown(self): self.stationPage.get_driver().quit() @allure.story("模块点击测试") @pytest.mark.parametrize("module", moduleData) def test_select_module(self, module):
# -*- coding: utf-8 -*- # @Author : wrx from time import sleep from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By from config.setting import base_url from public.models.read_yaml_data import read_yamlData from public.page_obj.basePage import BasePage from public.page_obj.exResultsPage import ExResultsPage from public.page_obj.mzPlanPage import MzPlanPage from public.page_obj.zyPlanPage import ZyPlanPage webElement = read_yamlData(r"\public\webElement\dpjh.yaml") myPlan = read_yamlData(r"\testcase\testdata\myplan.yaml") look_name = read_yamlData(r"\testcase\testdata\planName.yaml") class DpjhPage(BasePage): """ 点评计划列表页面 """ def at_page(self): # 后期分离 Url self._driver.get( base_url + "#/ReviewPlan/selectPlan")
# -*- coding: utf-8 -*- # @Author : wrx from time import sleep from selenium.webdriver import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.remote.webdriver import WebDriver from public.models.read_yaml_data import read_yamlData from public.page_obj.basePage import BasePage from public.page_obj.dpjhPage import DpjhPage from public.page_obj.login import Login from public.page_obj.station import Station webElement = read_yamlData(r"\public\webElement\index.yaml") menuElement = read_yamlData(r"\public\webElement\menu.yaml") menuData = read_yamlData(r"\testcase\testdata\menu_data.yaml") class Main(BasePage): """ 处方点评首页 """ _base_url = "http://172.16.0.166:8034/index.html" def __init__(self, driver: WebDriver = None): super().__init__(driver) if self._driver.current_url == 'http://172.16.0.166:8034/index.html#/login': Login(self._driver).login("admin", "123").module_click("处方点评")
# -*- coding: utf-8 -*- # @Author : wrx from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By from config.setting import base_url from public.models.read_yaml_data import read_yamlData from public.page_obj.basePage import BasePage webElement = read_yamlData(r"\public\webElement\exResult.yaml") class ExResultsPage(BasePage): """ 抽取结果列表页 """ def at_page(self): # 后期拆分 Url self._driver.get( base_url + "#/ReviewPlan/extractResults") def search_by_keywords(self, name): """ 根据关键字搜索 """ self.find(webElement["输入计划名称"]).clear() self.find(webElement["输入计划名称"]).send_keys(name) self.find(webElement["搜索"]).click() def is_exist_plan(self, planName): """