1

With selenium we enter one field at a time, right now I am working on a project where there are 1000+ fields, actually it takes huge amount of time.

Is there any possible way in selenium to make this faster?

The 1000+ fields are distributed over 12 screens one after another. Basically need to implement multi-threading in selenium to enter data in multiple fields.

  • 1
    We need more information to answer this. Do you need to enter 1000+ fields on one screen then save, or do you have a variety of fields that need to be entered in multiple different screens? – Kate Paulk Oct 14 '16 at 15:05
  • 1000+ fields are distributed over 12 screens one after another. basically need to implement multithreading in selenium to enter data in multiple fields – Jatin khurana Oct 14 '16 at 16:10
2

This is the way I'd look at this:

A data entry setup with over 1000 fields spread over what sounds like a 12 screen wizard is not a valid candidate for multi-threading. Each thread is still going to have to enter all 1000 fields for a valid end-to-end test.

You do not want to do this more than you absolutely must.

I'd suggest you work it this way:

  • For each screen, find element names or IDs so you can fill directly (excellent suggestion from Niels)
  • For each screen, determine how much information is passed to and from that screen. You're going to mock this so you can test a screen at a time.
  • Use a headless browser such as PhantomJS for the functional testing. The same test actions performed with PhantomJS are much faster because the test system has no need to render anything, and in something this unwieldy, rendering is going to be a significant time factor.
  • Data drive and use the page object pattern.
  • Do not use any variation of sending keys. This is slow. Setting the field value via Javascript as Niels suggests is much faster, although you can run into issues where Javascript validation isn't triggered because setting the field value won't trigger an onblur() type event (if the onscreen validation is using onchange() you should be okay)

None of these suggestions change your core problem: an application requiring this much data entry is probably a bad application. If a developer handed something like this to me, I'd be asking them for ways to cut down the amount of data entry and ways to optimize record creation that did not require so many fields to be used.

I'd be stunned if your users really need to fill in all 1000+ fields. More likely there are groups of fields that should be considered duplicates, a relatively small set that is actually required for a record, and a lot of fields that should be calculated or inferred from other data.

1

Users also have to input it one field at a time, I think you have a usability issue here! Who in his sane mind is going to populate thousands of fields by hand.

What you could try is to use the JavascriptExecutor and fill the fields with jQuery or plain JavaScript in the browser. If you know the element names upfront you do not have to look them up with Selenium (Xpath or CSS locators) which is pretty slow.

Also there is a Async variant, you should be able to fire lots of JavaScript commands to fill the input fields at the same time and wait until they are all done before you continue.

  • Thanks niels, your solution is definitely gone work to make execution faster. My concern is to make it even more faster. 1. enter multiple field values parallely. 2. is this possible, if yes then how and if no then what is the limitation. I know you will come up with something exciting. :) – Jatin khurana Oct 14 '16 at 17:54
  • 1
    I think with the Async calls and for example the webworker ( w3schools.com/html/html5_webworkers.asp ) you can get the browser todo multithreading. I read that NightmareJS combined with PhantomJS is really fast in performing actions on websites. Have a look at codecept.io/nightmare – Niels van Reijmersdal Oct 14 '16 at 21:07
1

I'm not going to cover the problems with the application as this seems to have already been covered.

This sort of testing is not really what Selenium is designed to do. Selenium is primarily designed to test the Javascript on a website and to give a 'once over' on the end to end testing.

For your scenario, I would recommend:

  1. Extensive unit testing for Boundary Analysis

    • Unit testing is the biggest piece of the Test Pyramid for a reason. These will execute very quickly and allow you to determine if the parameters are valid.
  2. Integration Testing

    • This will be testing with your database and other integrations hooked up. Verify that all these fields make it into your database through unit testing. You can also do some Sql Injection at this point if you'd like. But the main key with this is to make sure the integrations are working and that valid data is being populated correctly.
  3. Smoke Testing

    • This is where Selenium comes in. Some basic, simple tests to verify that the UI works properly. Nothing fancy here, just validating the Javascript.
  4. Load Testing

    • With such large amounts of data you're going to want to load test this. JMeter is a good option. Plus while setting up your load testing scripts you can possibly set up some raw HTTP scripts.
  5. Raw HTTP

    • For the majority of your 'end to end' test you're going to want to do raw HTTP request and responses. This is going to be your overall best option. I'd recommend doing this within you're favorite programming language in order to be able to do other piece like DB validation and such easily. By using raw HTTP you will get by far the best overall performance for each test run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.