2

I am writing unit testcases for a UI Framework using Mocha, Chai and Karma. I have analysed before whether to use selenium webdriver to do testing, but since most of the test cases involve working with DOMElement I have found it difficult to be working with selenium though javascript version( WebDriverJS ) is available.

Even when I checked other UI Frameworks like jquery ui, kendo, semantic, foundation etc.. they have used javascript frameworks like jasmine, qunit etc.. for testing rather than selenium.

What could be the reason that UI Framework developers do not prefer Selenium?

1
  • What is THE question? Commented Jun 8, 2018 at 23:39

5 Answers 5

1

TL;DR: Selenium is just to slow, compared to for example Karma.


I guess most UI Frameworks manipulate the DOM. So verifying that the manipulation was correct is also done in the DOM. Most UI Frameworks seem to use Karma for cross-browser testing the DOM. By running plain JavaScript in the browser and using the plain JavaScript API to get back the results.

Checking all the functionality with Selenium would be slow, hard to maintain and unnecessary as you can test it faster with for example Karma and plain JavaScript.

Jasmine and qUnit are more alternative test runners than tools to verify the DOM. You can also build Selenium or Karma tests with them.

For building UI Frameworks I would expect you need something to run-tests against an actual DOM and check it does what you expect, preferable cross all supported browsers and bloody fast.

UI Frameworks are building blocks for building web-based workflows. Testing the building blocks is relatively easy with the browser JavaScript API. Where testing full workflows is not, here Selenium would be better suited.

1
  • Thanks for your response. You have given me some clarity. I think Selenium would be more appropriate for testing full workflows of an application. So I would rather go with Karma and Mocha as I need to test individual components.
    – vbrin27
    Commented Sep 23, 2018 at 12:03
1

Selenium is a UI automation library whereas libraries like Jasmine is a general javascript test framework which can be utilized for the unit as well as UI testing automation for the assertions.

If you are purely unit testing, then probably you don't need selenium.

0

Selenium is more designed for doing end-to-end testing, where it simulates actions within a browser. Jasmine and QUnit are both unit testing frameworks for testing the code. If you're looking to do end-to-end tests that are more compatible with JS, check out Protractor—it's made for AngularJS apps. Otherwise, if you're unit testing, you should avoid Selenium and use one of the unit testing frameworks.

0

The reason is quick feedback. unit tests run much faster and selenium/protractor being e2e solutions runs slower. There is a clear separation between unit test and end to end testing.

Please let us know in specific what you need to understand.

2
  • Actually I need to know which testing framework would be more suitable to do unit testing of UI Components like slider, combobox, select etc.. Selenium or Javascript test runners like Karma, Jasmine ...
    – vbrin27
    Commented Sep 23, 2018 at 12:23
  • Selenium is not the solution as you are looking for a unit testing approach. With my limited knowledge on JS frameworks, I think Karma can be a suitable solution for your problem. Commented Sep 24, 2018 at 5:36
-1

You can use this approach - "VISUAL REGRESSION TESTING USING JEST, CHROMELESS AND AWS LAMBDA" https://novemberfive.co/blog/visual-regression-testing-jest-chromeless-lambda

1
  • Please do not add one-liners or link only answers. Add an explanation as to why this approach will be helpful. Commented Jun 12, 2018 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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