Can Selenium web driver be used to automate tests for Angular 4 applications? Or is Protractor a more reliable option?
Selenium can be used to test any web page, so Angular applications can be perfectly automated.
On top of that, you can easily write custom locators so waiting on typical
ng elements is feasible with any Selenium binding.
Especially if your language is C#, Java or Python, Selenium itself is likely the best choice.
Note the comment of @alexce in the linked topic: if I were to start our test automation efforts from scratch now, I would go for Python/Selenium. Personally, I also prefer a solid self-built framework around Selenium rather than add another third-party layer.
I have used Protractor to test different Angular SPAs, including a large suite of tests in which I have disabled the Selenium Promise Manager implementation and used Async/Await - which is way nicer if you understand Promises very well. Also, quite interesting for me, I have used Protractor on a non-Angular e-commerce app (the reason being that I'm so accustomed to Protractor) and never ran into specific problems.
Here are a few advantages of using Protractor to test an Angular App:
No need to add waits and sleeps: As the webpage finishes pending tasks, Protractor executes the next steps of the testing process by automatically connecting with the AngularJS application
Supports Angular-specific locator strategies including binding, model, repeater as well as native WebDriver locator strategies
One Config file to rule them all: you can set any global variables, integrate any packages and even execute the tests in cloud providers (SauceLabs, BrowserStack)
If you like Classes, as syntax, rather than using the JS Prototypes, using ES6 will be a breeze
The Protractor syntax is somehow shorter (and nicer) -> http://www.protractortest.org/#/webdriver-vs-protractor
It can take the advantage of the Selenium grid to run multiple browsers at once
It can run test on both real and headless browsers
It can use Jasmine or Mocha or Cucumber to write your test
You can integrate all the e2e tests into your /test directory within the application code-base, which is a huge advantage to have the tests in the same repository as the source code of the app resides
It works in conjunction with Selenium to offer an automated test infrastructure and it makes selenium grid to run multiple browsers all at once
Just a note: I'm not advocating for Protractor or so, I just have 2-3 years of experience using JS Selenium frameworks and I consider Protractor being an excellent candidate when it comes to Angular apps in general. But as I said, if you have a solid experience using Python, Java, or anything else, maybe it'll be better to build on top of your experience, rather than switching to a new language/ecosystem where you'll get often stuck, let's say. But if you have some time, take Protractor for a spin.
Protractor is the better option for Angular 4 automation, after all is a wrapper of Selenium WebDriverJS Api. You can find a lot of materials around the net, paid or free. Of course you need at least the basic single page application knowledge to start testing with protractor.