关闭

JMeter中使用Selenium进行测试

发表于:2014-6-05 11:19

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:babyhe    来源:51Testing软件测试网采编

  方法二
  准备工作:
  将文件selenium-server-standalone-2.*.jar拷贝到JMeter类库安装目录%JMETER_HOME%/lib/下,不需要启动Selenium server.
  Jmeter JUnit sampler
  将Selenium测试用例打包成.jar文件,并拷贝到%JMETER_HOME%/lib/junit/目录下,注意:测试用例应该继承TestCase or SeleniumTestCase类,从而允许JMeter获取到该测试用例,且测试方法名称应该以test开头。
  在Jmeter中创建test group和JUnit sampler测试计划,并在JUnit sampler中选择测试用例的名称,选择测试方法并运行。当然还可以根据需求设置其他参数。
  一个测试用例例子:
import junit.framework.TestCase;
import org.openqa.selenium.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.After;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class selenium extends TestCase {
WebDriver driver;
@Before
public void setUp() {
FirefoxProfile profile = new FirefoxProfile();
. . .
driver = new FirefoxDriver(profile);
}
@Test
public void testSelenium_test() throws Exception {
. . .
}
@After
public void tearDown() {
driver.quit();
}
}
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号