Performance testing using Selenium WebDriver, is it possible? - selenium-webdriver

Problem Statement: I have a simple test of "Successful login to web Page". This test to be carried out with 100 different username and password. Requirement is test should hit the server with 100 usernames at the same time.
Information: Do we have to use selenium grid or RC or simple WebDriver, we are free to use any. Reading usernames & passwords from xls, or xml or parameterized junit, we are free to use whatever.
Is this possible?
How can we achieve this?

Yes, it can be done with Selenium WebDriver. If you want to reach 100 concurrent sessions, your best choice is to use an headless browser, for example PhantomJS. Here you have a running example. This example uses JUnit, Selenium WebDriver, and WebDriverManager (to handle the required binary by PhantomJS).
To fit this example into your requirements, you need to change the value of NUMBER_OF_BROWSERS to 100 and then change the code of the singleTestExcution method for your own logic (open your app and do login).
You can also do it using real browsers, e.g. Chrome (equivalent example here). But if you need to reach to 100 clients, this is going to be very expensive in terms of resources (CPU and memory) conmsuption.

Related

Can we use gatling or Jmeter to perform operations such as input text, click on element, select dropdown?

Can we perform functional-load testing using gatling or jmeter?
By Functional load testing I mean to perform certain operations on web application. User performs operations such as
Clicking on link
Entering text into a combo box (textbox + Dropdown)
Enter text into multiple textboxes
And many other operations
I want to load web app with N number of users to identify the point where the application breaks.
I have tried using Selenium Webdriver with TestNG and its invocationCount and thread-pool-size. This opens 100's of browsers which degrades the performance of the systems on which I am running the tests.
Thank you for your help in advance.
Simply you can create your tests using selenium and integrate it with Jmeter to control you load
Please find below link for how to integrate selenium with Jmeter
https://www.blazemeter.com/blog/jmeter-webdriver-sampler
I presume you are looking for a free tool to run multiple webdriver tests concurrently and at load? If so I am not aware of any free tools that can scale to hurdreds or thousands of fully headed brower sessions but there are paid tools out there. If you are interested let me know and I will share.

Comparison of capybara-webkit vs selenium-webdriver

I want to write test cases for my rails application. I have already written a lot of test cases in Rails built-in framework Minitest.
Now I want to test javascript functionality of my web app.
I came across these two tools
1: Selenium web-driver
2: Capybara-webkit
I am confused which one to use. I know few advantages and disadvantages of these two tools like
Capybara webkit is headless while selenium web-driver open a browser.
Capybara is faster than selenium.
Capybara cannot open any other application while selenium can interact with third party apps like facebook and LinkedIn
Can anyone tell me the comparison of these two tools for testing ?
You're confusing a few things here. Capybara is a testing framework/DSL, for Ruby, which can be used with any of the test runner frameworks (RSpec, Minitest, etc). It can use a number a of different drivers to communicate with the web app being tested.
The default driver is rack_test which doesn't support any JS and cannot connect to any addresses outside the app under test.
A second driver option is selenium-webdriver which can control multiple different real browsers firefox/chrome/safari/etc. for testing, and can connect to any valid URL. The downside of using selenium-webdriver as the driver is that it opens a real browser and is therefore usually slower with a larger memory footprint.
Another driver option is capybara-webkit which is headless and can also connect to any valid URL. It is generally faster than using selenium however as it is built on an old version of QtWebkit it doesn't support newer web standards (ES2015, etc) so at a minimum you need to make sure all JS is transpiled to ES5 maximum.
There is nothing to stop you using different drivers for different tests to get the benefits of speed for most tests and then use a real browser for tests that need things like WebRTC, etc. The Capybara README details how to do that when using different test runners (RSpec, Minitest, etc)

Selenium script breaks when doing other activities

