web自动化7-pytest④实践测试用例-回归用例web自动化部分代码

news2024/11/13 14:34:54

文档说明:

  • 本文档包括web自动化目录结构
  • 代码元素定位 : 父级, 同级后面, 同级div, 包含, 不包含, 鼠标右键, 悬停, 句柄切换(浏览器切换,关闭), 不可见元素查找, 滑动到不可见元素出现, 悬停后点击, 页面有值判断, 页面数据量判断
  • web自动化: 前置, 后置事件
    结合上篇文章, 基本可以实现 web 自动化所有内容. 结合前几篇文章, 应用场景足够丰富!

目录结构:
在这里插入图片描述
conftest.py

# -*- coding: utf-8 -*-
"""
conftest - 
Author: duxiaowei
Date: 2024/7/19
"""
import time

import pytest
from selenium.webdriver.common.by import By

import cs_auto.web.com.common as common


@pytest.fixture(scope="session", autouse=True)
def web_start():
    # 设置环境
    # data = {'url': 'http://lemut.qd-aliyun-dmz-ack-internal.haier.net/ut/login', 'name': 221208530, 'pwd': 'Lexin,18766227989'}
    data = {'url': 'http://lemut.qd-aliyun-dmz-ack-internal.haier.net/ut/login', 'name': 13256883967, 'pwd': 'kf,13256883967'}
    # data = {'url': 'http://lemut-prev.qd-aliyun-dmz-ack-internal.haier.net/ut/login', 'name': 221208530, 'pwd': 'Lexin,18766227989'}
    # 坐席 - 登陆
    driver = common.login(data)
    driver.implicitly_wait(20)
    # 展开左侧
    driver.find_element(By.XPATH, '//div[@class="aRight"]').click()
    time.sleep(2)
    return driver

# -*- coding: utf-8 -*-
"""
conftest - 
Author: duxiaowei
Date: 2024/7/19
"""
import time

import pytest
from selenium.webdriver.common.by import By

import cs_auto.web.com.common as common


@pytest.fixture(scope="session", autouse=True)
def web_start():
    # 设置环境
    # data = {'url': 'http://lemut.qd-aliyun-dmz-ack-internal.haier.net/ut/login', 'name': 221208530, 'pwd': 'Lexin,18766227989'}
    data = {'url': 'http://lemut.qd-aliyun-dmz-ack-internal.haier.net/ut/login', 'name': 13256883967, 'pwd': 'kf,13256883967'}
    # data = {'url': 'http://lemut-prev.qd-aliyun-dmz-ack-internal.haier.net/ut/login', 'name': 221208530, 'pwd': 'Lexin,18766227989'}
    # 坐席 - 登陆
    driver = common.login(data)
    driver.implicitly_wait(20)
    # 展开左侧
    driver.find_element(By.XPATH, '//div[@class="aRight"]').click()
    time.sleep(2)
    return driver

# 关闭浏览器
@pytest.fixture(scope="session", autouse=True)
def web_end(web_start):
    yield
    web_start.close()


run.py

# -*- coding: utf-8 -*-
"""
run - 
Author: duxiaowei
Date: 2024/7/19
"""
import os

import pytest

if __name__ == '__main__':
    # pytest.main(["lemut_yywh_test.py::Test_运营维护::test_安装机器人信息采集"])
    pytest.main(["知识库_test.py::Test_业务受理::test_问答推荐","知识库_test.py::Test_业务受理::test_Uhome燃气热水器", "知识库_test.py::Test_业务受理::test_产品大类"])
    # 清空目录,并重新生成新的文件
    # os.system("allure generate ./allure_result -o ./allure-report --clean")
    # # 切换目录
    # os.system("cd D:\\code\\python\\cs_auto\\web\\test_auto\\allure-report")
    # 打开报告
    # os.system("allure serve D:\\code\\python\\cs_auto\\web\\test_auto\\allure-report")



# pytest.main(["lemut_yqgl_test.py::Test_舆情管理","lemut_yhqx_test.py::Test_用户与权限"])
# 运行生成测试报告:allure generate ./allure_result -o ./allure-report --clean
# allure使用了两种方式来渲染页面。分别是 allure open 和 allure serve。
# allure open:用于在本地渲染和查看结果;
# allure serve:用于在本地渲染后对外展示结果。

pytest.ini

[pytest]

testpaths = ./web
addopts = -vs --alluredir ./allure_result --reruns=0 --reruns-delay=3

lemut_ywsl_test.py

# -*- coding: utf-8 -*-
"""
lemut_select - 业务受理 10-
Author: duxiaowei
Date: 2024/7/17
"""
import time

import allure
import pytest
from selenium.webdriver.common.by import By


