You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/page-objects.md
+48-4
Original file line number
Diff line number
Diff line change
@@ -36,13 +36,42 @@ var AngularHomepage = function() {
36
36
this.setName=function(name) {
37
37
nameInput.sendKeys(name);
38
38
};
39
-
40
-
this.getGreeting=function() {
39
+
40
+
this.getGreetingText=function() {
41
41
returngreeting.getText();
42
42
};
43
43
};
44
44
module.exports=newAngularHomepage();
45
45
```
46
+
47
+
Or, if using `async / await`, something like this: (Note that functions
48
+
that don't use `await` shouldn't have the `async` prefix.)
49
+
50
+
```js
51
+
varAngularHomepage=function() {
52
+
var nameInput =element(by.model('yourName'));
53
+
var greeting =element(by.binding('yourName'));
54
+
55
+
this.get=asyncfunction() {
56
+
awaitbrowser.get('http://www.angularjs.org');
57
+
};
58
+
59
+
this.setName=asyncfunction(name) {
60
+
awaitnameInput.sendKeys(name);
61
+
};
62
+
63
+
this.getGreetingText=asyncfunction() {
64
+
returnawaitgreeting.getText();
65
+
};
66
+
67
+
// Not async, returns the element
68
+
this.getGreeting=function() {
69
+
return greeting;
70
+
};
71
+
};
72
+
module.exports=newAngularHomepage();
73
+
```
74
+
46
75
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
76
48
77
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.
0 commit comments