jmeter实现UI自动化demo

时间:2024-04-13 14:26:41

 jmeter实现UI自动化demo

 jmeter实现UI自动化demo

 jmeter实现UI自动化demo

 jmeter实现UI自动化demo

 jmeter实现UI自动化demo

 其中WebDriver Sampler中的代码如下:

var pkg = JavaImporter(org.openqa.selenium); //WebDriver classes
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait); //WebDriver classes
var wait = new support_ui.WebDriverWait(WDS.browser, 5000);
var timeunit = java.util.concurrent.TimeUnit


WDS.sampleResult.sampleStart(); //captures sampler's start time
WDS.sampleResult.getLatency();
WDS.log.info("Sample started");


WDS.browser.get('http://duckduckgo.com'); //opens website specified in 'http://duckduckgo.com'
WDS.log.info("Sample ended - navigated to duckduckgo.com");

var searchField = WDS.browser.findElement(pkg.By.id('search_form_input_homepage')); //saves search field into searchField
searchField.click(); //clicks search field

searchField.sendKeys(['blazemeter']); //types word "blazemeter" in field
WDS.log.info("Searched for BlazeMeter");

var button = WDS.browser.findElement(pkg.By.id('search_button_homepage')); //Find Search button
button.click(); //Click Search Button
WDS.log.info("Clicked on the search button");

var link = WDS.browser.findElement(pkg.By.cssSelector('#r1-0 > div > h2 > a.result__a > b')); //also saves selector as variable but uses CSS.
link.click(); //Click the search result's Link

//设置整个事务的总的请求超时时间
WDS.browser.manage().timeouts().pageLoadTimeout(20,timeunit.SECONDS);

WDS.sampleResult.sampleEnd();