Running Selenium Scripts in Jmeter
Pre -Req :
- Use latest Jmeter
- Goto link "http://jmeter-plugins.org/" and copy paste all the jars in "your_jmeter/lib" folder.
- Go to lib folder and delete files which has copies of older versions
- httpclient-4.2.6.jar (delect this jar)
- httpclient-4.3.1.jar
- httpcore-4.2.5.jar (delect this jar)
- httpcore-4.3.jar
Steps
- Open Eclipse
- Create new project
- Add Selenium libraries to your project
- Add a class file in project> src (ex: Jtest)
- Add the below code.
WebDriver driver;
@Before
public void setUp(){
driver=new FirefoxDriver();
System.out.println("before");
}
@Test
public void test_meel(){
driver.get("http://google.com");
}
@After
public void tearDown(){
driver.close();
System.out.println("after");
}
}
Note :
Junit Annotations are very important .
setUp() , tearDown() - method names should be exact.
6. Save and Run (To Add Junit library ie., project>rt ck properties>Libraries>Add Library>Junit>select junit4>Finish).
7. Once It has Run successfully , project>rt ck>export>Select JAR file>Do as below
(Export Destination = "your_Jmeter/lib")
8. Click Finish
9.Open Jmeter
10.Add Thread groups
11. Thread groups>Junit Sampler
12.Thread groups> View Results Tree
13. goto Junit Request> Class name
Output :
Result is same as if you Run seleniume script ie., Browser will open and close ,simultaneously performance is captured .
Tips :
Keep a watch on compiler version in eclipse .As currently Jmeter can recognize only 1.6 so your code needs to be compiled with 1.6 as well otherwise the class name and method will not show up in Jmeter.
Ref:
http://artoftesting.com/performanceTesting/jmeterJunit.html
http://stackoverflow.com/questions/29200736/jmeter-and-webdriver-set-do-not-work
http://jmetertips.blogspot.in/
http://pro-programmers.blogspot.in/2009/06/testing-junit-cases-in-jmeter-basic.html
http://jmetertips.blogspot.in/2009/07/running-junit-cases-with-jmeterbasic.html
http://www.javacodegeeks.com/2014/11/jmeter-tutorial-load-testing.html
No comments:
Post a Comment