0

I have used browser and ptor in my previous tests, and they have different issues, but overall both seem buggy, although I like browser better.

So my question is, for testing a large angular application, is it more preferred to use the protractor.getInstance or just using regular browser?

user2167582
  • 5,986
  • 13
  • 64
  • 121

3 Answers3

3

The browser object and the object returned by protractor.getInstance() are the same object.

console.log("compare " + (protractor.getInstance() === browser));

prints "compare true"

It doesn't matter which you use, except stylistically. I like the browser object better.

For the non-wrapped webdriver instance, use browser.driver.

alan.myrvold
  • 164
  • 3
  • You're absolutely right. I did not realize this until I tested this myself just now! Thanks for sharing this. – wlingke Jan 22 '14 at 14:44
  • so i know its mentioned that ptor is constructed off browser, does that mean ptor is the bigger player here? – user2167582 Jan 23 '14 at 01:34
  • 1
    @user2167582 It doesn't matter which one you use since they are the same object. I would just use browser because it's more convenient. – wlingke Jan 23 '14 at 03:09
1

It doesn't matter. EDIT: Per alan.myrvold, browser and protractor.getInstance() are actually the exact same object. I didn't realize this until I verified his comment just now. Therefore you can use either one.

Note that if you are testing a NON-angular app, you must use browser.driver or protractor.getInstance().driver which is a webdriver instance. Using protractor.getInstance() or browser will throw errors because it will try to search for angular.

wlingke
  • 4,699
  • 4
  • 36
  • 52
-2

It's a very general question.

The angular community right now seems to move to Protractor, which is WebdriverJS based and - as far as I can tell - pretty powerful. The gist behind it is, that it uses regular browsers to do automated testing for you.

However, Protractor is a very young project and it requires a bit of getting used to. I myself found it a bit buggy and not yet suited to my needs.

Second point is: Do both. Do not completely rely on (integration) tests. You should always test functionality by hand - and should have it tested by someone else. After all, your computer is not a human.

Lastly, there is no definite answer, and I do not think it belongs here - we're here to help with specific programming problems.

Florian
  • 3,366
  • 1
  • 29
  • 35
  • thanks, I was just wondering if protractor.getInstance() was ready to do what browser did in angular e2e tests. – user2167582 Jan 21 '14 at 15:40
  • depends on what you want exactly - a quick look at the protractor source (https://github.com/angular/protractor/blob/master/lib/protractor.js#L11) reveals the capabilities with elements implemented. I'd say the options in karma are a bit better (but i usually resort to trigger events via `angular.element`). – Florian Jan 21 '14 at 17:01