Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: relationship with Karma #9

Closed
dylang opened this issue Jun 15, 2013 · 39 comments

Comments

@dylang
Copy link

commented Jun 15, 2013

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?

@juliemr

This comment has been minimized.

Copy link
Member

commented Jun 17, 2013

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

@ghost ghost assigned juliemr Jun 17, 2013

@georgiosd

This comment has been minimized.

Copy link

commented Jun 24, 2013

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

@juliemr

This comment has been minimized.

Copy link
Member

commented Jun 24, 2013

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

@tbosch

This comment has been minimized.

Copy link

commented Jun 24, 2013

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

Tobias

@georgiosd

This comment has been minimized.

Copy link

commented Jun 24, 2013

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?
@juliemr

This comment has been minimized.

Copy link
Member

commented Jun 24, 2013

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

This comment has been minimized.

Copy link
Member

commented Jun 24, 2013

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.

@georgiosd

This comment has been minimized.

Copy link

commented Jun 24, 2013

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

This comment has been minimized.

Copy link

commented Jun 24, 2013

I'm on windows!

@juliemr

This comment has been minimized.

Copy link
Member

commented Jun 24, 2013

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

@georgiosd

This comment has been minimized.

Copy link

commented Jun 24, 2013

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.

@tbosch

This comment has been minimized.

Copy link

commented Jun 25, 2013

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...

@juliemr

This comment has been minimized.

Copy link
Member

commented Jun 27, 2013

Georgios - does this work for you?

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

This comment has been minimized.

Copy link

commented Jul 1, 2013

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

@jperl

This comment has been minimized.

Copy link

commented Jul 11, 2013

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

@juliemr

This comment has been minimized.

Copy link
Member

commented Jul 11, 2013

@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.

@johnjelinek

This comment has been minimized.

Copy link

commented Aug 20, 2013

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

@juliemr

This comment has been minimized.

Copy link
Member

commented Aug 22, 2013

@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.

@johnjelinek

This comment has been minimized.

Copy link

commented Aug 22, 2013

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" notifications@github.com 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//issues/9#issuecomment-23131698
.

@juliemr

This comment has been minimized.

Copy link
Member

commented Aug 29, 2013

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

@juliemr juliemr closed this Aug 29, 2013

@jaredly

This comment has been minimized.

Copy link

commented Sep 25, 2013

@johnjelinek fyi you can just run phantomjs --webdriver=4444, and it will act as a webdriverjs server (on port 4444).

@johnjelinek

This comment has been minimized.

Copy link

commented Sep 25, 2013

I'll try this out!
On Sep 24, 2013 7:34 PM, "Jared Forsyth" notifications@github.com wrote:

@johnjelinek https://github.com/johnjelinek fyi you can just run phantomjs
--webdriver=4444, and it will act as a webdriverjs server (on port 4444).


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

@atul221282

This comment has been minimized.

Copy link

commented Oct 10, 2013

can we use protractor for unit testing? I think not but just need confirmation from experts out there..

@johnjelinek

This comment has been minimized.

Copy link

commented Oct 10, 2013

You 'could', but it's the won't tool for the job. Use karma as your test
runner.
On Oct 10, 2013 1:21 AM, "Atul" notifications@github.com wrote:

can we use protractor for unit testing? I think not but just need
confirmation from experts out there..


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

@juliemr

This comment has been minimized.

Copy link
Member

commented Oct 10, 2013

Yup - Karma is a great tool for unit testing, and you should use that.

@dylang

This comment has been minimized.

Copy link
Author

commented Oct 10, 2013

Because this question comes up so frequently (not just here, but in my office, at meetups, etc) - would it be possible to say something about Karma in the Protractor readme?

For example:

Tool Purpose What sets it apart Example Usage
Protractor End-to-End Has knowledge of the whole page, not individual modules. Create account, buy a widget, sign out. Did it work as I expected?
Karma Unit You choose what modules or files to make available to test. It does not know about the whole page. When I pass various values to this service do I get the output I expected?

