Пример #1
0
    def test_3_operationMonitor(self):
        shebeigaojing_h1 = self.driver.find_element_by_xpath(
            GetConf.locator("设备告警", "一级菜单"))
        shebeigaojing_h1.click()

        dangqiangaojing_h2 = self.driver.find_element_by_xpath(
            GetConf.locator("设备告警", "二级菜单_当前告警"))
        lishigaojing_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("设备告警", "二级菜单_历史告警"))

        dangqiangaojing_h2.click()
        word_element_1 = GetConf.locator("设备告警", "元素_当前未结")
        # self.base_page.wait_eleVisible(word_element_1, wait_time=10)
        try:
            self.assertTrue("当前未结" in word_element_1)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_3_operationMonitor,当前告警 用例断言失败")
            raise e

        lishigaojing_h2.click()
        word_element_2 = GetConf.locator("设备告警", "元素_查询按钮")
        # self.base_page.wait_eleVisible(word_element_2, wait_time=10)
        try:
            self.assertTrue("查询" in word_element_2)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_3_operationMonitor,历史告警 用例断言失败")
            raise e
Пример #2
0
    def test_7_report(self):
        baobiao_h1 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("报表管理", "一级菜单"))
        ribao_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("报表管理", "二级菜单_日报"))
        yuebao_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("报表管理", "二级菜单_月报"))

        # 日报
        baobiao_h1.click()
        ribao_h2.click()
        word_element_1 = GetConf.locator("报表管理", "元素_表头")
        try:
            self.base_page.wait_eleVisible(word_element_1, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_7_report,日报 用例断言失败")
            raise e

        # 月报
        yuebao_h2.click()
        word_element_2 = GetConf.locator("报表管理", "元素_表格")
        try:
            self.base_page.wait_eleVisible(word_element_2, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_7_report,月报 用例断言失败")
            raise e
Пример #3
0
    def login(self, name, pwd):
        username_locator = self.driver.find_element_by_xpath(
            GetConf.locator("登录", "用户名"))
        pwd_locator = self.driver.find_element_by_xpath(
            GetConf.locator("登录", "密码"))
        login_button_locator = self.driver.find_element_by_xpath(
            GetConf.locator("登录", "登录"))

        username_locator.send_keys(name)
        pwd_locator.send_keys(pwd)
        login_button_locator.click()
Пример #4
0
class LoginPage(BasePage):
    # 子类集成父类的init不需要使用超继承,也不需要再次定义init的参数,直接用就行了
    username = GetConf.locator("登录", "用户名")
    pwd = GetConf.locator("登录", "密码")

    # 清除输入框里的内容
    def clear_username(self):
        return self.wait_eleVisible(self.username).clear()

    def clear_pwd(self):
        return self.wait_eleVisible(self.pwd).clear()
Пример #5
0
    def test_2_skyView(self):
        nengyuanjiashicang_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("能源驾驶舱", "二级菜单"))
        nengyuanjiashicang_h2.click()

        word_element = GetConf.locator("能源驾驶舱", "能源消耗总量")
        # self.base_page.wait_eleVisible(word_element, wait_time=10)
        try:
            self.assertTrue("能源消耗总量" in word_element)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_2_skyView 用例断言失败")
            raise e
Пример #6
0
 def test_alarm(self):
     self.base_page.wait_eleVisible((GetConf.locator("设备告警",
                                                     "一级菜单"))).click()
     self.base_page.wait_eleVisible((GetConf.locator("设备告警",
                                                     "二级菜单_当前告警"))).click()
     alarm_num = self.base_page.wait_eleVisible(
         (GetConf.locator("设备告警", "元素_当前未结数量")))
     try:
         self.assertFalse(alarm_num.text == 0 or alarm_num.text is None)
         self.base_page.logger.info("用例成功执行")
     except AssertionError as e:
         self.base_page.logger.error("test_alarm 用例断言失败")
         self.base_page.save_screenshot()
         raise e
Пример #7
0
 def test_3_create_role(self):
     self.manage_page.wait_eleclickable(GetConf.locator("权限管理",
                                                        "一级菜单")).click()
     self.manage_page.wait_eleclickable(GetConf.locator(
         "权限管理", "二级菜单_角色管理")).click()
     self.manage_page.submit_role()
     try:
         seccess_locator = self.manage_page.wait_eleVisible(
             GetConf.locator("权限管理", "元素_操作成功提示"), 5)
         self.assertTrue("新增角色成功" == seccess_locator.text)
         self.manage_page.logger.info("用例成功执行")
     except AssertionError as e:
         self.manage_page.logger.error("test_3_create_role 用例断言失败")
         self.manage_page.save_screenshot()
         raise e
Пример #8
0
 def test_5_role_to_user(self):
     self.manage_page.wait_eleclickable(GetConf.locator("权限管理",
                                                        "一级菜单")).click()
     self.manage_page.wait_eleclickable(GetConf.locator(
         "权限管理", "二级菜单_账号管理")).click()
     self.manage_page.add_role_user()
     try:
         seccess_locator = self.manage_page.wait_eleVisible(
             GetConf.locator("权限管理", "元素_操作成功提示"))
         self.assertTrue("操作成功!" == seccess_locator.text)
         self.manage_page.logger.info("用例成功执行")
     except AssertionError as e:
         self.manage_page.logger.error("test_5_role_to_user 用例断言失败")
         self.manage_page.save_screenshot()
         raise e
Пример #9
0
 def test_6_delete_role(self):
     self.manage_page.wait_eleclickable(GetConf.locator("权限管理",
                                                        "一级菜单")).click()
     self.manage_page.wait_eleclickable(GetConf.locator(
         "权限管理", "二级菜单_角色管理")).click()
     self.manage_page.del_role()
     time.sleep(1)
     try:
         role = self.manage_page.ele_exist_or_not(
             GetConf.locator("权限管理", "元素_被删除的角色"))
         self.assertFalse(role)
         self.manage_page.logger.info("用例成功执行")
     except AssertionError as e:
         self.manage_page.logger.error("test_6_delete_role 用例断言失败")
         self.manage_page.save_screenshot()
         raise e
Пример #10
0
 def test_1_create_user(self):
     data = eval(GetConf.datas("CREATEUSER", "user"))
     self.manage_page.wait_eleclickable(GetConf.locator("权限管理",
                                                        "一级菜单")).click()
     self.manage_page.wait_eleclickable(GetConf.locator(
         "权限管理", "二级菜单_账号管理")).click()
     self.manage_page.wait_eleclickable(GetConf.locator("权限管理",
                                                        "元素_新建账号")).click()
     self.manage_page.submit_user(user=data["username"], name=data["name"])
     try:
         seccess_locator = self.manage_page.wait_eleVisible(
             GetConf.locator("权限管理", "元素_操作成功提示"))
         self.assertTrue(data["expected"] == seccess_locator.text)
         self.manage_page.logger.info("用例成功执行")
     except AssertionError as e:
         self.manage_page.logger.error("test_1_create_user 用例断言失败")
         self.manage_page.save_screenshot()
         raise e
Пример #11
0
    def test_1_login(self):
        user = eval(GetConf.datas("USER", "user_ok"))
        self.base_page.login(user["username"], user["password"])
        logo_locator = GetConf.locator("能源节度使", "logo")
        self.base_page.wait_eleVisible(logo_locator, wait_time=10)

        # 检查登录后首页的logo元素有没有出现
        # logo = base_page.driver.find_element_by_xpath('//p[@class="title ml30 flex-row flex-center"]')  # presence_of_element_located() 后面的值一定要是str
        try:
            self.assertTrue('能源节度使' in logo_locator)
        except AssertionError as e:
            self.base_page.logger.error("test_1_login 用例断言失败")
            raise e
Пример #12
0
    def test_8_manage(self):
        quanxian_h1 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("权限管理", "一级菜单"))
        zhanghao_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("权限管理", "二级菜单_账号管理"))
        zuzhi_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("权限管理", "二级菜单_组织管理"))
        role_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("权限管理", "二级菜单_角色管理"))

        # 账号管理
        quanxian_h1.click()
        zhanghao_h2.click()
        word_element_1 = GetConf.locator("权限管理", "元素_新建账号")
        try:
            # self.base_page.wait_eleVisible(word_element_1, wait_time=10)
            self.assertTrue("新建账号" in word_element_1)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_8_manage,账号管理 用例断言失败")
            raise e

        # 组织管理
        zuzhi_h2.click()
        word_element_2 = GetConf.locator("权限管理", "元素_成员管理")
        try:
            # self.base_page.wait_eleVisible(word_element_2, wait_time=10)
            self.assertTrue("成员管理" in word_element_2)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_8_manage,组织管理 用例断言失败")
            raise e

        # 角色管理
        role_h2.click()
        word_element_3 = GetConf.locator("权限管理", "元素_创建角色")
        try:
            # self.base_page.wait_eleVisible(word_element_3, wait_time=10)
            self.assertTrue("创建角色" in word_element_3)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_8_manage,角色管理 用例断言失败")
            raise e