# 业务受理
@allure.feature("业务受理")
@pytest.mark.run(order=10)
class Test_业务受理:

    @pytest.fixture(scope="function", autouse=True)
    def setup(self, web_start):
        self.driver = web_start
        time.sleep(1)
        self.driver.find_element(By.XPATH, '//div/span[text()="业务受理"]').click()
        time.sleep(2)
        yield
        time.sleep(1)
        # 关闭当前页签,打开-业务查询页签
        self.driver.find_element(By.XPATH, '//div/span[text()="业务受理"]').click()

    # 客满维护
    @pytest.mark.run(order=11)
    @allure.title("客满维护")
    @pytest.mark.parametrize('HIC信息单号,开始天,结束天', [("YT02407120021805", "2024-07-11", "2024-07-12")])
    def test_客满维护(self, HIC信息单号, 开始天, 结束天):
        self.driver.find_element(By.XPATH, '//ul/li[text()="客满维护"]').click()
        time.sleep(2)
        try:
            self.driver.find_element(By.XPATH, '//label[text()="HIC信息单号:"]/following-sibling::div/div/input').send_keys(
                HIC信息单号)
            time.sleep(1)
            # 时间框
            self.driver.find_element(By.XPATH, '//label[text()="挂机时间:"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').send_keys(
                开始天)
            time.sleep(1)
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].clear()
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].send_keys(结束天)
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div[@class="el-picker-panel__footer"]/button[2]/span').click()

            time.sleep(1)  # 查询
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(2)
            text = self.driver.find_element(By.XPATH,
                                            '//div[@class!="el-table__fixed"]/div/table/tbody/tr/td[3]/div/span[text()="' + HIC信息单号 + '"]').text
            print(text)
            # 导出
            self.driver.find_element(By.XPATH,
                                     '//div[@id="clientSatList"]/div/form/div[2]/div/div[2]/button/span').click()
            time.sleep(2)
            assert text == HIC信息单号
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"客户满意度")]/i').click()

    # 电商督办
    @pytest.mark.run(order=12)
    @allure.title("电商督办")
    @pytest.mark.parametrize('信息单号,开始天,结束天', [("YT02407120020689", "2024-07-05", "2024-07-12")])
    def test_电商督办(self, 信息单号, 开始天, 结束天):
        self.driver.find_element(By.XPATH, '//ul/li[text()="电商督办"]').click()
        try:
            time.sleep(2)
            self.driver.find_element(By.XPATH, '//label[text()="信息单号:"]/following-sibling::div/div/input').send_keys(
                信息单号)
            time.sleep(1)
            # 时间框
            self.driver.find_element(By.XPATH, '//label[text()="录入时间:"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').send_keys(
                开始天)
            time.sleep(1)
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].clear()
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].send_keys(结束天)
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div[@class="el-picker-panel__footer"]/button[2]/span').click()

            time.sleep(1)  # 查询
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(2)  # 详情页
            self.driver.find_element(By.XPATH,
                                     '//div[@class!="el-table__fixed"]/div/table/tbody/tr/td/div/span/button/span[text()="详情"]').click()
            time.sleep(2)
            text = self.driver.find_element(By.XPATH,
                                            '//th[contains(text(),"信息单号:")]/following-sibling::td/span').text
            print(text)
            # 进入详情页
            assert text == 信息单号
            # 关闭
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/button[@aria-label="Close"]/i').click()
        finally:
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"电商督办")]/i').click()

    # 电商邀评
    @pytest.mark.run(order=13)
    @allure.title("电商邀评")
    @pytest.mark.parametrize('订单编号,开始天,结束天', [("3949535376648537739", "2024-07-05", "2024-07-13")])
    def test_电商邀评(self, 订单编号, 开始天, 结束天):
        self.driver.find_element(By.XPATH, '//ul/li[text()="电商邀评"]').click()
        try:
            time.sleep(2)
            self.driver.find_element(By.XPATH, '//label[text()="订单编号:"]/following-sibling::div/div/input').send_keys(
                订单编号)
            time.sleep(1)
            # 时间框
            self.driver.find_element(By.XPATH,
                                     '//i[@class="el-input__icon el-range__close-icon"]').click()
            self.driver.find_element(By.XPATH, '//label[text()="邀评新增时间:"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//label[text()="邀评新增时间:"]/following-sibling::div/div/input').send_keys(
                开始天)
            self.driver.find_elements(By.XPATH,
                                      '//label[text()="邀评新增时间:"]/following-sibling::div/div/input')[
                1].send_keys(结束天)
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            # 导出
            self.driver.find_element(By.XPATH,
                                     '//span[text()="评价导入"]/parent::button/parent::div/following-sibling::div/button/span').click()
            time.sleep(2)
            # 进入详情页
            self.driver.find_element(By.XPATH,
                                     '//div[@class!="el-table__fixed"]/div/table/tbody/tr/td/div/span/button/span[text()="闭环"]').click()
            time.sleep(2)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="reviewUserInfo"]/div[1]/div[2]/table/tbody[1]/tr/td[1]/div/input').get_attribute(
                'value')
            # 判断值是否正确
            assert text == 订单编号
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"邀评客户信息")]/i').click()
        finally:
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"电商邀评")]/i').click()

    # 工贸督办
    @pytest.mark.run(order=14)
    @allure.title("工贸督办")
    @pytest.mark.parametrize('信息单号,开始天,结束天', [("JN02407120022700", "2024-07-05", "2024-07-13")])
    def test_工贸督办(self, 信息单号, 开始天, 结束天):
        self.driver.find_element(By.XPATH, '//ul/li[text()="工贸督办"]').click()
        try:
            time.sleep(2)
            self.driver.find_element(By.XPATH, '//label[text()="信息单号:"]/following-sibling::div/div/input').send_keys(
                信息单号)
            time.sleep(1)
            # 时间框
            self.driver.find_element(By.XPATH, '//label[text()="入库时间:"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').send_keys(
                开始天)
            time.sleep(1)
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].clear()
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].send_keys(结束天)
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div[@class="el-picker-panel__footer"]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()

            time.sleep(2)
            # 进入详情页
            self.driver.find_element(By.XPATH,
                                     '//div[@class!="el-table__fixed"]/div/table/tbody/tr/td/div/span/button/span[text()="查看详情"]').click()
            time.sleep(2)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="industrySuperviseDetail"]/div[1]/div[2]/table/tbody[2]/tr/td[3]/div/input').get_attribute(
                'value')
            # 判断值是否正确
            assert text == 信息单号
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"督办详情")]/i').click()
        finally:
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"工贸督办")]/i').click()

    # 抱怨信息督办库
    @pytest.mark.run(order=15)
    @allure.title("抱怨信息督办库")
    @pytest.mark.parametrize('信息单号,开始天,结束天', [("JH02407120022611", "2024-07-05", "2024-07-13")])
    def test_抱怨信息督办库(self, 信息单号, 开始天, 结束天, web_start):
        self.driver.find_element(By.XPATH, '//ul/li[text()="抱怨信息督办库"]').click()
        try:
            time.sleep(2)
            self.driver.find_element(By.XPATH, '//label[text()="信息单号:"]/following-sibling::div/div/input').clear()
            self.driver.find_element(By.XPATH, '//label[text()="信息单号:"]/following-sibling::div/div/input').send_keys(
                信息单号)
            time.sleep(1)
            # 时间框
            self.driver.find_element(By.XPATH, '//label[text()="录单时间(起):"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div[@class="el-picker-panel__body"]/div[1]/span[1]/div/input').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div[@class="el-picker-panel__body"]/div[1]/span[1]/div/input').send_keys(
                开始天)
            time.sleep(2)
            # 时间框-确定
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]//div[2]/button[2]/span').click()
            # 时间框
            self.driver.find_element(By.XPATH, '//label[text()="录单时间(止):"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div[@class="el-picker-panel__body"]/div[1]/span[1]/div/input').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div[@class="el-picker-panel__body"]/div[1]/span[1]/div/input').send_keys(
                结束天)
            time.sleep(1)
            # 时间框-确定
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]//div[2]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()

            time.sleep(1)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="complainInfoDatabase"]/div[2]/div[1]/div[3]//tr/td[3]').text
            assert text == 信息单号
        finally:
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"抱怨信息督办库")]/i').click()

    # 小海跳闸审核查询
    @pytest.mark.run(order=16)
    @allure.title("小海跳闸审核查询")
    @pytest.mark.parametrize('信息单号,开始天,结束天', [("DL02407120002842", "2024-07-05", "2024-07-13")])
    def test_小海跳闸审核查询(self, 信息单号, 开始天, 结束天, web_start):
        self.driver.find_element(By.XPATH, '//ul/li[text()="小海跳闸审核查询"]').click()
        try:
            time.sleep(2)
            self.driver.find_element(By.XPATH, '//label[text()="信息单号:"]/following-sibling::div/div/input').clear()
            self.driver.find_element(By.XPATH, '//label[text()="信息单号:"]/following-sibling::div/div/input').send_keys(
                信息单号)
            time.sleep(1)
            # 时间框
            self.driver.find_element(By.XPATH, '//label[text()="登记开始时间:"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div[@class="el-picker-panel__body"]/div[1]/span[1]/div/input').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div[@class="el-picker-panel__body"]/div[1]/span[1]/div/input').send_keys(
                开始天)
            time.sleep(1)
            # 时间框-确定
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]//div[2]/button[2]/span').click()
            time.sleep(1)
            # 时间框
            self.driver.find_element(By.XPATH, '//label[text()="登记结束时间:"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div[@class="el-picker-panel__body"]/div[1]/span[1]/div/input').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div[@class="el-picker-panel__body"]/div[1]/span[1]/div/input').send_keys(
                结束天)
            time.sleep(1)
            # 时间框-确定
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]//div[2]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()

            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//*[@id="tripList"]/div[2]/div[1]/div[3]/table/tbody/tr/td[2]/div/span/button').click()
            time.sleep(2)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="tripDetail"]/div[1]/div[2]/table/tbody[1]/tr/td[1]/div/input').get_attribute(
                'value')
            # 判断值是否正确
            assert text == 信息单号
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"小海跳闸审核查询详情")]/i').click()
            time.sleep(1)
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"小海跳闸审核查询")]/i').click()

    # 舆情工单处理
    @pytest.mark.run(order=17)
    @allure.title("舆情工单处理")
    @pytest.mark.parametrize('舆情工单号,开始天,结束天', [("202407120115", "2024-07-05", "2024-07-13")])
    def test_舆情工单处理(self, 舆情工单号, 开始天, 结束天):
        self.driver.find_element(By.XPATH, '//ul/li[text()="舆情工单处理"]').click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"高级查询")]').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//label[text()="舆情工单号:"]/following-sibling::div/div/input').send_keys(
                舆情工单号)
            time.sleep(1)
            # 创建时间
            self.driver.find_element(By.XPATH, '//label[text()="创建时间:"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').send_keys(
                开始天)
            time.sleep(1)
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].clear()
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].send_keys(结束天)
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div[@class="el-picker-panel__footer"]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)
            # 鼠标-滑动到浏览器底部
            self.driver.execute_script("window.scrollTo(0, document.body.clientHeight)")
            # 详情
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//*[@id="industrySupervise"]/div[2]/div[1]/div[3]/table/tbody/tr/td[2]/div/span/button[1]/span').click()
            time.sleep(2)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="industrySupervise"]/div[3]/div/div[2]/div/div[1]/form/div[2]/div[1]/div/div').text
            # 判断值是否正确
            assert text == 舆情工单号

            # 关闭
            time.sleep(1)
            # 关闭
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/button[@aria-label="Close"]/i').click()
            time.sleep(1)
        finally:
            self.driver.execute_script("window.scrollTo(0, 0)")
            self.driver.find_element(By.XPATH, '//span[contains(text(),"舆情工单处理")]/i').click()

