JMeterIs the use of very extensive
Performance Testing Tools, while
Seleniumis a powerful open source web for Throughtworks Company
Functional TestingTools. JMeter and selenium can be used together to achieve automated performance testing of Web pages. There are two ways to invoke the selenium test case in JMeter. You can use Jmeter
JUnitSampler or BeanShell sampler, the latter method includes the selenium client and
Server, so you do not need to start the server separately.
Method OneGet ready
work: Copy the file Selenium-server-standalone-2.*.jar to the JMETER Class Library installation directory%jmeter_home%/lib/, and start selenium server manually. Jmeter JUnit Sampler Package The selenium test case into a. jar file and copy it to the%jmeter_home%/lib/junit/directory, note:
Test CasesThe TestCase or Seleniumtestcase class should be inherited, allowing JMeter to get to the test case, and the test method name should be
TestBeginning. Create the test group and JUnit Sampler testing plan in JMeter, and select the test case name in JUnit sampler, select the test method and run it. Of course, you can also set additional parameters as required. A test case example:
Package Com.example.tests;import Com.thoughtworks.selenium.*;import Org.junit.before;import org.junit.Test;import Org.junit.after;public class Selenium extends Selenesetestcase {@Beforepublic void SetUp () throws Exception {...} @Testpublic void Testselenium_test () throws Exception {...} @Afterpublic void TearDown () throws Exception {Selenium.stop ();}} |
Method TwoPreparation: Copy the file Selenium-server-standalone-2.*.jar to the JMETER Class Library installation directory%jmeter_home%/lib/, you do not need to start selenium server. Jmeter JUnit Sampler Package The selenium test case into a. jar file and copy it to the%jmeter_home%/lib/junit/directory, note: The test case should inherit testcase or The Seleniumtestcase class, which allows the jmeter to get to the test case, and the test method name should begin with testing. Create the test group and JUnit Sampler testing plan in JMeter, and select the test case name in JUnit sampler, select the test method and run it. Of course, you can also set additional parameters as required. A test case example:
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; @Beforepublic void SetUp () {Firefoxprofile profile = new Firefoxprofile (); .... driver = new Firefoxdriver (profile);} @Testpublic void Testselenium_test () throws Exception {...} @Afterpublic void TearDown () {driver.quit ();}} |
Test with selenium in "Go" jmeter