首页 > 其他分享 >论坛系统测试报告

论坛系统测试报告

时间:2024-10-30 20:17:03浏览次数:7  
标签:测试报告 系统 self driver element 论坛 SELECTOR find CSS

一、项目介绍

为“论坛系统”项目设计并实施自动化测试,自动化测试是通过Selenium编写的自动化脚本,覆盖了用户登录、用户注册等核心功能模块,确保该项目各个模块功能的稳定,使用户有流畅的论坛浏览和使用体验。

策略:对论坛进行,功能测试,界面测试,易用性测试,安全测试,性能测试,兼容性测试,并使用selenium编写自动化测试脚本进行自动化测试。

二、测试计划

2.1 测试用例

2.2 执行测试用例

1.登录界面功能

测试场景一:输入正确用户名和密码点击登录


预期结果:登录成功,直接跳转到论坛首页

实际结果:成功跳转到论坛首页

测试场景二:输入错误的用户名和密码 


预期结果:系统弹窗提示用户名或密码错误 

实际结果:系统提升用户名或密码错误

测场景三:输入用户名但不输入密码


预期结果:密码框下面提示密码不能为空

实际结果:密码框下方提示密码不能为空

测场景四:不输入用户名但输入密码


预期结果:用户名输入框提示用户名不能为空

实际结果:密码框下方提示密码不能为空

2.注册页面功能

测场景一:输入用户名,昵称,密码,点击同意条款进行注册


预期结果:注册成功跳转到登录页面可以正常登录跳转到论坛首页

实际结果:注册成功可以正常登录到论坛首页 

测试用例二:不输入用户名,但输入昵称,密码,同意条款进行注册


预期结果: 用户名输入框提示用户名不能为空

实际结果:用户名输入框提升用户名不能为空

测试用例三:输入用户名,但输入昵称,密码,不同意条款进行注册


预期结果:勾选条款位置变红,用来提示用户选择

实际结果:勾选条款位置变红

3.论坛首页功能 

测试用例一:点击论坛中的C++板块


预期结果:页面跳转到C++板块

实际结果论坛跳转到C++板块

测试用例二 :点击论坛首页的发布按钮


预期结果:点击发布按钮之后跳转到帖子编辑页面

实际结果:成功跳转到帖子编辑页面

测试用例三:点击首页的任意一个帖子


预期结果:跳转到帖子的详情页面

 

实际结果:成功跳转到帖子详情页面

测试用例四:输入一个正确的帖子标题进行搜索


预期结果:提示搜索结果,在搜索列表中显示搜索结果

实际结果:依然停留这首页,没有提示搜索是都成功,在搜索列表中没有显示搜索结果

BUG:搜索功能无效

测试用例五: 不输入一个帖子标题进行搜索


预期结果:系统提升请输入帖子标题

实际结果:没有任何提示,页面没有任何响应

BUG:搜索功能无效

4.帖子详情页

测试用例一:在帖子详情页对帖子进行回复


预期结果:系统提示回复成功,并在贴字回复列表中显示

实际结果:系统提示回复成功,并在贴字回复列表中显示

测试用例二:点击发私信按钮


预期结果:点击之后弹出编辑私信框

实际结果:点击之后弹出编辑私信框

测试用例三:在帖子详情页面对帖子进行点赞 


预期结果:系统提升点赞成功

实际结果:系统提示点赞成功

5.发布新帖子页面功能

测试用例一:选择模块,标题,和帖子内容进行发布


预期结果:系统提示发布成功跳转到论坛首页

实际结果:系统提示发布成功跳转到论坛首页

测试用例二:不输入新帖的标题进行发布


预期结果 :系统提示请输入帖子标题

实际结果:系统提示请输入帖子标题

 6.回复私信界面功能

测试用例一:点击回复私信按钮进行私信编写并发送


预期结果:系统提示发送成功

实际结果:系统提示发送成功 

测试用例二:不输入私信内容进行回复


预期结果:系统提示请输入要发送的内容

实际结果:系统提示请输入要发送的内容

7.我的贴子界面功能

测试用例一:在我的帖子界面点击自己发布的贴子进行查看


预期结果:成功进入帖子详情页面

实际结果:成功进入帖子详情页面

缺陷:(没有返回上页功能不方便返回)

 8.个人中心界面功能