lemut_yywh_test.py

# -*- coding: utf-8 -*-
"""
lemut_select - 运营维护, 30-44
话术维护 -弹窗要前端修改为:增加话术操作
Author: duxiaowei
Date: 2024/7/24
"""

import time
import allure
import pytest
from selenium.webdriver.common.by import By


# 运营维护
@pytest.mark.run(order=30)
@allure.feature("运营维护")
class Test_运营维护:

    @pytest.fixture(scope="function", autouse=True)
    def setup(self, web_start):
        self.driver = web_start
        time.sleep(1)
        self.driver.find_element(By.XPATH, '//div/span[text()="运营维护"]').click()
        time.sleep(2)
        yield
        time.sleep(1)
        # 关闭当前页签,打开-业务查询页签
        self.driver.find_element(By.XPATH, '//div/span[text()="运营维护"]').click()

    # 自动应答账号
    @pytest.mark.run(order=31)
    @allure.title("自动应答账号")
    def test_自动应答账号(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="自动应答账号"]').click()
        try:
            time.sleep(1)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="autoAnswerCode"]/div/div/div/table/tbody/tr[1]/td[2]/div/span').text
            time.sleep(1)
            assert text is not None or text != ""
        finally:
            # 关闭
            self.driver.find_element(By.XPATH, '//span[contains(text(),"自动应答账号")]/i').click()

    # 弹屏信息维护
    @pytest.mark.run(order=32)
    @allure.title("弹屏信息维护")
    def test_弹屏信息维护(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="弹屏信息维护"]').click()
        try:
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(2)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="getMessageList"]/div/div/div/div/table/tbody/tr[1]/td[2]/div/span').text
            # 判断有数据
            assert int(text) == 1
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//*[@id="getMessageList"]/div/form/div/div/div[2]/button[2]/span').click()
            time.sleep(2)
            self.driver.find_element(By.XPATH,
                                     '//span[text()="新增弹屏信息"]/following-sibling::button/i').click()
        finally:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"弹屏信息维护")]/i').click()

    # 话术维护
    @pytest.mark.run(order=33)
    @allure.title("话术维护")
    def test_话术维护(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="话术维护"]').click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//label[text()="话术类型:"]/following-sibling::div/div/div/span/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//ul/li/span[text()="过渡语"]').click()
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)
            assert self.driver.find_element(By.XPATH,
                                            '//*[@id="classList"]/div/div/div/table/tbody/tr[1]/td[5]/div/span').text == "过渡语"

            self.driver.find_element(By.XPATH,
                                     '//*[@id="classList"]/div/form/div[2]/div/div[2]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//span[text()="增加话术操作"]/following-sibling::button/i').click()
        finally:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"话术维护")]/i').click()

    # 话术类型维护
    @pytest.mark.run(order=34)
    @allure.title("话术类型维护")
    def test_话术类型维护(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="话术类型维护"]').click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//label[text()="渠道类型:"]/following-sibling::div/div/div/span/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//ul/li/span[text()="微信/易信"]').click()
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)
            # 判断有数据
            assert self.driver.find_element(By.XPATH,
                                            '//*[@id="classList"]/div/div/div/table/tbody/tr[1]/td[3]/div/span').text == "微信/易信"

            self.driver.find_element(By.XPATH,
                                     '//*[@id="classList"]/div/form/div[2]/div/div[2]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//span[text()="增加话术类型操作"]/following-sibling::button/i').click()
        finally:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"话术类型维护")]/i').click()

    # 安装机器人信息采集
    @pytest.mark.run(order=35)
    @allure.title("安装机器人信息采集")
    def test_安装机器人信息采集(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="安装机器人信息采集"]').click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(2)
            # 判断有数据
            textTotal = self.driver.find_element(By.XPATH,'//*[@id="kdxfTelList"]/div[2]/div[2]/span[1]').text
            count = textTotal.split(" ")[1]

            assert int(count) > 0
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"安装机器人信息采集")]/i').click()

    # 智能IVR报表
    @pytest.mark.run(order=36)
    @allure.title("智能IVR报表")
    def test_智能IVR报表(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="智能IVR报表"]').click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="telRecordQuery"]/div/div/div/div/table/tbody/tr[1]/td[1]/div/span').text
            # 判断有数据
            assert int(text) == 1
        finally:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"智能IVR报表")]/i').click()

    # 分机管理
    @pytest.mark.run(order=37)
    @allure.title("分机管理")
    def test_分机管理(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="分机管理"]').click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="commerceExtension"]/div/div/div/div/table/tbody/tr[1]/td[2]/div/span').text
            # 判断有数据
            assert int(text) == 1
            self.driver.find_element(By.XPATH,
                                     '//*[@id="commerceExtension"]/div/form/div[2]/div/div[2]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//span[text()="分机号绑定"]/following-sibling::button/i').click()
            time.sleep(1)
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"分机管理")]/i').click()

    # 关键字检索维护
    @pytest.mark.run(order=38)
    @allure.title("关键字检索维护")
    def test_关键字检索维护(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="关键字检索维护"]').click()
        try:
            time.sleep(1)

            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="keyWordsManage"]/div/div/div/div/table/tbody/tr[1]/td[2]/div/span').text
            # 判断有数据
            assert int(text) == 1
            self.driver.find_element(By.XPATH,
                                     '//*[@id="keyWordsManage"]/div/form/div[2]/div/div[2]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//span[text()="新增关键字信息"]/following-sibling::button/i').click()
            time.sleep(1)
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"关键字检索维护")]/i').click()

    # 直接派单弹屏维护
    @pytest.mark.run(order=39)
    @allure.title("直接派单弹屏维护")
    def test_直接派单弹屏维护(self):
        time.sleep(1)
        直接派单弹屏维护 = self.driver.find_element(By.XPATH, '//ul/li[text()="直接派单弹屏维护"]')
        # 滚动到元素使其可见
        self.driver.execute_script("arguments[0].scrollIntoView(true);", 直接派单弹屏维护)
        time.sleep(1)
        直接派单弹屏维护.click()

        try:
            time.sleep(1)

            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="faultTreeMessage"]/div/div/div/div/table/tbody/tr[1]/td[2]/div/span').text
            # 判断有数据
            assert int(text) == 1
            self.driver.find_element(By.XPATH,
                                     '//*[@id="faultTreeMessage"]/div/form/div[2]/div/div[2]/button[2]/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//span[text()="新增故障树弹屏信息"]/following-sibling::button/i').click()
            time.sleep(1)
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"直接派单弹屏维护")]/i').click()

    # 产品大类维护
    @pytest.mark.run(order=40)
    @allure.title("产品大类维护")
    def test_产品大类维护(self):
        time.sleep(1)
        产品大类维护 = self.driver.find_element(By.XPATH, '//ul/li[text()="产品大类维护"]')
        # 滚动到元素使其可见
        self.driver.execute_script("arguments[0].scrollIntoView(true);", 产品大类维护)
        time.sleep(1)
        产品大类维护.click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="proKindMainten"]/div/div/div/div/table/tbody/tr[1]/td[1]/div/span').text
            # 判断有数据
            assert int(text) == 1
        finally:
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"产品大类维护")]/i').click()

    # 代报管理
    @pytest.mark.run(order=41)
    @allure.title("代报管理")
    def test_代报管理(self):
        time.sleep(1)
        代报管理 = self.driver.find_element(By.XPATH, '//ul/li[text()="代报管理"]')
        # 滚动到元素使其可见
        self.driver.execute_script("arguments[0].scrollIntoView(true);", 代报管理)
        time.sleep(1)
        代报管理.click()
        time.sleep(1)
        try:
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="autoAnswerCode"]/div/div/div/div/table/tbody/tr[1]/td[1]/div/span').text
            # 判断有数据
            assert int(text) == 1
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//*[@id="autoAnswerCode"]/div/form/div[2]/div/div[2]/button[2]').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//span[text()="新增"]/following-sibling::button/i').click()
            time.sleep(1)

        finally:
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"代报管理")]/i').click()

    # 短信发送记录查询
    @pytest.mark.run(order=42)
    @allure.title("短信发送记录查询")
    @pytest.mark.parametrize('手机号,开始天,结束天', [("17664080420", "2024-07-11", "2024-07-13")])
    def test_短信发送记录查询(self, 手机号, 开始天, 结束天):
        time.sleep(1)
        短信发送记录查询 = self.driver.find_element(By.XPATH, '//ul/li[text()="短信发送记录查询"]')
        # 滚动到元素使其可见
        self.driver.execute_script("arguments[0].scrollIntoView(true);", 短信发送记录查询)
        time.sleep(1)
        短信发送记录查询.click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="客服专项"]').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//label[text()="手机号:"]/following-sibling::div/div/input[not(@id)]').send_keys(手机号)
            time.sleep(1)
            # 时间框
            self.driver.find_element(By.XPATH, '//label[text()="发送时间:"]/following-sibling::div/div/input').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').clear()
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]').send_keys(
                开始天)
            time.sleep(1)
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].clear()
            self.driver.find_elements(By.XPATH,
                                      '//div[not(contains(@style,"display"))]/div/div/div/span/span/div/input[@class="el-input__inner"]')[
                2].send_keys(结束天)
            self.driver.find_element(By.XPATH,
                                     '//div[not(contains(@style,"display"))]/div[@class="el-picker-panel__footer"]/button[2]/span').click()
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)

            tds = self.driver.find_elements(By.XPATH,
                                            '//*[@id="duibeiMessage"]/div/div/div/table/tbody/tr/td[5]/div/span')
            # 判断有一个td的内容:推送智能报单链接
            assert any(lambda td: td.text == "推送智能报单链接" for td in tds)
        finally:
            # 关闭
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[contains(text(),"短信发送记录查询")]/i').click()

    # 字典项维护
    @pytest.mark.run(order=43)
    @allure.title("字典项维护")
    def test_字典项维护(self):
        time.sleep(1)
        字典项维护 = self.driver.find_element(By.XPATH, '//ul/li[text()="字典项维护"]')
        # 滚动到元素使其可见
        self.driver.execute_script("arguments[0].scrollIntoView(true);", 字典项维护)
        time.sleep(1)
        字典项维护.click()
        try:
            time.sleep(1)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="tableWithNoPagnation"]/div/div/table/tbody/tr[1]/td[1]/div/span').text
            # 判断有数据
            assert int(text) == 1
            time.sleep(1)
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"字典项维护")]/i').click()

    # 老用户复购指引维护
    @pytest.mark.run(order=44)
    @allure.title("老用户复购指引维护")
    def test_老用户复购指引维护(self):
        time.sleep(1)
        老用户复购指引维护 = self.driver.find_element(By.XPATH, '//ul/li[text()="老用户复购指引维护"]')
        # 滚动到元素使其可见
        self.driver.execute_script("arguments[0].scrollIntoView(true);", 老用户复购指引维护)
        time.sleep(1)
        老用户复购指引维护.click()
        try:
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//span[text()="查询"]').click()
            time.sleep(1)
            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="rebuy-guide"]/div/div/div/div/table/tbody/tr[1]/td[1]/div/span').text
            # 判断有数据
            assert int(text) == 1
        finally:
            time.sleep(1)

            self.driver.find_element(By.XPATH, '//span[contains(text(),"老用户复购指引维护")]/i').click()

