While trying to automate any angular application using selenium
most of us face issues like synchronization and absence of angular specific
locator like ngbinding, ngmodel, ngrepater, etc.
So In this article, we
are going to discuss one of the most asked questions I usually faced on
Automating Angular application using Selenium.
To automate angular
application using selenium we can make use of ngWebDriver.
What is
ngWebDriver?
A small library of
WebDriver locators and more for AngularJS (v1.x) and Angular (2, 3, 4, 5, 6, 7,
8), for Java. It works with Firefox, Chrome and all the other
Selenium-WebDriver browsers.
ngWebDriver
is the most convenient solution for the above issues as it has taken javascript
from the Angular Protractor project.
ngWebDriver supports
below locator like
ByAngular.repeater("")
ByAngular.exactRepeater("")
ByAngular.binding("")
ByAngular.exactBinding("")
ByAngular.model('')
ByAngular.options("")
ByAngular.buttonText("")
ByAngular.partialButtonText("")
ByAngular.cssContainingText("")
To start working with
ngWebDriver we can download its maven dependency using this link.
To download the jar file
use this link.
In this example, I am using the below maven dependency.
We have to start with
creating an object of ngWebDriver and pass our chrome or firefox driver in that.
Below is the sample code
implementation.
Please note we can also make use of conventional locator using
by class along with an Angular locator strategy like ByAngular.
Hello Ankur,
ReplyThanks for sharing this amazing article... as a new in Automation Testing I learned a lot
Hi Ankur,
ReplyCan you provide page object model for ngwebdriver
Have you found the page Object model pattern for ngWebdriver. if yes please help me
ReplyHello Ankur,
ReplyNice article. I would love to share this with my QA automation testing Friends. It will helpful for them. By using images you made it easier to understand. Thank you for sharing.