测试用例一:输入正确的原密码:123

再输入新密码和确认密码:1234

进行密码修改用新的密码进行登录


预期结果:系统提示修改成功跳转到登录页面可以正常登录

实际结果:直接跳转到登录界面

缺陷:没有提示修改成功,在修改密码时无法点击查看密码

兼容性测试 

测试用例:分别在谷歌浏览器和Edge浏览器下进入论坛系统


预期结果:两个浏览器下进行系统并无不同

谷歌浏览器下:

Edge浏览器:

实际结果:两个浏览器下进行论坛系统并没有什么不同

 三、自动化测试

3.1 创建驱动类

import os.path
from datetime import datetime

import webdriver_manager.drivers.chrome
from requests import options
from selenium import webdriver
from selenium.webdriver.ie.service import Service
from webdriver_manager.chrome import ChromeDriverManager


#创建一个浏览器的对象因为要对多个页面进行测试不可能每个页面都创建一个浏览器的对象
class Driver:
    #定义构造函数
    #声明变量
    driver = ""
    def __init__(self):
        options = webdriver.ChromeOptions()
        self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options)
        self.driver.maximize_window()
    #创建屏幕截图方面
    def getscreenshot(self):
        #需要屏幕截图的保存到images文件中
        #保存的文件名为2024—10—28—时间.png
        diam = datetime.now().strftime("%Y-%m-%d")
        #判断保存图片的日期文件夹是否存在
        if not os.path.exists("../images/"+diam):
            #不存在就创建一个日期分类的文件夹
            os.mkdir("../images/"+diam)
        #设置图片的名称格式
        fliename = datetime.now().strftime("%Y-%m-%d-%H%M%S")+".png"
        self.driver.save_screenshot("../images/"+diam+"/"+fliename)

forum = Driver()

3.2 创建登录功能测试类

import time
from pickletools import long1
from time import sleep

from Tools.scripts.cleanfuture import dryrun
from selenium.webdriver.common.by import By

from common.com import forum, Driver


#登录页面的测试
class forumlogin:
    #创一个字符串用存储url
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://127.0.0.1:9580/sign-in.html"
        self.driver = forum.driver
        self.driver.get(self.url)

    #正常登录的测试用例
    def normalTest(self):
        #首先清除原本输入框的内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        #寻找用户名和密码输入框输入正确的用户名和密码
        self.driver.find_element(By.CSS_SELECTOR,"#username").send_keys("Test1")
        self.driver.find_element(By.CSS_SELECTOR,"#password").send_keys("1234")
        #点击登录按钮
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        time.sleep(2)
        #验证是否正常登录通过寻找论坛首页的中的用户名进行验证
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.dropdown > a > div")
        #首先最大化窗口进行屏幕截图
        self.driver.maximize_window()
        forum.getscreenshot()
        #因为需要测试异常登录所以就需要先让界面回到登录界面
        # self.driver.back()
        # time.sleep(3)
        # self.driver.quit()
    #异常登录
    def abnormalTest(self):
        #测试用例一:输入错误的用户名和错误的密码
        #首先清除原本输入框的内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        time.sleep(1)
        # 寻找用户名和密码输入框输入错误的的用户名和密码
        self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("Test11")
        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("123")
        time.sleep(1)
        #点击登录按钮
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        #首先最大化窗口进行屏幕截图
        self.driver.maximize_window()
        forum.getscreenshot()
        time.sleep(1)
        #输入错误的用户名和密码时会显示用户名或密码错误需要验证是否异常登录
        adim = self.driver.find_element(By.CSS_SELECTOR,"body > div.jq-toast-wrap.bottom-right > div > h2").text
        assert adim == "警告"
        time.sleep(1)
#############################################################
        #测试用例二:输入错误用户名和正确的密码
        #首先清除原本输入框的内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        time.sleep(1)
        # 寻找用户名和密码输入框
        self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("Test11")
        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("1234")
        time.sleep(1)
        #点击登录按钮
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        #首先最大化窗口进行屏幕截图
        self.driver.maximize_window()
        forum.getscreenshot()
        time.sleep(1)
        #输入错误的用户名和密码时会显示用户名或密码错误需要验证是否异常登录
        adim = self.driver.find_element(By.CSS_SELECTOR,"body > div.jq-toast-wrap.bottom-right > div > h2").text
        assert adim == "警告"
        time.sleep(1)
