jmeter vs selenium - testing

Hi, I want to get into test automation, and the two tools I found during my first web search are Selenium and Jmeter.
Which one do you think is the first to have a look at? Or do I need both tools as they're totally different?
What I would need is the possibility to do Clientside-Certificate-Authentication, filling forms with different Information, and checking result pages.

Apache JMeter is definitely tool for performance testing and load/stress tests. But you can use it also for functional tests as well (in your example: fill form ->check results but with checking if results are as expected - but better don't do functional testing with him)
For functional testing on the other hand there are Selenium and also Canoo web test.
So final answer will be to combine those two. (I was using JMeter for performance tests and canoo web test for functional testing, but I guess that Selenium is much better choice now)

Use Selenium for your functional tests
Use JMeter for stress tests, and measure performance

In both cases you can record a session, so you can start your Selenium or JMeter engine, do something in your browser and then stop recording. After that you can use Selenium or JMeter to run the session recorded again.
Selenium tests browser fields and buttons. In Selenium you can fill a input field and click a button, wait for the page load and then inspect the page.
Jmeter could be used for testing user-browser GET and POST communications. In Jmeter you can request an URL and post some parameters like the browser do and then inspect the page response.
PROS and CONS:
Selenium is good if you want to test javascript page functionalities.
Selenium is good if you want to have your test cases written in Java, Javascript, Python or simple html text files. Selenium can format your test cases in many programming languages. JMeter always uses an XML format for store test cases.
JMeter is good if you don't want to deal with browser versions. JMeter works in all browsers. Selenium has a wide list of supported browsers, but will always have browser requirements.
JMeter is good if you want to also record HTTP, SOAP and RESTFul protocols. JMeter can be used for record and test communications between servers. JMeter doesn't need a browser to run, Selenium does.
JMeter can run SQL queries, bash scripts, Java classes, ... from JMeter test. By the other hand, Selenium tests can be embedded in Java, Python, Javascript, ... programs.
Both supports xpath, html inspection, css inspection, ...

as mentioned in above replies, Selenium is a tool for testing functionality. Usually its described as a tool for automated testing, while on other hand JMeter is a tool used for performance testing.
I would suggest to start off with Selenium, since the most important aspect of any web application is that it's working correctly. Try to create the basic suite of couple of tests, with the most important automated tests that verify some functionality. Once you have the base automated testing knowledge at least, I would move on to JMeter and performance testing.
In my personal experience, performance testing requires much more knowledge about the system being tested than automated testing. Both JMeter and Selenium should not be complex to learn, but for performance testing you need to more about web application tested.

Related

Selenium vs Cypress for tests that hit databases, elasticsearch, filesystem, etc

I am getting ready to start a new automation project and have done some reading on Cypress as a Selenium alternative. Given that Cypress apparently runs directly in the browser as opposed to Selenium's approach, is it difficult to perform test steps with Cypress tests that fall outside the browser such as communicating with a data store, interacting with services and interacting with product infrastructure such as remote file systems? With my limited exposure to Cypress, I have only seen browser tests so I was hoping someone could shed some light on this.
When it comes to automated testing for web applications, there are two main contenders: Selenium and Cypress. Both have their pros and cons, but which one is the best?
Selenium has been around for much longer than Cypress and is therefore more widely used. It is also more flexible, allowing for tests to be written in a variety of programming languages. However, Selenium can be slow and unreliable, and it is not as easy to use as Cypress.
Cypress, on the other hand, is a newer tool that is gaining popularity due to its simplicity and reliability. Cypress tests are written in JavaScript, making it easier for front-end developers to get started with automated testing. Cypress is also faster than Selenium and can run tests in parallel, making it more efficient.
So, which one should you use? It depends on your needs. If you need a more flexible tool that can be used with different programming languages, Selenium is a good choice. However, if you want a tool that is easier to use and more reliable, Cypress is the better option.
If you need access to things outside the browser, I would go with selenium. This is what I currently do, I have a webdriver wrapper which has "plugins" loaded so that I can make db statements, query the webserver and additionally issue selenium commands to the browser.
If you're looking for just test 100% within the browser, then cypress may be the way to go.
Alternatively, you could use selenium for workflow tests and cypress or even qunitjs for intra-browser unit tests.
In the app I work on, I actually ship a page which contains a qunit page with all of the in-browser tests. Then in a selenium test, in addition to the rest of the workflow, I browser to the qunit page and report on their status as well.

Karate UI and Gatling [duplicate]

I am developing WebUI automation tests using Karate 0.9.5.RC5 and it is working wonderfully. Does anyone know how to execute performance testing in Karate for WebUI Automation tests?
That's great to hear and thanks for the feedback. To be honest, we have focused on API perf testing and UI functional test automation so far. Maybe you can help us by experimenting and sharing what you find.
You must be aware of the Gatling integration for API performance testing. So we have some pieces of the puzzle in place.
So maybe a hybrid strategy is best:
identify the API calls being made by the UI, in the future we would like to derive them automatically from the Chrome network / devtools
manually convert the API calls to Karate tests, note that the VS Code plugin has an option to import from cURL
now you can convert the Karate tests to a performance test, and for most teams, this is sufficient
if needed, you can add some Karate calls to load HTML and static resources to make the load profile more realistic
finally, it may be possible to run a Karate UI test in parallel, just to measure "real user" experience and measure the HTML / JS load times etc on the browser side. we don't have this in place yet, but it should be possible to get all the page timings and perf-stats from Chrome
potentially you could look at spinning up multiple Chrome instances in parallel using Docker - but again, this is something yet to be explored

Is it possible to execute performance test in Karate for WebUI Automation?

I am developing WebUI automation tests using Karate 0.9.5.RC5 and it is working wonderfully. Does anyone know how to execute performance testing in Karate for WebUI Automation tests?
That's great to hear and thanks for the feedback. To be honest, we have focused on API perf testing and UI functional test automation so far. Maybe you can help us by experimenting and sharing what you find.
You must be aware of the Gatling integration for API performance testing. So we have some pieces of the puzzle in place.
So maybe a hybrid strategy is best:
identify the API calls being made by the UI, in the future we would like to derive them automatically from the Chrome network / devtools
manually convert the API calls to Karate tests, note that the VS Code plugin has an option to import from cURL
now you can convert the Karate tests to a performance test, and for most teams, this is sufficient
if needed, you can add some Karate calls to load HTML and static resources to make the load profile more realistic
finally, it may be possible to run a Karate UI test in parallel, just to measure "real user" experience and measure the HTML / JS load times etc on the browser side. we don't have this in place yet, but it should be possible to get all the page timings and perf-stats from Chrome
potentially you could look at spinning up multiple Chrome instances in parallel using Docker - but again, this is something yet to be explored

Performance/Load test using selenium webdriver prerecorded steps

I have been using selenium webdriver as my main method to do functional tests. So far its been working greate with our product.
I need to do some performance and/or load tests on the website, I was wondering if there is a tool that would incorporate my selenium tests or a tool which i can use with the recorded tests as the base.
Currently i am using selenium webdriver with C#
Any help is appreciated.
Given you have tests written in C# the most obvious way would be using Visual Studio Load Testing capabilities.
If you are looking for a free and open-source solution I would recommend going for Apache JMeter. JMeter has integration with Selenium via WebDriver Sampler plugin so you should be able to run your Selenium tests in multi-threaded manner. However you will need to convert your C# code into one of the WebDriver Sampler supported languages (default is JavaScript)
Remember that Selenium tests are very resource-intensive as real browsers consume a lot of CPU/RAM so the number of virtual users you will be able to mimic this way will be very limited. So recommended approach is creating main load on a HTTP protocol level and use one Selenium instance to check rendering speed while your application is under the load.
You can install WebDriver Sampler plugin using JMeter Plugins Manager.
Why do you need to run full browsers. HTTP layer tests are far simpler? You also should be looking at only a subset of business processes in performance which generate a preponderance of load.

Selenium and HTTPUnit

What's the pro's and cons for both and why should I use either of them for functional testing?
Regards,
Jonas
Selenium is for integration testing, It will test how your web application behaves in an actual browser. This can find things that HTTPUnit cannot, e.g. browser compatibility of css and JavaScript.
HTTPUnit tests web applications by directly calling the web service and manipulating the response. This is a functional test framework as it tests what your web app does, not how it behaves across different platforms.
One advantage of HTTPUnit is that it is much quicker than Selenium. Personally I would (and do) use both. HTTPUnit for complete functional testing and Selenium for selective (not complete) integration testing to check browser compatibility.
HttpUnit is very simple, extremely easy to use, and requires very little to get up and running. It's a good place to start for simple tests, however it will require more coding to create complex tests.
Selenium is more than just a library, like HttpUnit. It equips you better for more advanced, stateful tests.
Selenium will use your browser to automate tests
- Selenium http://seleniumhq.org/
httpunit goes from the html specification and simulates a standards conformant browser
- httpunit http://httpunit.sourceforge.net/
Selenium is more specific and will let you use browser specific behaviour and not limit the application under test.
With httpunit the limits are set by what httpunit supports which is far less than most browser do. E.g. the javascript capabilities are reduced to a very small set. On the other hand if your app passes httpunit tests it will probably run on quite a few browsers and environments.
So if you are interested in supporting a mininimal common set of features httpunit might be for you.