知识库_test.py

# -*- coding: utf-8 -*-
"""
知识库 - 
Author: duxiaowei
Date: 2024/7/30
"""

import time
import allure
import pytest
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains  # 鼠标右键操作模拟

# 业务受理
@allure.feature("业务受理-知识库")
@pytest.mark.run(order=100)
class Test_业务受理:

    @pytest.fixture(scope="function", autouse=True)
    def setup(self, web_start):
        self.driver = web_start
        time.sleep(1)
        self.driver.find_element(By.XPATH, '//div/span[text()="业务受理"]').click()
        time.sleep(2)
        yield
        time.sleep(1)
        # 关闭当前页签,打开-业务查询页签
        self.driver.find_element(By.XPATH, '//div/span[text()="业务受理"]').click()

    # 产品中心,跳转
    @pytest.mark.run(order=101)
    @allure.title("知识库-产品卡片-三包法卡片跳转")
    def test_产品中心_三包法(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 产品卡片跳转
            # 悬停 按钮,等2秒
            labelIcon = self.driver.find_element(By.XPATH, '//*[@id="rightNav"]')
            labelIcon.click()
            ActionChains(self.driver).move_to_element(labelIcon).perform()
            time.sleep(1)
            # 点击-产品中心
            self.driver.find_element(By.XPATH, '//li/div[@class="orderTitle" and text()="产品中心"]').click()
            time.sleep(3)
            # 获取所有句柄
            handles1 = self.driver.window_handles
            self.driver.switch_to.window(handles1[1])
            # 产品卡片跳转,判断
            time.sleep(1)
            assert self.driver.find_element(By.XPATH, '//li[@role="menuitem" and text()="产品中心"]').text == "产品中心"
            self.driver.close()

            # 切换回,主页面
            self.driver.switch_to.window(handles1[0])

            # 三包法
            # 悬停 按钮,等2秒
            labelIcon = self.driver.find_element(By.XPATH, '//*[@id="rightNav"]')
            labelIcon.click()
            ActionChains(self.driver).move_to_element(labelIcon).perform()
            time.sleep(1)
            # 点击-三包法
            self.driver.find_element(By.XPATH, '//li/div[@class="orderTitle" and text()="三包法"]').click()
            time.sleep(2)
            # 获取所有句柄
            handles2 = self.driver.window_handles
            self.driver.switch_to.window(handles2[1])
            # 产品卡片跳转,判断
            time.sleep(2)
            assert self.driver.find_element(By.XPATH, '//span[text()="搜 索"]/parent::button/parent::div/preceding-sibling::input').get_attribute("value") == "三包"
            self.driver.close()

        finally:
            self.driver.switch_to.window(handles2[0])
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()

    # 智能推荐-产品大类,模糊查询验证
    @pytest.mark.run(order=102)
    @allure.title("智能推荐-产品大类")
    def test_产品大类(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 智能推荐
            self.driver.find_element(By.XPATH, '//*[@id="tab-intelligence"]').click()
            time.sleep(1)
            # 产品大类,输入
            self.driver.find_element(By.XPATH, '//span[text()="产品大类:"]/parent::div/parent::label/following-sibling::div/div/div/input').send_keys("冰箱")
            time.sleep(1)
            # 点击放大镜
            self.driver.find_element(By.XPATH,'//i[@class="el-icon-search pGlass pointer"]').click()
            time.sleep(1)
            # 点击,冰箱,产品大类区分方法
            self.driver.find_element(By.XPATH,'//*[@id="pane-intelligence"]/div/div/div/div/div/div/div/ul').click()
            time.sleep(1)
            # 点击,统帅
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]/div/div[3]/div/div/span').click()
            time.sleep(1)
            # 点击,500L以下
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]//span[contains(text(),"500升以下")]').click()
            time.sleep(1)
            # 点击,统帅冰箱
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]//span[contains(text(),"统帅冰箱")]').click()
            input = self.driver.find_element(By.XPATH, '//*[@id="orderLogIn"]/div[1]/form/div[1]/div[1]/div/div/div/div/input').get_attribute("value")
            # 判断包含 ,统帅
            assert "统帅冰箱" in input

        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()

    # 智能推荐-产品大类,模糊查询验证
    @pytest.mark.run(order=103)
    @allure.title("sop退换机")
    def test_sop退换机(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 点击,维修
            self.driver.find_element(By.XPATH, '//*[@id="tab-1"]').click()
            time.sleep(1)
            产品大类 = self.driver.find_element(By.XPATH,
                                            '//span[text()="产品大类:"]/parent::div/parent::label/following-sibling::div/div/div/input')
            ActionChains(self.driver).move_to_element(产品大类).perform()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//i[@class="el-select__caret el-input__icon el-icon-circle-close"]').click()
            time.sleep(1)
            产品大类.send_keys("家用空调")
            # 选择 家用空调
            self.driver.find_element(By.XPATH, '//div/div/div/ul/li[17]/span[contains(text(),"家用空调")]').click()
            time.sleep(1)

            服务类型 = self.driver.find_element(By.XPATH, '//span[text()="服务类型:"]/parent::div/parent::label/following-sibling::div/div/div/input')
            # 鼠标悬停后,出现x,点击删除框中内容
            ActionChains(self.driver).move_to_element(服务类型).perform()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//i[@class="el-select__caret el-input__icon el-icon-circle-close"]').click()
            服务类型.send_keys("退机")
            # 选择 退机
            self.driver.find_element(By.XPATH, '//div/div/div/ul/li[11]/span[contains(text(),"退机")]').click()
            time.sleep(3)
            # sop 推荐内容
            sop_text = self.driver.find_element(By.XPATH,'//*[@id="pane-intelligence"]/div/div/div/div/div/div/div/ul/div[2]').text
            time.sleep(1)
            assert "退换机指引流程" in sop_text
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()

    # 文章推荐
    @pytest.mark.run(order=104)
    @allure.title("文章推荐")
    def test_文章推荐(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 点击,维修
            self.driver.find_element(By.XPATH, '//*[@id="tab-5"]').click()
            time.sleep(1)
            产品大类 = self.driver.find_element(By.XPATH,'//span[text()="产品大类:"]/parent::div/parent::label/following-sibling::div/div/div/input')
            ActionChains(self.driver).move_to_element(产品大类).perform()
            time.sleep(1)
            self.driver.find_element(By.XPATH,'//i[@class="el-select__caret el-input__icon el-icon-circle-close"]').click()
            time.sleep(1)
            产品大类.send_keys("商用空调")
            self.driver.find_element(By.XPATH,'//div/div/div/ul/li[16]/span[contains(text(),"商用空调")]').click()
            # 选择 故障初判
            self.driver.find_element(By.XPATH, '//span[text()="故障初判:"]/parent::div/parent::label/following-sibling::div/div/div/input').send_keys("安装")
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//div/div/div/ul/li/span[text()="安装"]').click()

            time.sleep(3)
            # 文章推荐
            text = self.driver.find_element(By.XPATH,'//*[@id="pane-intelligence"]/div/div/div/div[2]/div/div[2]/div').text
            self.driver.find_element(By.XPATH, '//*[@id="pane-intelligence"]/div/div/div/div[2]/div/div[2]/div/ul/li').click()

            # 获取所有句柄
            handles1 = self.driver.window_handles
            self.driver.switch_to.window(handles1[1])
            time.sleep(2)
            new_page_text = self.driver.find_element(By.XPATH, '//*[@id="fname"]/span').text
            assert new_page_text in text
            self.driver.close()
        finally:
            self.driver.switch_to.window(handles1[0])
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()

    # 安装指引类
    @pytest.mark.run(order=105)
    @allure.title("安装指引类")
    def test_安装指引(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 点击,安装
            self.driver.find_element(By.XPATH, '//*[@id="tab-2"]').click()
            time.sleep(1)
            产品大类 = self.driver.find_element(By.XPATH,'//span[text()="产品大类:"]/parent::div/parent::label/following-sibling::div/div/div/input')
            ActionChains(self.driver).move_to_element(产品大类).perform()
            time.sleep(1)
            self.driver.find_element(By.XPATH,'//i[@class="el-select__caret el-input__icon el-icon-circle-close"]').click()
            time.sleep(1)
            产品大类.send_keys("家用空调")
            self.driver.find_element(By.XPATH,'//div/div/div/ul/li/span[contains(text(),"家用空调")]').click()

            time.sleep(3)
            # 推荐
            self.driver.find_element(By.XPATH, '//*[@id="pane-intelligence"]/div//li[@class="sop-item"]/p').click()
            # 已到货
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]/div/div/span').click()
            # 首次安装
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]/div[2]/div[3]/div/div/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]/div[2]/div[5]/div/div[2]/div/div/span').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]/div[2]/div[5]/div/div[6]/div/div/span').click()
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]/div[2]/div[5]/div/div[10]/div/div/span').click() #
            textarea = self.driver.find_element(By.XPATH, '//*[@id="orderLogIn"]/div/form/div//textarea').get_attribute('value')
            assert "已提示收费" in textarea
        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()
    # Uhome燃气热水器
    @pytest.mark.run(order=106)
    @allure.title("Uhome燃气热水器")
    def test_Uhome燃气热水器(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 点击,维修
            self.driver.find_element(By.XPATH, '//*[@id="tab-1"]').click()
            time.sleep(1)
            产品大类 = self.driver.find_element(By.XPATH,'//span[text()="产品大类:"]/parent::div/parent::label/following-sibling::div/div/div/input')
            ActionChains(self.driver).move_to_element(产品大类).perform()
            time.sleep(1)
            self.driver.find_element(By.XPATH,'//i[@class="el-select__caret el-input__icon el-icon-circle-close"]').click()
            time.sleep(1)
            产品大类.send_keys("Uhome燃气热水器")
            self.driver.find_element(By.XPATH,'//div/div/div/ul/li/span[contains(text(),"Uhome燃气热水器")]').click()
            # 选择 故障初判
            self.driver.find_element(By.XPATH,
                                     '//span[text()="故障初判:"]/parent::div/parent::label/following-sibling::div/div/div/input').send_keys(
                "E2")
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//div/div/div/ul/li/span[contains(text(),"E2")]').click()
            self.driver.find_element(By.XPATH, '//label[text()="来显号码:"]/following-sibling::div/div/input').send_keys("18251962523")

            time.sleep(3)
            # # 点击,咨询完毕
            self.driver.find_element(By.XPATH, '//*[@id="pane-intelligence"]//table/tbody/tr/td[2]/div/button[1]/span').click()
            time.sleep(3)
            textarea = self.driver.find_element(By.XPATH, '//span[text()="用户反映:"]/parent::div/parent::label/following-sibling::div/div/textarea').get_attribute('value')
            assert "给用户发送指导视频,用户接受,咨询完毕" in textarea
            time.sleep(1)
            # 切换回维修
            self.driver.find_element(By.XPATH, '//*[@id="tab-1"]').click()
            time.sleep(2)
            # # 点击,维修派单
            self.driver.find_element(By.XPATH,'//*[@id="pane-intelligence"]//table/tbody/tr/td[2]/div/button[2]/span').click()
            time.sleep(3)
            textarea2 = self.driver.find_element(By.XPATH,
                                                '//span[text()="用户反映:"]/parent::div/parent::label/following-sibling::div/div/textarea').get_attribute(
                'value')
            # print(textarea2)
            assert "用户不接受,派单售后" in textarea2

        finally:
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()


    # Sop推荐场景
    @pytest.mark.run(order=107)
    @allure.title("Sop推荐场景")
    def test_Sop推荐场景(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 点击,维修
            self.driver.find_element(By.XPATH, '//*[@id="tab-1"]').click()
            time.sleep(1)
            产品大类 = self.driver.find_element(By.XPATH,'//span[text()="产品大类:"]/parent::div/parent::label/following-sibling::div/div/div/input')
            ActionChains(self.driver).move_to_element(产品大类).perform()
            time.sleep(1)
            self.driver.find_element(By.XPATH,'//i[@class="el-select__caret el-input__icon el-icon-circle-close"]').click()
            time.sleep(1)
            产品大类.send_keys("冰箱")
            self.driver.find_element(By.XPATH,'//div/div/div/ul/li/span[contains(text(),"冰箱")]').click()

            # 选择 故障初判
            self.driver.find_element(By.XPATH,
                                     '//span[text()="故障初判:"]/parent::div/parent::label/following-sibling::div/div/div/input').send_keys(
                "冰箱噪音大")
            time.sleep(1)
            self.driver.find_element(By.XPATH,'//div/div/div/ul/li/span[contains(text(),"冰箱噪音大")]').click()
            self.driver.find_element(By.XPATH, '//label[text()="来显号码:"]/following-sibling::div/div/input').clear()
            self.driver.find_element(By.XPATH, '//label[text()="来显号码:"]/following-sibling::div/div/input').send_keys("18251962523")
            time.sleep(3)
            # # 点击, 诊断书,冰箱噪音大
            self.driver.find_element(By.XPATH, '//*[@id="pane-intelligence"]//ul/div/div/li/p').click()
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//div[@class="btn-box"]/span[contains(text(),"咕噜声")]').click()
            time.sleep(1)
            # 点击, 咨询完毕
            self.driver.find_element(By.XPATH, '//*[@id="sopig"]/div[2]/button').click()
            time.sleep(3)
            textarea = self.driver.find_element(By.XPATH, '//label[text()="故障思路:"]/following-sibling::div/div/textarea').get_attribute('value')

            assert "就会形成一定的咕噜声,这是正常现象,请您放心使用" in textarea

        finally:
            # pass
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()

    # 产品信息推荐
    @pytest.mark.run(order=108)
    @allure.title("产品信息推荐")
    def test_产品信息推荐(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 点击,售后其他
            self.driver.find_element(By.XPATH, '//*[@id="tab-5"]').click()
            time.sleep(1)
            产品大类 = self.driver.find_element(By.XPATH,
                                            '//span[text()="产品大类:"]/parent::div/parent::label/following-sibling::div/div/div/input')
            ActionChains(self.driver).move_to_element(产品大类).perform()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//i[@class="el-select__caret el-input__icon el-icon-circle-close"]').click()
            time.sleep(1)
            产品大类.send_keys("冰箱")
            self.driver.find_element(By.XPATH, '//div/div/div/ul/li/span[contains(text(),"冰箱")]').click()

            # 产品型号
            self.driver.find_element(By.XPATH,
                                     '//span[text()="产品型号:"]/parent::div/parent::label/following-sibling::div/div/div/input').send_keys(
                "BCD-218C ZB")
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//div/ul/li[contains(text(),"BCD-218C ZB")]').click()

            time.sleep(3)

            text = self.driver.find_element(By.XPATH,
                                            '//*[@id="pane-intelligence"]//div[@class="smartRecomm-container"]//div[@role="button"]').text
            assert "BCD-218C ZB" in text



        finally:
            # pass
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()
    # 问答推荐
    @pytest.mark.run(order=109)
    @allure.title("问答推荐")
    def test_问答推荐(self):
        self.driver.find_element(By.XPATH, '//ul/li[text()="服务受理"]').click()
        time.sleep(2)
        try:
            # 点击,售后其他
            self.driver.find_element(By.XPATH, '//*[@id="tab-5"]').click()
            time.sleep(1)
            产品大类 = self.driver.find_element(By.XPATH,
                                            '//span[text()="产品大类:"]/parent::div/parent::label/following-sibling::div/div/div/input')
            ActionChains(self.driver).move_to_element(产品大类).perform()
            time.sleep(1)
            self.driver.find_element(By.XPATH,
                                     '//i[@class="el-select__caret el-input__icon el-icon-circle-close"]').click()
            time.sleep(1)
            产品大类.send_keys("冰箱")
            self.driver.find_element(By.XPATH, '//div/div/div/ul/li/span[contains(text(),"冰箱")]').click()

            # 产品型号
            self.driver.find_element(By.XPATH,
                                     '//span[text()="产品型号:"]/parent::div/parent::label/following-sibling::div/div/div/input').send_keys(
                "BCD-218C ZB")
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//div/ul/li[contains(text(),"BCD-218C ZB")]').click()
            # 选择 故障初判
            self.driver.find_element(By.XPATH,
                                     '//span[text()="故障初判:"]/parent::div/parent::label/following-sibling::div/div/div/input').send_keys(
                "冰箱温度不会调节")
            time.sleep(1)
            self.driver.find_element(By.XPATH, '//div/div/div/ul/li/span[contains(text(),"冰箱温度不会调节")]').click()
            self.driver.find_element(By.XPATH, '//label[text()="来显号码:"]/following-sibling::div/div/input').clear()
            self.driver.find_element(By.XPATH,
                                     '//label[text()="来显号码:"]/following-sibling::div/div/input').send_keys(
                "18251962523")
            time.sleep(3)

            text = self.driver.find_element(By.XPATH,
                                                '//*[@id="pane-intelligence"]//div[@class="smartRecomm-container"]//div[@role="button"]').text
            assert "BCD-218C ZB" in text



        finally:
            # pass
            self.driver.find_element(By.XPATH, '//span[contains(text(),"服务受理")]/i').click()


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1989759.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Django—模板继承和包含

模块的继承意义:将需要多次用到的内容(盒子)进行引用,减少代码的重复使用 如我们经常在网上看见的导航栏,页脚等 第一步:我们将继承模块写在一个html文件里面 第二步:创建一个html文件&#x…

【归并排序/快排/堆排序】912. 排序数组

力扣连接:. - 力扣(LeetCode) 归并排序 对左右子集合分别排序,然后合并两个有序数组 class Solution {int[] nums;public int[] sortArray(int[] nums) {this.nums nums;return sort(0, nums.length-1);}int[] sort(int st, i…

电机学前置知识

https://zhuanlan.zhihu.com/p/712393024 基本定律 全电流定律(安培环路定律) 在磁场中沿任意闭合回路磁场强度的线积分等于穿过该回路所有电流的代数和,即: ∮ H ⋅ d l ∮ J ⋅ d s \oint H \cdot dl \oint J \cdot ds ∮H…

Windows 11下RTX 4090深度学习及大模型微调环境安装指南

在安装深度学习及大模型微调环境时,经历了多次反复操作(如CUDA、cuDNN、PyTorch的安装与卸载)。为了避免走弯路,总结了以下步骤: 步骤 1:显卡驱动安装 首先在安装完Windows 11后,安装RTX 4090显…

C++——类模板经典案例——自定义通用数组类

案例:自定义数组类 需求: 1,对内置数据及自定义数据类型的数据存储 2,将数组中的数据存储到堆区 3,构造函数中可以存入数组的容量 4,提供对应的拷贝构造函数和运算符重载防止浅拷贝问题的发生 5&#xff0c…

户外上网黑科技|300~500元随身wifi测评推荐,华为vs格行vs中兴vs上赞,哪个好?

1.老牌国货,颜值担当——华为 设备价格:499元 套餐价格:99一个月 599一年 质保时间:1年 测评:网速大概在50~60M/S,华为是老牌国货了,设备上没有硬伤,家里连接多设备都没什么问…

小怡分享之Java中的异常

前言: 🌈✨之前小怡带大家认识了String类,今天小怡给大家分享Java中的异常。 1.异常的概念与体系结构 1.1 异常的概念 在日常开发中,绞尽脑汁将代码写的尽善尽美,在程序运行中,难免会出现一些奇奇怪怪…

Python学习(2):在单机机器学习,使用Dask实现鸢尾数据集 Iris 的分类任务

目录 一、源码来源 二、鸢尾花数据集的品种分类 1、数据处理步骤 (1)数据集加载 (2)准备特征和标签 (3)训练集和测试集划分 2、安装必需的软件包 3、运行程序 三、信用卡欺诈数据集检测信用卡交易…

全网最详细的LVS实战详解

一、Lvs-nat实战部署 1、准备 设置好网卡信息 2、基础环境搭建详情 ①调度器LVS:网卡ens160(NAT模式)、网卡ens224(仅主机模式),使其可处于不同的VLAN段 为网卡ens160设置IP vmset.sh ens160 172.25.254.100 lvs.zf.org为网卡ens224设置IP vmset.sh ens224 192.…

在MAC安装Lazarus 起点 - 我们的第一个Lazarus程序!

安装Lazarus 首先到Lazarus官网,找到合适的版本下载页面,比如Mac的版本: https://sourceforge.net/projects/lazarus/files/Lazarus%20macOS%20x86-64/Lazarus%203.4/ 将三个文件都下载到本地,需要安装这三个文件: …

Python学习(1):使用Python的Dask库实现并行计算

目录 一、Dask介绍 二、使用说明 安装 三、测试 1、单个文件中实现功能 2、运行多个可执行文件 最近在写并行计算相关部分,用到了python的Dask库。 Dask官网:Dask | Scale the Python tools you love 一、Dask介绍 Dask是一个灵活的并行和分布式…

C语言 ——— 学习并使用字符分类函数

目录 学习isupper函数 学习isdigit函数 学习tolower函数 将输入的字符串中把大写字母转换为小写字母并输出 学习isupper函数 参数部分: 形参需要传递的是一个字母,字符在ASCII码表上是以整型存储的,所以实参部分用(int c)没有问题 返回…

HarmonyOS笔记3:从网络数据接口API获取数据

面向HarmonyOS的移动应用一般采用MVVM模式(见参考文献【1】),其中: M(Model层):模型层,存储数据和相关逻辑的模型。它表示组件或其他相关业务逻辑之间传输的数据。Model是对原始数据的进一步处理…

享界S9别乱选,定价有大玄机!

文 | AUTO芯球 作者 | 雷慢 享界S9刚上市, 就有人傻钱多、工作忙的老大哥来问我, 两个版本怎么选? 这不巧了吗,论华为车系,我是资深用户, 常开问界M9,试过智界S7,问界M7&#x…

PUA自己到无法自拔,或许是你过度信奉【优绩主义】

本文算是人文社科心理篇的第二期,不时发一些【理性】的【鸡汤】,或许对你认识社会本质有所帮助~ 一.定义 顾名思义,从理科生的角度来说,【优绩主义】以优秀的成绩作为评判人生是否成功的极大型指标,在东亚的【休息羞…

性能优化之自定义指令实现图片懒加载

1)图片懒加载 是常见的用于在页面滚动时动态加载图片,而不是在页面加载时一次性加载所有图片。性能优化必备提高页面加载速度的手段,特别是在包含大量图片的网站上。 图片懒加载的原理,其实就是,当图片出现在视口内时…

数据分析:宏基因组的荟萃分析之MMUPHin

禁止商业或二改转载,仅供自学使用,侵权必究,如需截取部分内容请后台联系作者! 介绍 批次效应是实验中由于样本处理和测序技术变异引起的非生物学差异,可能干扰研究结果。这种效应难以完全消除,但可通过方法如PCA、PC…

【Vue3】Pinia getters

【Vue3】Pinia getters 背景简介开发环境开发步骤及源码 背景 随着年龄的增长,很多曾经烂熟于心的技术原理已被岁月摩擦得愈发模糊起来,技术出身的人总是很难放下一些执念,遂将这些知识整理成文,以纪念曾经努力学习奋斗的日子。本…

求职leetcode题目(6)

1.简化路径 解题思路: 根据题意,使用栈进行模拟即可。 具体的,从前往后处理 path,每次以 item 为单位进行处理(有效的文件名),根据 item 为何值进行分情况讨论: item 为有效值 :存…

AQS框架

文章目录 概要AQS概述公平锁与非公平锁原理可重入 概要 假设现在需要写一个SDK层面的锁,应该如何实现呢? 初步的思路如下: 搞一个状态标记,用来表示持有或未持有锁,但得是 volatile 类型的保证线程可见性。编写一个 …