####################################################
        #测试用例三:输入正确的用户名和错误的密码
        #首先清除原本输入框的内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        time.sleep(1)
        # 寻找用户名和密码输入框
        self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("Test1")
        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("123")
        time.sleep(1)
        #点击登录按钮
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        #首先最大化窗口进行屏幕截图
        self.driver.maximize_window()
        forum.getscreenshot()
        time.sleep(1)
        #输入错误的用户名和密码时会显示用户名或密码错误需要验证是否异常登录
        adim = self.driver.find_element(By.CSS_SELECTOR,"body > div.jq-toast-wrap.bottom-right > div > h2").text
        assert adim == "警告"
        time.sleep(1)
####################################################
        # 测试用例四:不输入用户名但输入密码
        #首先清除原本输入框的内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        time.sleep(1)
        # 密码输入框

        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("123")
        time.sleep(1)
        #点击登录按钮
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        #首先最大化窗口进行屏幕截图
        self.driver.maximize_window()
        forum.getscreenshot()
        time.sleep(1)
        #输入错误的用户名和密码时会显示用户名或密码错误需要验证是否异常登录
        adim = self.driver.find_element(By.CSS_SELECTOR,"#signInForm > div.mb-3 > div").text
        assert adim == "用户名不能为空"
        time.sleep(1)
####################################################
        # 测试用例五:输入用户名但不输入密码
        # 首先清除原本输入框的内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        time.sleep(1)
        # 寻找用户名
        self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("Test1")

        time.sleep(1)
        #点击登录按钮
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        #首先最大化窗口进行屏幕截图
        self.driver.maximize_window()
        forum.getscreenshot()
        time.sleep(1)
        #输入错误的用户名和密码时会显示用户名或密码错误需要验证是否异常登录
        adim = self.driver.find_element(By.CSS_SELECTOR,"#signInForm > div.mb-2 > div > div").text
        assert adim == "密码不能为空"
        time.sleep(1)


#测试
login = forumlogin()
# login.abnormalTest()
login.normalTest()

3.3 创建注册功能测试类

import time
from distutils.command.check import check
from pickletools import long1
from time import sleep

from Tools.scripts.cleanfuture import dryrun
from selenium.webdriver.common.by import By

from common.com import forum, Driver
#注册页面的测试
class signUp:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://127.0.0.1:9580/sign-up.html"
        self.driver = forum.driver
        self.driver.get(self.url)
    #正常注册
    def snormal(self):
        #寻找输入框并清除内容
        self.driver.find_element(By.CSS_SELECTOR,"#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#nickname").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").clear()

        #进行输入
        self.driver.find_element(By.CSS_SELECTOR,"#username").send_keys("test222")
        self.driver.find_element(By.CSS_SELECTOR, "#nickname").send_keys("测试员")
        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("123")
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").send_keys("123")
        #同意条框点击注册
        time.sleep(1)
        self.driver.find_element(By.CSS_SELECTOR,"#policy").click()
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        time.sleep(1)
        #进行截图
        forum.getscreenshot()
        #验证登录成功后是否跳转到登录页面
        self.driver.find_element(By.CSS_SELECTOR,"body > div > div > div > div:nth-child(1) > div > div.card.card-md > div > h2")
    #异常注册
    def failsign(self):
        #测试用例一:不输入用户名,但输入昵称,密码,同意条款进行注册
        #寻找输入框并清除内容
        self.driver.find_element(By.CSS_SELECTOR,"#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#nickname").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").clear()
        #进行输入

        self.driver.find_element(By.CSS_SELECTOR, "#nickname").send_keys("测试员")
        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("123")
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").send_keys("123")
        #同意条框点击注册
        time.sleep(1)
        self.driver.find_element(By.CSS_SELECTOR,"#policy").click()
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        time.sleep(1)
        #进行截图
        forum.getscreenshot()
        #寻找用户名不能为空的提示内容验证测试结果
        self.driver.find_element(By.CSS_SELECTOR,"#signUpForm > div > div:nth-child(2) > div")
