Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page objects #25

Open
des-des opened this issue Jul 3, 2016 · 5 comments
Open

Page objects #25

des-des opened this issue Jul 3, 2016 · 5 comments

Comments

@des-des
Copy link
Member

des-des commented Jul 3, 2016

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

@nelsonic
Copy link
Member

nelsonic commented Jul 3, 2016

Yeah, page objects are really useful.
if you have time to write up an example please do. 🚀

@rchovatiya88
Copy link
Collaborator

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)

screen shot 2016-11-30 at 5 11 00 pm

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.

@nelsonic
Copy link
Member

@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! 🎉

@peacetrader
Copy link

how to run the pageobjects tests from Pom folder?. Thanks.

@rchovatiya88
Copy link
Collaborator

@purnimashanti Try adding the path of where the file is form first line - like 'require(../pom/utils'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants