mardi 31 janvier 2017

Is JavaScript compatible with strict Page Object Pattern?

I have built various Test Automation frameworks using the Page Object Pattern with Java (http://ift.tt/19A2hZK).

Two of the big benefits I have found are:

1) You can see what methods are available when you have an instance of a page (e.g. typing homepage. will show me all the actions/methods you can call from the homepage)

2) Because navigation methods (e.g. goToHomepage()) return an instance of the subsequent page (e.g. homepage), you can navigate through your tests simply by writing the code and seeing where it takes you.

e.g.

WelcomePage welcomePage = loginPage.loginWithValidUser(validUser);
PaymentsPage paymentsPage = welcomePage.goToPaymentsPage();

These benefits work perfectly with Java since the type of object (or page in this case) is known by the IDE.

However, with JavaScript (dynamically typed language), the object type is not fixed at any point and is often ambiguous to the IDE. Therefore, I cannot see how you can realise these benefits on an automation suite built using JavaScript (e.g. by using Cucumber).

Can anyone show me how you would use JavaScript with the Page Object Pattern to gain these benefits?

Aucun commentaire:

Enregistrer un commentaire