Open des-des opened 8 years ago
Yeah, page objects
are really useful.
if you have time to write up an example please do. 🚀
Finally got the page objects to work! I came across this project on my learning journey. Thought i would share my findings :)
The Idea is to have the elements of the page in different file so you can re-use it and if the element changes then we only have to fix at one spot and it'll fix for rest of your tests.
Test case - Go to the site, Assert Main Logo is working, Add a test user and Log out.
There will be Two files - tests.js (tests) & utils.js(elements)
Notice the correlation
In utils the function - this.mainLogo = function () { browser .click('body > nav > a'); browser.assert.containsText('.style1>strong', 'Testing'); return browser; };
In test the function to call - utils(browser).mainLogo();
Hopefully this helps.. Thanks @nelsonic and team for a great project and helping others.
@rchovatiya88 this is a great addition! would you mind sending us a Pull Request adding this to the tutorial? you've been invited to be a Collaborator on the repository we'd ❤️ to include your learnings! thanks! 🎉
how to run the pageobjects tests from Pom folder?. Thanks.
@purnimashanti Try adding the path of where the file is form first line - like 'require(../pom/utils'
Page objects allow the user to create custom selectors and sequences of selenium commands for a particular page on the site. This allows us to keep the tests dry while keeping the namespacing the commands/selectors to a particular page.
This feature is quickly becomes useful as the size of the tests grows.
http://nightwatchjs.org/guide#page-objects
happy to write this up with examples and make a pull