I am using selenium to automate my application.. My applicaton works on IE only.. I dont have much scope for other browser..
but when my scripts are running if i do other activities like reading mails, or update QC in another window.. Those are breaking my scripts (no such element or no such window..) once in a while (mostly out of 10, 2 to 3 times i am facing this issue). But can not make system idle till my scripts are run as i do have other activities after started the script. How to stabilize this?? Any one facing these kind of issues??
Running Selenium tests locally using your one and only IE browser does come at the cost of having to not touch your mouse or keyboard during test executions. A way to get around this is to create one or more virtual machines. VirtualBox from Oracle is a popular choice but there are others. You need to install an operating system on your new virtual machine and odds are that your existing Windows license is single use. You can request an additional Microsoft Windows OS license from your IT department or simply buy one yourself for, what? $190? I have done that when the paper work at my client was unmanageable. My time is worth more than that.
Another alternative is to take advantage of 90 day free licenses from Microsoft.
Start your test on the virtual machine then change focus back to your desktop to do other work. I have even added code to the end of test logic to beep when the test completes so that I know when to expand my virtual machine.
Update
You should add an antivirus to that virtual machine. Safety first. :-)
Selenium does not support and non web-based applications, it only supports web based applications.
So if you are doing activities like reading mails and update QC in other window, you will not able to find the elements through selenium.
If you are facing some challenges with IE browser. Please refer this link:https://code.google.com/p/selenium/wiki/InternetExplorerDriver
There are following limitations are given below:
Some limitations of Selenium Automation tool are as follows:
It does not support and non web-based applications, it only supports web based applications.
Its and open source tool so in case of any technical issues you need to rely on the selenium community forums to get your issue resolved.
You need to know at least one of the supported language very well in order to automate your application successfully.
No inbuilt reporting capability so you need plugins like JUnit and TestNG for test reports.
Lot of challenges with IE browser.

Performance testing using Jmeter and WebDriver Sampler

I am creating a performance test suite in jmeter with webdriver sampler. I am able to do it but when I see the results(load time).It keeps changing every time I run the test for same URL (homepage). How do I get accurate results?
Performance testing using WebDriver Sampler is not what it is designed for.
As per WebDriver Sampler Tutorial
Note: It is NOT the intention of this project to replace the HTTP Samplers included in JMeter. Rather it is meant to compliment them by measuring the end user load time.
and
The Web Driver Sampler is meant to be run in conjunction with a HTTP Sampler so that from the server's perspective, the load is production like. At the same time, the web sampler will simulate the user experience of interacting with the website/webapp whilst the server is under load, hence measuring the real user's experience at the same time.
So I would recommend the following approach:
Develop your test using HTTP Request Samplers
Follow recommendations from How to make JMeter behave more like a real browser guide
Add a separate Thread Group with 1 virtual user and put WebDriver Sampler in there to measure real-life user experience during load test.

How can i use Selenium for long scenarios?

I have been asked to record a long running scenario which involves pages of functionality for the life-cycle of a patient from registration to billing. I tried Selenium IDE but it is flaky, giving replay errors of what it just recorded. When i try Selenium 2, I get into DOM and XPATH problems. Selenium 2 is meant for unit testing i believe. What are the open source alternatives which scale to 5 minute scenario record and replay ? I know this is a subjective question, which might have been asked before, but the options might have improved.
We use Selenium 2 on a daily basis (driven by groovy scripts but that's not the point) to run long running scenarii involving multi-websites connections [and even mail confirmations verification]. It's very stable when a proper error handling is done. The key to success with long scenarios is "expect to fail". Like in a real world, when you sometime have to click twice on a button
You have to use the WEbdriver and not the recording in IDE.
You have to use Paje Object Model to make the project stable.
see this article:
https://weblogs.java.net/blog/johnsmart/archive/2010/08/09/selenium-2web-driver-land-where-page-objects-are-king
Selenium Web driver will actually work. Xpath problems might be due to page loading time issues.
Include Implicit or Explicit waits in your selenium code.
Even Thread.sleep(milliseconds) will fix the issues to some extent.
I would actually suggest maybe switching over to Watir-webdriver with PageObject if you are going to be using long-running scenarios. We have extremely long scenarios in an AJAX application and could not solve the problem with Selenium. Switching over to watir-webdriver and the page-object gem allowed us to reuse pages with proper waits, and no failures.

Resources