Пример #13
0
    def test_4_currentAlarm(self):
        shishijiance_h1 = self.driver.find_element_by_xpath(
            GetConf.locator("实时监测", "一级菜单"))
        shishigongkuang_h2 = self.driver.find_element_by_xpath(
            GetConf.locator("实时监测", "二级菜单_实时工况"))
        mingxichaxun_h2 = self.driver.find_element_by_xpath(
            GetConf.locator("实时监测", "二级菜单_明细查询"))
        shishijiance_h1.click()
        shishigongkuang_h2.click()

        # 检查有没有出现弹窗提醒,有则点确定关掉弹窗
        time.sleep(3)
        try:
            ok = self.base_page.driver.switch_to.alert
            ok.accept()
        except (NoSuchElementException, NoAlertPresentException) as noalert:
            print(noalert)

        # 切换站点到 宜山大楼
        xiala_element = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("实时监测", "下拉箭头"))
        xiala_element.click()
        yishandalou = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("实时监测", "宜山大楼"))
        yishandalou.click()

        time.sleep(2)
        word_element_4 = GetConf.locator("实时监测", "接线图文字")
        try:
            self.base_page.wait_eleVisible(word_element_4, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_4_currentAlarm,实时工况 用例断言失败")
            raise e

        mingxichaxun_h2.click()
        word_element_5 = GetConf.locator("实时监测", "明细查询_查询按钮")
        try:
            self.base_page.wait_eleVisible(word_element_5, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_4_currentAlarm,明细查询 用例断言失败")
            raise e
Пример #14
0
    def test_5_orderManage(self):
        yunweigongdan_h1 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("运维工单", "一级菜单"))
        gongzuotai_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("运维工单", "二级菜单_工作台"))
        dingjianguanli_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("运维工单", "二级菜单_定检管理"))
        gongdanchaxun_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("运维工单", "二级菜单_工单查询"))

        yunweigongdan_h1.click()
        gongzuotai_h2.click()
        word_element_1 = GetConf.locator("运维工单", "工作台_头像")
        try:
            self.base_page.wait_eleVisible(word_element_1, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_5_orderManage,工作台 用例断言失败")
            raise e

        dingjianguanli_h2.click()
        word_element_2 = GetConf.locator("运维工单", "元素_定检管理_新增计划")
        try:
            self.base_page.wait_eleVisible(word_element_2, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_5_orderManage,定检管理 用例断言失败")
            raise e

        gongdanchaxun_h2.click()
        word_element_3 = GetConf.locator("运维工单", "元素_工单查询_工单编号")
        try:
            self.assertTrue("工单编号" in word_element_3)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_5_orderManage,工单查询 用例断言失败")
            raise e
Пример #15
0
username_locator.send_keys("yoyo")
pwd_locator.send_keys("123456")
login_button_locator.click()
time.sleep(3)
# error_locator = driver.find_element_by_xpath('//div[@class="el-form-item__error"]')
# print(error_locator.text)

# shebeigaojing_h1 = driver.find_element_by_xpath(GetConf.locator("设备告警", "一级菜单"))
# shebeigaojing_h1.click()
#
# dangqiangaojing_h2 = driver.find_element_by_xpath(GetConf.locator("设备告警", "二级菜单_当前告警"))
# lishigaojing_h2 = driver.find_element_by_xpath(GetConf.locator("设备告警", "二级菜单_历史告警"))
# time.sleep(1)
# dangqiangaojing_h2.click()
# word_element_1 = BasePage(driver).wait_eleVisible(GetConf.locator("设备告警", "元素_当前未结数量"))
# print(word_element_1.text)

WebDriverWait(driver,20, 1).until(expected_conditions.visibility_of_element_located((By.XPATH, '//span[text()="权限管理"]'))).click()
# time.sleep(1)
# WebDriverWait(driver,20, 1).until(expected_conditions.element_to_be_clickable((By.XPATH, '//span[text()="账号管理"]'))).click()
# WebDriverWait(driver,20, 1).until(expected_conditions.element_to_be_clickable((By.XPATH, '//div[text()="新建账号"]'))).click()
# WebDriverWait(driver,20, 1).until(expected_conditions.presence_of_element_located((By.XPATH, '//form[@class="el-form el-form--label-top"]/div[2]/div[1]//input[@class="el-input__inner"]'))).send_keys("rrrere")

base_page.wait_eleclickable(GetConf.locator("权限管理", "一级菜单")).click()
base_page.wait_eleclickable(GetConf.locator("权限管理", "二级菜单_角色管理")).click()

role = base_page.ele_exist_or_not(GetConf.locator("权限管理", "元素_被删除的角色"))
print(role)


Пример #16
0
    def test_6_eleQuality(self):
        diannengzhiliang_h1 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("电能质量", "一级菜单"))
        gailan_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("电能质量", "二级菜单_电能质量概览"))
        dianyapiancha_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("电能质量", "二级菜单_电压偏差"))
        gongleyinshu_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("电能质量", "二级菜单_功率因数"))
        sanxiangdianliu_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("电能质量", "二级菜单_三相电流不平衡"))
        xiebodianliu_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("电能质量", "二级菜单_谐波电流"))
        xiebodianya_h2 = self.base_page.driver.find_element_by_xpath(
            GetConf.locator("电能质量", "二级菜单_谐波电压"))

        # 概览页面
        diannengzhiliang_h1.click()
        gailan_h2.click()
        word_element_1 = GetConf.locator("电能质量", "元素_指标")
        try:
            self.base_page.wait_eleVisible(word_element_1, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_6_eleQuality,电能质量概览 用例断言失败")
            raise e

        # 电压偏差页面
        dianyapiancha_h2.click()
        word_element_2 = GetConf.locator("电能质量", "元素_电压合格率")
        try:
            self.base_page.wait_eleVisible(word_element_2, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_6_eleQuality,电压偏差 用例断言失败")
            raise e

        # 功率因数页面
        gongleyinshu_h2.click()
        word_element_3 = GetConf.locator("电能质量", "元素_功率因素")
        try:
            self.base_page.wait_eleVisible(word_element_3, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_6_eleQuality,功率因数 用例断言失败")
            raise e

        # 三相电流不平衡页面
        sanxiangdianliu_h2.click()
        word_element_4 = GetConf.locator("电能质量", "元素_最大不平衡率")
        try:
            self.base_page.wait_eleVisible(word_element_4, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_6_eleQuality,三相电流不平衡 用例断言失败")
            raise e

        # 谐波电流页面
        xiebodianliu_h2.click()
        word_element_5 = GetConf.locator("电能质量", "元素_最大A相电流总畸变率")
        try:
            self.base_page.wait_eleVisible(word_element_5, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_6_eleQuality,谐波电流 用例断言失败")
            raise e

        # 谐波电压页面
        xiebodianya_h2.click()
        word_element_6 = GetConf.locator("电能质量", "元素_最大A相电压总畸变率")
        try:
            self.base_page.wait_eleVisible(word_element_6, wait_time=10)
            self.base_page.logger.info("用例成功执行")
        except AssertionError as e:
            self.base_page.logger.error("test_6_eleQuality,谐波电压 用例断言失败")
            raise e
Пример #17
0
 def clear_username(self):
     return self.wait_eleVisible(GetConf.locator("登录", "用户名")).clear()
Пример #18
0
 def quit_sys(self):
     self.wait_eleclickable(GetConf.locator("登录", "元素_右上角下拉箭头")).click()
     self.wait_eleclickable(GetConf.locator("登录", "元素_退出")).click()
Пример #19
0
 def clear_pwd(self):
     return self.wait_eleVisible(GetConf.locator("登录", "密码")).clear()