Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What testing does Selenium cover over and above Karma?

I understand that Karma is a JavaScript test runner, which can run tests in real browsers. If that is the case, what kind of test coverage does Selenium provide over and above Karma.

like image 836
Jason Weden Avatar asked Dec 20 '12 02:12

Jason Weden


People also ask

What kind of testing does Selenium do?

Selenium is a test automation framework that allows you to automate web app testing. With languages like Java, Python, Ruby, C#, you can write test scripts to run against browsers and VMs.

Does karma use Selenium?

If you are using javascript to write unit tests - via jasmine/mocha/chai or equivalent then - the argument that karma relies heavily on javascript and selenium doesn't - is redundant.

What is karma testing?

Karma is essentially a tool which spawns a web server that executes source code against test code for each of the browsers connected. The results of each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.

What testing level does Selenium support?

According to Selenium's official website (selenium. dev), It supports Functional Testing in System Testing Level and Functional Testing in Acceptance Testing Level.


2 Answers

There is a huge difference between Karma and Selenium. Selenium has a built-in browser control mechanism, while Karma does not. So Selenium is more suited to end to end testing, for example with nightwatch.js. Karma is designed for unit tests, so it is much harder to achieve end to end tests on it, you can add for example a phantomjs launcher, but it will never be the same as real browser tests with Selenium... I think both of them can run any js testing framework if you have an adapter... Mocha, jasmine, qunit, etc...

An eternity later:

It is possible to write e2e tests with Karma. You need to create an iframe or open a new window and run a script, which does the navigation, fires the events, submits forms, etc. from the parent frame or window. The tested page needs to allow your Karma server with CORS or you need to disable browser security. I am working on an e2e testing library, which does exactly this.

like image 61
inf3rno Avatar answered Nov 08 '22 12:11

inf3rno


There are several versions of Selenium, the newest (I believe) of which is Selenium Web Driver which allows you to create a driver that will handle a browser for you by simulating actions that interact with the UI much like a user would (through a Json wire).

My current understanding of Karma (which may I add is very limited) is that it relies heavily on executing javascript. Because of this Karma would have to call change events on elements (as in, 'blur' and 'hover over') whereas Selenium would just click, tab out, move cursor to. Selenium's browsers are limited to those specified on their webpage here.

like image 27
Nashibukasan Avatar answered Nov 08 '22 11:11

Nashibukasan