####################################################################
        #测试用例三:输入用户名,但输入昵称,密码,不同意条款进行注册
        # 寻找输入框并清除内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#nickname").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").clear()

        # 进行输入
        self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("test222")
        self.driver.find_element(By.CSS_SELECTOR, "#nickname").send_keys("测试员")
        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("123")
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").send_keys("123")
        time.sleep(1)
        checkbox = self.driver.find_element(By.CSS_SELECTOR, "#policy")
        if checkbox.is_selected():
            checkbox.click()
        self.driver.find_element(By.CSS_SELECTOR, "#submit").click()
        time.sleep(1)
        # 进行截图
        forum.getscreenshot()
        #检查是否还停用户注册界面来验证
        self.driver.find_element(By.CSS_SELECTOR,"#signUpForm > div > h2")
#####################################################################
        # 测试用例四:不输入昵称,输入用户名,密码,同意条款进行注册
        # 寻找输入框并清除内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#nickname").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").clear()

        # 进行输入
        self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("test222")

        self.driver.find_element(By.CSS_SELECTOR, "#password").send_keys("123")
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").send_keys("123")
        time.sleep(1)
        self.driver.find_element(By.CSS_SELECTOR,"#policy").click()
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        # 进行截图
        forum.getscreenshot()
        # 寻找昵称不能为空的提示内容验证测试结果
        self.driver.find_element(By.CSS_SELECTOR, "#signUpForm > div > div:nth-child(3) > div")

#####################################################################
        # 测试用例四:不输入密码,输入昵称,密码,同意条款进行注册
        # 寻找输入框并清除内容
        self.driver.find_element(By.CSS_SELECTOR, "#username").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#nickname").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#password").clear()
        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").clear()

        #进行输入
        self.driver.find_element(By.CSS_SELECTOR, "#username").send_keys("test222")
        self.driver.find_element(By.CSS_SELECTOR, "#nickname").send_keys("测试员")

        self.driver.find_element(By.CSS_SELECTOR, "#passwordRepeat").send_keys("123")

        #同意条框点击注册
        time.sleep(1)
        self.driver.find_element(By.CSS_SELECTOR,"#policy").click()
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        # 进行截图
        forum.getscreenshot()
        #寻找提示框验证登录
        self.driver.find_element(By.CSS_SELECTOR,"#signUpForm > div > div:nth-child(4) > div > div")




signUP = signUp()
# signUP.snormal()
signUP.failsign()

3.4 创建论坛首页功能测试类

import time
from distutils.command.check import check
from pickletools import long1
from time import sleep

from Tools.scripts.cleanfuture import dryrun
from selenium.webdriver.common.by import By

from common.com import forum, Driver
#论坛首页测试
class fpega:
    # url = ""
    driver = ""
    def __init__(self):
        # self.url = "http://127.0.0.1:9580/index.html"
        self.driver = forum.driver
        # self.driver.get(self.url)
    def fcheckelement(self):
        time.sleep(1)
        #进行元素查找

        self.driver.find_element(By.CSS_SELECTOR,"#artical-items-body > div:nth-child(1) > div > div.col > div.text-truncate > a > strong")
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_nickname")
        self.driver.find_element(By.CSS_SELECTOR, "#topBoardList > li:nth-child(2) > a")
        self.driver.find_element(By.CSS_SELECTOR, "#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post")
        self.driver.find_element(By.CSS_SELECTOR, "body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.d-none.d-md-flex.me-3 > div > form > div > input")
        #进行截图
        forum.getscreenshot()

fpega = fpega()
fpega.fcheckelement()

3.5 创建论坛帖子详情页功能测试类

import time
from distutils.command.check import check
from pickletools import long1
from time import sleep

from Tools.scripts.cleanfuture import dryrun
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By

