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

Commit 8d71a1b

Browse files
timothystoneqiyigg
authored andcommitted
docs(page-objects.md): Refactor the existing Page Object example (#4576)
* 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.
1 parent a62efc6 commit 8d71a1b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/page-objects.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('angularjs homepage', function() {
1919
});
2020
```
2121

22-
With PageObjects
22+
With Page Objects
2323
----------------
2424

2525
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:
@@ -41,13 +41,16 @@ var AngularHomepage = function() {
4141
return greeting.getText();
4242
};
4343
};
44+
module.exports = new AngularHomepage();
4445
```
45-
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).
46+
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).
47+
48+
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.
4649

4750
```js
51+
var angularHomepage = require('./AngularHomepage');
4852
describe('angularjs homepage', function() {
4953
it('should greet the named user', function() {
50-
var angularHomepage = new AngularHomepage();
5154
angularHomepage.get();
5255

5356
angularHomepage.setName('Julie');

0 commit comments

Comments
 (0)