Is JavaScript compatible with a strict page object template?

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?

+7
java javascript testing ui-automation pageobjects
source share
3 answers

I don't relate much to these patterns. But I will talk about some details, maybe this will help you. http://www.guru99.com/page-object-model-pom-page-factory-in-selenium-ultimate-guide.html

http://www.assertselenium.com/automation-design-practices/page-object-pattern/

It seems like a great way to achieve this is to use TypeScript (which is a statically typed version of JavaScript ):

https://en.wikipedia.org/wiki/TypeScript

+2
source share

From Gerrit0's comment above and further exploring this, it seems like a great way to achieve this is to use TypeScript (which is a statically typed version of JavaScript):

https://en.wikipedia.org/wiki/TypeScript

+3
source share

If you use Jetbrains products such as IntelliJ IDEA, it will complete code completion and the correct navigation for you. The javascript world page object also has a template. AngularJs also offers it in its own e2e test environment ( http://www.protractortest.org/#/page-objects ). Personally, I use IIFE for page objects, and IntelliJ does the rest. If this doesn't suit your needs, you can still choose typescript and translate it into javascript.

0
source share

All Articles