一、实验目的及要求
1. 熟悉使用Jmeter性能测试工具,能运用该工具执行简单的性能测试,并对结果进行分析。
2. 掌握Selenium录制并编写脚本、调试、维护测试用例、输出测试结果的方法。
3. 熟悉测试管理工具testLink的使用,能将测试过程通过该工具管理起来。
二、实验设备(环境)及要求
1.Windows系统配置JDK环境,下载Jmeter安装包;
2. Windows系统安装python以及Selenium以及Firefox浏览器;
三、实验内容
1、熟悉使用Jmeter性能测试工具,能运用该工具执行简单的性能测试,并对结果进行分析。
(1) 线程组设置
(2)在线程组下添加Samples
(3)在线程组下添加 “聚合报告”监听器
(4)在线程组下添加“图形结果”监听器(注意:有两个图形结果,应选择下一个)
(5)给出图形化的结果图
2、基于Firefox插件安装Selenium IDE进行Web页面的录制和回放。
(1)安装火狐浏览器,并下载Selenium IDE插件
(2)实现录制163邮箱登陆功能,并进行脚本录制(操作过程截图),把录制的脚本保存为python语言,并把代码复制。
创建新项目:
录制:
# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
class TestHp():
def setup_method(self, method):
self.driver = webdriver.Firefox()
self.vars = {}
def teardown_method(self, method):
self.driver.quit()
def test_hp(self):
self.driver.get("https://mail.qq.com/")
self.driver.set_window_size(1214, 863)
self.driver.switch_to.frame(1)
self.driver.switch_to.frame(0)
self.driver.find_element(By.ID, "p").click()
element = self.driver.find_element(By.ID, "p")
actions = ActionChains(self.driver)
actions.double_click(element).perform()
self.driver.find_element(By.ID, "p").click()
self.driver.find_element(By.ID, "p").send_keys("H")
self.driver.find_element(By.ID, "switcher_plogin").click()
self.driver.find_element(By.ID, "p").click()
self.driver.find_element(By.ID, "p").send_keys("Hp20011130.")
self.driver.find_element(By.ID, "p").send_keys(Keys.ENTER)
self.driver.switch_to.frame(0)
self.driver.find_element(By.ID, "slideBg").click()
self.driver.find_element(By.ID, "slideBg").click()
self.driver.find_element(By.ID, "embedVerifyBtn").click()
element = self.driver.find_element(By.ID, "embedVerifyBtn")
actions = ActionChains(self.driver)
actions.move_to_element(element).perform()
element = self.driver.find_element(By.CSS_SELECTOR, "body")
actions = ActionChains(self.driver)
actions.move_to_element(element, 0, 0).perform()
self.driver.switch_to.default_content()
self.driver.switch_to.default_content()
self.driver.find_element(By.CSS_SELECTOR, "html").click()
3、测试管理工具Testlink的使用,163邮箱注册功能的测试用例设计与执行;
(1)163邮箱注册功能需求
邮件地址要求6-18个字符,可用字母、数字下划线,但必须以字母开头;
密码要求6-16个字符,区分大小写;
确认密码要与密码一致;
验证码需与图片中的字符一致,但不区分大小写;
手机号应是1打头的11位0-9间的数字。
完成注册功能最后要勾选同意“服务条款”和“隐私权相关政策”
四、实验结果分析以及出现问题
首先,在我们的实验中,通过Jmeter对目标网站进行了并发用户数、响应时间等关键性能指标的测试。结果显示,随着并发用户数的增加,系统的响应时间呈现上升趋势,表明在高负载情况下,系统性能有所下降。这一发现对于优化系统架构、提升用户体验具有重要意义。
其次,Selenium IDE作为一款强大的自动化测试工具,能够录制用户在Web页面上的操作,并将其转化为可执行的测试脚本。在本次实验中,我们成功地安装了Selenium IDE插件,并通过它录制了一系列的Web操作。通过回放功能,我们可以验证录制的脚本是否能够准确无误地模拟用户的行为。此外,Selenium IDE还支持将录制的脚本导出为多种编程语言,我们在实验中选择了Python作为脚本语言,以便于后续的定制化开发。然而,导出的Python代码往往需要进一步的修改和优化,才能满足特定测试场景的需求。
在实验过程中,我们也遇到了一些问题。例如,在使用Jmeter进行性能测试时,由于缺乏足够的经验,初始设置的测试计划并不合理,导致测试结果不准确。对此,我们通过查阅官方文档和相关教程,逐步调整和优化了测试计划。在使用Selenium IDE时,我们也发现录制的脚本在某些复杂的交互场景下会出现错误。
总结来说,通过对Jmeter和Selenium IDE的学习与实践,我们不仅掌握了性能测试和自动化测试的基本技能,也认识到了实际操作中的挑战。这些经验对于我们未来的软件测试工作具有重要的指导意义。未来,我们将继续深化对这些工具的理解,不断提升自己的测试能力,以期在软件质量保障的道路上更进一步。