Jmeter之webdriver插件的使用
一、下载插件安装插件:
- 下载地址 JMeterPlugins-WebDriver-1.1.2
- 将JMeterPlugins-WebDriver-1.1.2\lib\ext中的*.jar拷贝到D:\apache-jmeter-2.13\lib\ext下。
- 将JMeterPlugins-WebDriver-1.1.2\lib中的*.jar拷贝到D:\apache-jmeter-2.13\lib下。
- 重启jmeter
二、添加配置
添加插件配置元件jp@gc - Chrome Driver Config,添加chromedriver.exe的路径
三、添加取样器
添加sample jp@gc - WebDriver Sampler
四、取样器中写代码
function sleep(delay) {
var start = (new Date()).getTime();
while ((new Date()).getTime() - start < delay) {
continue;
}
}
WDS.sampleResult.sampleStart()
WDS.browser.get("https://www.baidu.com/");
var searchBox = WDS.browser.findElement(org.openqa.selenium.By.id("kw"));
searchBox.sendKeys('久曲健 博客园');
searchBox.sendKeys(org.openqa.selenium.Keys.ENTER);
sleep(3000);
// 4. Verify successful form submission
var results = WDS.browser.findElements(org.openqa.selenium.By.cssSelector("div > h3 > a[target='_blank']"))
if(results.empty) {
WDS.sampleResult.successful = false
WDS.sampleResult.responseMessage = 'There were no results returned'
}
WDS.sampleResult.sampleEnd()
五、效果
优秀不够,你是否无可替代
软件测试交流QQ群:721256703,期待你的加入!!
欢迎关注我的微信公众号:软件测试君
![](https://www.cnblogs.com/images/cnblogs_com/longronglang/1061549/o_QQ%E6%88%AA%E5%9B%BE20190728134401.jpg)