一、下载插件安装插件:

  1. 下载地址 JMeterPlugins-WebDriver-1.1.2
  2. 将JMeterPlugins-WebDriver-1.1.2\lib\ext中的*.jar拷贝到D:\apache-jmeter-2.13\lib\ext下。
  3. 将JMeterPlugins-WebDriver-1.1.2\lib中的*.jar拷贝到D:\apache-jmeter-2.13\lib下。
  4. 重启jmeter

二、添加配置

添加插件配置元件jp@gc - Chrome Driver Config,添加chromedriver.exe的路径

Jmeter之webdriver插件的使用_Jmeter之webdriver插件的使

三、添加取样器

添加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()

五、效果




Jmeter之webdriver插件的使用_Jmeter之webdriver插件的使_02