from common.com import forum, Driver
#帖子详情页面的测试
class pContent:
    # url = ""
    driver = ""
    def __init__(self):
        # self.url = "http://127.0.0.1:9580/index.html"
        self.driver = forum.driver
        # self.driver.get(self.url)

    #检查页面元素
    def pCheck(self):
        #选择C++板块的帖子进行测试
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(3) > a").click()
        time.sleep(1)
        self.driver.find_element(By.CSS_SELECTOR,"#artical-items-body > div:nth-child(1) > div > div.col > div.text-truncate > a > strong").click()
        #帖子详情页面的元素进行查找
        #发布人
        self.driver.find_element(By.CSS_SELECTOR,"#article_details_author_name")
        #发布时间
        self.driver.find_element(By.CSS_SELECTOR,"#details_article_createTime")
        #帖子的标题
        self.driver.find_element(By.CSS_SELECTOR, "#details_article_title")
        time.sleep(1)
        #评论区列表
        text = self.driver.find_element(By.CSS_SELECTOR, "#details_article_reply_content_59").text
        print(text)

        #评论输入框
        self.driver.find_element(By.CSS_SELECTOR, "#article_details_reply > div.CodeMirror.cm-s-default.CodeMirror-wrap > div.CodeMirror-scroll > div.CodeMirror-sizer > div > div > div > div.CodeMirror-code > div.CodeMirror-activeline > pre")
        #评论发布按钮
        self.driver.find_element(By.CSS_SELECTOR, "#details_btn_article_reply")
        #点赞按钮
        self.driver.find_element(By.CSS_SELECTOR, "#details_btn_like_count")


    #功能测试
    def pFunTest(self):
        #测试用例一:编辑一个评论进行发布
        #发送一个评论看是否在列表中正常显示
        # #找到评论编辑框进行输入
        # self.driver.find_element(By.CSS_SELECTOR,"#article_details_reply > div.editormd-toolbar > div > ul > li:nth-child(12)").click()
        # #找到回复按钮点击进行回复
        # time.sleep(2)
        # self.driver.find_element(By.CSS_SELECTOR, "#details_btn_article_reply").click()

        #测试用例二:对帖子内容不进行编辑直接发布
        # 使用Actions链模拟点击
        time.sleep(1)
        element = self.driver.find_element(By.ID, "details_btn_article_reply")
        ActionChains(self.driver).move_to_element(element).click().perform()
        #查找提示框

        text1 = self.driver.find_element(By.CSS_SELECTOR, "body > div.jq-toast-wrap.bottom-right > div").text
        #打印验证
        print(text1)
        #进行截图验证
        forum.getscreenshot()

        #对点赞功能进行测试
        #寻找点赞按钮并点击
        time.sleep(1)
        element1 = self.driver.find_element(By.ID, "details_btn_like_count")
        ActionChains(self.driver).move_to_element(element1).click().perform()
        #检查提示框
        text2 = self.driver.find_element(By.CSS_SELECTOR,"body > div.jq-toast-wrap.bottom-right").text
        print(text2)

        time.sleep(1)
        # 进行截图验证
        forum.getscreenshot()


# pcontent = pContent()
# pcontent.pCheck()
# pcontent.pFunTest()

3.6 创建私信功能测试用例类

import time
from distutils.command.check import check
from pickletools import long1
from time import sleep

from Tools.scripts.cleanfuture import dryrun
from Tools.scripts.find_recursionlimit import test_init
from selenium.webdriver.common import alert
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By

from common.com import forum, Driver
#私信功能的测试
class prMe:
    url =""
    driver = ""
    def __init__(self):
        self.driver = forum.driver
        # self.url = "http://127.0.0.1:9580/index.html#"
        # self.driver.get(url=self.url)

    #进行私信发发送测试
    def prFunTest(self):
        #任意点击一个帖子给帖子的作者发私信
        self.driver.find_element(By.CSS_SELECTOR,"#artical-items-body > div:nth-child(1) > div > div.col > div.text-truncate > a").click()
        self.driver.find_element(By.CSS_SELECTOR,"#btn_details_send_message").click()
        time.sleep(2)
        #输入信息
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_receive_content").send_keys("111111111")
        time.sleep(1)
        #点击发送
        self.driver.find_element(By.CSS_SELECTOR,"#btn_index_send_message").click()

        time.sleep(2)


# prMe = prMe()
# prMe.prFunTest()

3.7 创建论坛新帖发布页面功能测试类

import time
from distutils.command.check import check
from pickletools import long1
from time import sleep, process_time_ns

from Tools.scripts.cleanfuture import dryrun
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By

