Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
docs(page-objects.md): Refactor the existing Page Object example (#4576)
Browse files Browse the repository at this point in the history
* Refactor the existing Page Object example

so that it will run as presented. Open possibilities for future work, carry the initial introduction over into a Page Object. Introduce `world`, etc.
  • Loading branch information
timothystone authored and qiyigg committed Nov 14, 2017
1 parent a62efc6 commit 8d71a1b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/page-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('angularjs homepage', function() {
});
```

With PageObjects
With Page Objects
----------------

To switch to Page Objects, the first thing you need to do is create a Page Object. A Page Object for ‘The Basics’ example on the angularjs.org homepage could look like this:
Expand All @@ -41,13 +41,16 @@ var AngularHomepage = function() {
return greeting.getText();
};
};
module.exports = new AngularHomepage();
```
The next thing you need to do is modify the test script to use the PageObject and its properties. Note that the _functionality_ of the test script itself does not change (nothing is added or deleted).
The next thing you need to do is modify the test script to use the Page Object and its properties. Note that the _functionality_ of the test script itself does not change (nothing is added or deleted).

In the test script, you'll `require` the Page Object as presented above. The path to the Page Object _will be relative_ to your spec, so adjust accordingly.

```js
var angularHomepage = require('./AngularHomepage');
describe('angularjs homepage', function() {
it('should greet the named user', function() {
var angularHomepage = new AngularHomepage();
angularHomepage.get();

angularHomepage.setName('Julie');
Expand Down

0 comments on commit 8d71a1b

Please sign in to comment.