Refer to the below Links for Practise |
Complete JAVA QUIZ Selenium Advanced Quiz 50 Real Time Interview Questions Selenium Quiz REST API QUIZ |
JMETER
The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.
Apache JMeter features include:
Ability to load and performance test many different applications/server/protocol types:
• Web – HTTP, HTTPS (Java, NodeJS, PHP, ASP.NET, …)
• SOAP / REST Webservices
• FTP
• Database via JDBC
• LDAP
• Message-oriented middleware (MOM) via JMS
• Mail – SMTP(S), POP3(S) and IMAP(S)
• Native commands or shell scripts
• TCP
• Java Objects
Scenario:
Execute the Selenium Scripts in JMETER and verify the average response time taken in the execution of Selenium Scripts.
1. Download the Apache JMETER zip file from this link -> https://jmeter.apache.org/download_jmeter.cgi
Example: Download apache-jmeter-x.0.zip file.
2. Unzip the file and verify the contents of the JMETER.
3. Download the jmeter-plugins-webdriver from this link https://jmeter-plugins.org/?search=jpgc-webdriver and extract the contents and copy in the JMETER/lib folder.
Example: Download jpgc-webdriver-2.3.zip file.
4. Download the Java Native Access jars and JNA Platform jars and extract the files and copy in the JMETER/lib folder as shown below:
Java Native Access[JNA] allows you to call directly into native functions using natural Java method invocation. The Java call looks just like the call does in native code. Most calls require no special handling or configuration.
5. Open JMeter bat available under JMeter/bin folder.
• Right Click on Test Plan->Create Thread Group.
• Right Click on Thread Group->Select Sampler->WebDriver Sampler
• Right Click on Thread Group-> Select Config Element->Firefox Driver Config.
• Right Click on Thread Group->Listener->View Results in Table.
Sampler->Samplers tell JMeter to send requests to a server and wait for a response.
Config->Configuration elements can be used to set up defaults and variables for later use by samplers.
Listeners->A listener is a component that shows the results of the samples.
6. Copy the Jmeter Script in the WebDriver Sampler as shown below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
WDS.sampleResult.sampleStart(); //captures sampler's start time WDS.sampleResult.getLatency(); WDS.log.info("Sample started"); // 1. Open the Web Application WDS.browser.get('http://indeed.co.in') // 2. Enter characters into the text input field var pkg = JavaImporter(org.openqa.selenium) var what = WDS.browser.findElement(pkg.By.id('what')) what.clear() what.sendKeys(['Selenium']) var where = WDS.browser.findElement(pkg.By.id('where')) where.clear() where.sendKeys(['Bangalore']) // 3. Click on the button to submit the form var button = WDS.browser.findElement(pkg.By.id('fj')) button.click() // 4. Verify successful form submission var results = WDS.browser.findElements(pkg.By.cssSelector('.summary')) if(results.empty) { WDS.sampleResult.successful = false WDS.sampleResult.responseMessage = 'There were no results returned' } WDS.sampleResult.sampleEnd(); |
7. Execute the Jmeter Script and verify the Results in the View Results Table Listener for the Sample Time captured for executing the Selenium Script.
Hi,
Can we call TestNG Framework Selenium scripts into Jmeter??
Thanks,