from common.com import forum, Driver
#发布新帖页面的测试
class epega:
    driver = ""
    def __init__(self):
        self.driver = forum.driver

    #元素检查
    def eCheck(self):
        #返回首页
        self.driver.find_element(By.CSS_SELECTOR,"#nav_board_index > a").click()
        #点击发布帖子按钮
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post").click()
        #查找板块选择元素
        self.driver.find_element(By.CSS_SELECTOR, "#article_post_borad")
        #查找标题输入框
        self.driver.find_element(By.CSS_SELECTOR, "#article_post_title")
        #查找内容编辑框
        self.driver.find_element(By.CSS_SELECTOR, "#edit-article > div.CodeMirror.cm-s-default.CodeMirror-wrap.CodeMirror-empty > div.CodeMirror-scroll > div.CodeMirror-sizer > div > div > div > div.CodeMirror-code > div > pre")
        time.sleep(1)
        #寻找发布按钮
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_submit")
        time.sleep(2)

    #功能测试
    def eFuncTest(self):
        #测一:正常发布一篇帖子因为编辑框是外置的所以导致无法交互
        #默认发布Java板块
        # #找到标题输入框和内容编辑框进行编辑然后点击发布
        # self.driver.find_element(By.CSS_SELECTOR,"#article_post_title").send_keys("测试帖子1")
        # self.driver.find_element(By.CSS_SELECTOR,"#edit-article > div.CodeMirror.cm-s-default.CodeMirror-wrap.CodeMirror-empty > div.CodeMirror-scroll > div.CodeMirror-sizer > div").send_keys("自动化测试中")
        # time.sleep(2)
        # self.driver.find_element(By.CSS_SELECTOR,"#article_post_submit").click()
        # time.sleep(5)

        #测试二:不输入帖子的标题进行发布
        # 使用Actions链模拟点击
        time.sleep(1)
        element = self.driver.find_element(By.ID, "article_post_submit")
        ActionChains(self.driver).move_to_element(element).click().perform()

        #检查提示
        text1 = self.driver.find_element(By.CSS_SELECTOR,"body > div.jq-toast-wrap.bottom-right > div").text
        print(text1)
        #进行截图验证
        forum.getscreenshot()

        ############################
        #测三:输入标题但输入内容
        self.driver.find_element(By.CSS_SELECTOR, "#article_post_title").send_keys("测试帖子1")
        # 使用Actions链模拟点击
        time.sleep(1)
        element1 = self.driver.find_element(By.ID, "article_post_submit")
        ActionChains(self.driver).move_to_element(element1).click().perform()

        #查找提示
        text2 = self.driver.find_element(By.CSS_SELECTOR,"body > div.jq-toast-wrap.bottom-right").text
        #打印验证
        print(text2)
        #进行截图验证
        forum.getscreenshot()
        #刷新页面进行返回
        # 返回首页
        time.sleep(1)
        element2 = self.driver.find_element(By.CSS_SELECTOR, "#nav_board_index > a")
        ActionChains(self.driver).move_to_element(element2).click().perform()

        time.sleep(2)

# epega = epega()
# epega.eCheck()
# epega.eFuncTest()

3.8 创建启动文件

from Test import entryTest
from Test import firstPega
from Test import postContent
from Test import editPage
from Test import privates
if __name__ =="main":
    #首先测试登录失败
    entryTest.forumlogin().abnormalTest()
    #然后登录成功
    entryTest.forumlogin().normalTest()
    #进入首页进行测试
    firstPega.fpega().fcheckelement()
    #进入博客详情页测试
    postContent.pContent().pCheck()
    postContent.pContent().pFunTest()
    #进入博客编辑页面
    editPage.epega().eCheck()
    editPage.epega().eFuncTest()
    #进入私信页面
    privates.prMe().prFunTest()

四. 环境准备 

系统:windows11
浏览器:Chrome130.0.6723.59、Edge127.0.2651.74
测试工具:Selenium4.0.0 

五、项目Bug

5.1 Bug描述

浏览器:Chrome130.0.6723.59

搜索功能无法使用,点击无反应,按下回车键时屏幕之后闪一下

5.2 Bug描述

浏览器:Chrome130.0.6723.59

有些模块在首页没有显示,但在新帖发布页面有

 六、测试总结

本次测试对,登录,注册,编辑新帖等核心功能进行测试并用selenium编写自动化测试脚本。需要完善搜索功能,确保修改密码时新密码不能与原密码一致,完善首页的各模块分类,以便用户浏览,提高用户的使用体验。

标签:测试报告,系统,self,driver,element,论坛,SELECTOR,find,CSS
From: https://blog.csdn.net/weixin_58233541/article/details/143259252

相关文章