[英]How to simulate 120 concurrent users of a web application with real conditions?
[英]Testing for Concurrent users for a dynamic web appliacation
我想测试一个Web输入,它将输入作为参数并生成输出。 我不想进行加载或压力测试,我想让大约100个用户输入参数并单击提交。 我们怎样才能自动化呢?
我想测试的Web应用程序是http://protein.rnet.missouri.edu:8080/MongoTest/
您可以使用HtmlUnit实现此类功能。
HtmlUnit是一个“用于Java程序的GUI-Less浏览器”。 它模拟HTML文档,并提供一个API,允许您调用页面,填写表单,单击链接等...就像在“普通”浏览器中一样。
这样做的方法如下:
//set browser
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10);
//not to throw exception on javascript error
webClient.setThrowExceptionOnScriptError(false);
//set page to access
final HtmlPage homepageEn = webClient.getPage("http://protein.rnet.missouri.edu:8080/MongoTest/");
//get the form by id
HtmlForm form = homepageEn.getFirstByXPath("//form[@id='input_form']");
//setup the fields to use
HtmlTextInput mailField = form.getInputByName("mail");
HtmlPasswordInput passwordField = form.getInputByName("password");
//define the submit button (defined by value)
HtmlSubmitInput submitButton = form.getInputByValue("submit");
//change the value of text fields
mailField.setValueAttribute("somemail@xyzmail.com");
passwordField.setValueAttribute("some_password");
//finally submit the form by clicking the button
final HtmlPage resultsPage = submitButton.click();
然后,您可以使用循环或其他东西实现100个用户。 这完全取决于你..
希望这可以帮助...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.