protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Docs: relationship with Karma

Open dylang opened this issue 13 years ago • 39 comments

I'm not sure if Protractor is intended to to be used with, in addition to, or instead of Karma.

Maybe a few words in the Readme would be helpful?

dylang avatar Jun 15 '13 19:06 dylang

Definitely - we'll be moving E2E tests from Angular examples over at some point and will definitely clarify then.

juliemr avatar Jun 17 '13 20:06 juliemr

Can you give a few pointers on how to get going with it? I mean, in terms of running tests, we can check out the samples but I don't see much in way of configuring Karma for Protactor

georgiosd avatar Jun 24 '13 18:06 georgiosd

Protractor and Karma should not be used together; instead they provide separate systems for running tests. Protractor and Karma cover different aspects of testing - Karma is intended mostly for unit tests, while Protractor should be used for end to end testing.

Protractor is built on top of WebDriverJS, which uses a Selenium/WebDriver server to provision browsers and drive test execution. Examples of pure WebDriverJS can be found here: http://code.google.com/p/selenium/wiki/WebDriverJs

juliemr avatar Jun 24 '13 18:06 juliemr

Just an idea (not from me actually, https://github.com/karma-runner/karma/issues/542): Use WebDriver to start the browser for karma. That could be a nice feature for Protractor, what do you think?

Tobias

tbosch avatar Jun 24 '13 19:06 tbosch

Hm, I thought you may be making efforts to combine them, as runners.

Some more questions (let me know if there's a better avenue for them than this issues page):

  • Will you be making efforts to simplify assertions (without complex .then() callbacks) like the E2E scenario had?
  • I'm in two minds on whether to use protractor in JS or port it to .NET so I can write my tests in C#. If I decide to do so - what would be the best way to keep the two repositories in sync, other than manually checking your check-ins every so often?

georgiosd avatar Jun 24 '13 19:06 georgiosd

Tobias - I'm not sure exactly what feature you're proposing. The setup at the moment already does launch browsers using WebDriver.

I do plan to include scripts to help download the selenium standalone server and chromedriver, which should make it easier to get started with protractor.

juliemr avatar Jun 24 '13 19:06 juliemr

Georgios - I think it makes sense to keep Protractor and Karma separate - for end to end tests, you want the native event driving and flexibility of webdriver, while for unit tests you want fast execution and autowatching of files.

I'm actually currently at work on simpler assertions which understand promises!

I have no current plans to port to .NET, but I will be porting to Java at some point. I haven't yet figured out the method for keeping repositories in sync, but I will definitely document the process once it's worked out.

juliemr avatar Jun 24 '13 19:06 juliemr

That's great!

Looking at your code it won't be as simple as I thought. Not sure how easily I can access element.data() from the C# WebDriver.

Where do I have to put chromedriver.exe for this to run? I tried setting capabilities['chrome.binary'] to no avail.

Also, do you have a roadmap on the project? If so, please share

georgiosd avatar Jun 24 '13 20:06 georgiosd

I'm on windows!

georgiosd avatar Jun 24 '13 20:06 georgiosd

Accessing element.data() shouldn't be any different in C# than in node.js, since it's done through executeScriptAsync. (C# docs: http://selenium.googlecode.com/svn/trunk/docs/api/dotnet/html/M_OpenQA_Selenium_IJavaScriptExecutor_ExecuteAsyncScript.htm)

I have chromedriver in the same directory as the selenium standalone binary, but I am on a mac so no guarantees for windows.

I'm hoping to use issues to track my roadmap, but don't have much laid our yet :)

EDIT: Where to put ChromeDriver on various systems: https://code.google.com/p/selenium/wiki/ChromeDriver

juliemr avatar Jun 24 '13 20:06 juliemr

Still doesn't wanna play nice :S Any further ideas, let me know.

Thanks for pointing that out - this may actually be viable. I'll keep you posted on the port if I go ahead.

georgiosd avatar Jun 24 '13 20:06 georgiosd

I thought about something like starting karma from protractor command line interface and then make karma use the same webdriver configuration as protractor. I think usually what you want in a CI is to run your end2end and unit tests against the same browsers. If you add further scripts to e.g. download and start the webdriver server automatically, this could then be also used for running the karma tests. But I am not sure about how much benefit this would be...

tbosch avatar Jun 25 '13 15:06 tbosch

Georgios - does this work for you?

java -jar selenium-server-standalone-2.33.0.jar -Dwebdriver.chrome.driver=./chromedriver

juliemr avatar Jun 27 '13 01:06 juliemr

I've opted to go with WebDriver in C# after all (copying all your wonderful clientSideScripts :)) - perhaps this can help anyone searching for the same problem

georgiosd avatar Jul 01 '13 07:07 georgiosd

I am also curious as to why protractor would not be built off of karma?

jperl avatar Jul 11 '13 19:07 jperl

@jperl WebDriver provides native event firing, which allows you to test the application truly as a user would. There's also active work on WebDriver to update it to do native event firing on mobile browsers. Karma, on the other hand, loads code into an iframe, which is great for unit testing but doesn't truly interact with the site in the way a user would.

juliemr avatar Jul 11 '13 19:07 juliemr

@juliemr is there support for PhantomJS/SlimerJS with Protractor?

johnjelinek avatar Aug 20 '13 22:08 johnjelinek

@johnjelinek No direct support. I'm not sure what the use case for end to end tests with PhantomJS would be - certainly that's not how your users are interacting with your page. As far as I know, the only advantage of PhantomJS is that it's fast, and while fast end2end tests are better, performance isn't the same kind of issue that it is for unit tests. Is there another reason to test with it?

That said, there is this thing: https://github.com/detro/ghostdriver

so potentially, you could hook PhantomJS up to your selenium server and use it.

juliemr avatar Aug 22 '13 22:08 juliemr

In my scenario, the continuous integration server doesn't have xserver and so a headless browser, based on webkit/gecko (phantom/slimer), should suffice to make sure everything is working in terms of smoke tests. On Aug 22, 2013 5:39 PM, "Julie Ralph" [email protected] wrote:

@johnjelinek https://github.com/johnjelinek No direct support. I'm not sure what the use case for end to end tests with PhantomJS would be - certainly that's not how your users are interacting with your page. As far as I know, the only advantage of PhantomJS is that it's fast, and while fast end2end tests are better, performance isn't the same kind of issue that it is for unit tests. Is there another reason to test with it?

That said, there is this thing: https://github.com/detro/ghostdriver

so potentially, you could hook PhantomJS up to your selenium server and use it.

— Reply to this email directly or view it on GitHubhttps://github.com/angular/protractor/issues/9#issuecomment-23131698 .

johnjelinek avatar Aug 22 '13 22:08 johnjelinek

Closing this thread as I think everything has been addressed. Please open new issues if anything is lingering!

juliemr avatar Aug 29 '13 04:08 juliemr