I created various test automation schemes using the page object template with Java ( https://code.google.com/p/selenium/wiki/PageObjects ).
Two of my biggest advantages:
1) You can see what methods are available when you have an instance of the page (for example, on the home page. I will show me all the actions / methods that you can call on the main page)
2) Since navigation methods (e.g. goToHomepage ()) return an instance of a subsequent page (e.g. a home page), you can navigate your tests simply by writing code and looking at where it takes you.
eg.
WelcomePage welcomePage = loginPage.loginWithValidUser(validUser); PaymentsPage paymentsPage = welcomePage.goToPaymentsPage();
These benefits work fine with Java, because the type of object (or page in this case) is known by the IDE.
However, with JavaScript (dynamically typed language), the type of an object is not fixed at any point and is often ambiguous for an IDE. Therefore, I donβt see how you can realize these advantages in an automation suite built using JavaScript (for example, using Cucumber).
Can someone show me how to use JavaScript with the page object template to get these benefits?
java javascript testing ui-automation pageobjects
Charlie seligman
source share