Disclaimer: I haven't used Protractor yet and I'm still new with Karma.

@juliemr

This comment has been minimized.

Copy link
Member

commented Oct 10, 2013

I'll add something to the FAQ.

@juliemr juliemr reopened this Oct 10, 2013

@atul221282

This comment has been minimized.

Copy link

commented Oct 10, 2013

Thanking everyone for their feedback.

I like using Karma for Unit testing and I love protractor for end to end testing but can we make protractor work for unit testing because if we can do that we will be removing dependency on karma and then for testing we just have to use protractor. Just a thought..

Regards,
Atul

@johnjelinek

This comment has been minimized.

Copy link

commented Oct 10, 2013

They should be separate.
On Oct 10, 2013 5:52 PM, "Atul" notifications@github.com wrote:

Thanking everyone for their feedback.

I like using Karma for Unit testing and I love protractor for end to end
testing but can we make protractor work for unit testing because if we can
do that we will be removing dependency on karma and then for testing we
just have to use protractor. Just a thought..

Regards,
Atul


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

@juliemr

This comment has been minimized.

Copy link
Member

commented Oct 10, 2013

Yes, they should be separate systems. Karma is great for what it does!

@juliemr juliemr closed this in 8ddcf75 Oct 16, 2013

@bbaia

This comment has been minimized.

Copy link

commented Oct 29, 2013

@georgiosd I've started working on the .NET port: https://github.com/bbaia/protractor-net
Feedback is welcome

@atul221282

This comment has been minimized.

Copy link

commented Oct 29, 2013

Hi @bbaia got bit excited to see your post.
What do I need to do to get this end to end test to work on ASP.Net MVC4 project.
IF i am not wrong all i have to do is to install protractor via nuget and then just start writing test case under test project?

Wait for ur reply.

Regards,
Atul Chaudhary

@georgiosd

This comment has been minimized.

Copy link

commented Oct 29, 2013

@bbaia Have you looked at https://github.com/TestStack/TestStack.Seleno at all?
I have some custom code that is a sort of hybrid between the two!

@bbaia

This comment has been minimized.

Copy link

commented Oct 30, 2013

@atul221282 Yes, check out the sample.

@georgiosd Nope, but if you want to use the PageObjects pattern, Selenium provides a package (Selenium.Support) for that.
See also protractor's documentation: https://github.com/angular/protractor/blob/master/docs/getting-started.md#organizing-real-tests-page-objects

@jfroom

This comment has been minimized.

Copy link
Contributor

commented Oct 31, 2013

Has anyone here gotten E2E tests to run with PhantomJS? Would you be able to share your setup on this thread? #189 Thanks.

@jfroom

This comment has been minimized.

Copy link
Contributor

commented Oct 31, 2013

Once there's a process it seems like one of the MD docs should be updated with how to get PhantomJS running so the insights aren't hidden away in these forums. Better yet, it may be worth integrating directly into Protractor like Karma did - imho.

@juliemr

This comment has been minimized.

Copy link
Member

commented Oct 31, 2013

I'd be happy to accept a pull request with docs on how to use PhantomJS!

@jfroom

This comment has been minimized.

Copy link
Contributor

commented Oct 31, 2013

Sorry, meant to put that previous comment about MD docs on a different thread!

kbaltrinic pushed a commit to kbaltrinic/protractor that referenced this issue May 2, 2014
docs(faq): update docs now that $interval service is available
Updating the docs now that the $interval service is available
as a solution for applications which poll continuously. Also,
adding an FAQ question clarifying the difference between Karma
and Protractor. Closes angular#9
@reddynr

This comment has been minimized.

Copy link

commented Nov 14, 2016

I using protractor to perform unit testing.. I am getting error if use expect function like below. Please advice is highly appreciated.
element(by.model('ctrl.formData.emailAddress')).sendKeys('xyz@abc.com');
var emailaddress = element(by.model('ctrl.formData.emailAddress'));

expect(emailaddress.getText()).toEqual('xyz@abc.com');

error : Expected '' to equal 'narendra@abc.com'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.