UNPKG

3.62 kBMarkdownView Raw
1# How to run
2
3* `gulp test --env dev --tags "@debug"`
4
5# Page Objects
6##Page Map
7```javascript
8const AbstractPageMap = require("protractor-boilerplate").AbstractPageMap;
9const LoginPage = require("./page/LoginPage");
10
11class PageMap extends AbstractPageMap {
12
13 constructor() {
14 super();
15
16 this.definePage("Login", "^.+))$", LoginPage);
17
18 }
19
20}
21```
22###Methods
23* definePage
24
25| param | mandatory | description |
26|--------|-----------|---------------------------------|
27| alias | M | alias of the page |
28| regexp | M | regexp of URL to determine page |
29| clazz | M | page class |
30
31##Page
32```javascript
33const Page = require("protractor-boilerplate").AbstractPage;
34const CustomComponent = require("./CustomComponent");
35
36class CustomPage extends Page {
37
38 constructor() {
39 super();
40
41 this.defineComponent("Custom Component", new CustomComponent());
42 this.defineElement("Custom Element", "h3");
43 this.defineCollection("Custom Collection", "h3.button");
44 }
45
46}
47```
48###Methods
49* defineComponent
50
51| param | mandatory | description |
52|-----------|-----------|------------------------|
53| alias | M | alias of the component |
54| component | M | component object |
55
56* defineElement
57
58| param | mandatory | description |
59|----------|-----------|-------------------------|
60| alias | M | alias of the component |
61| selector | M | css selector of element |
62
63* defineCollection
64
65| param | mandatory | description |
66|----------|-----------|-------------------------|
67| alias | M | alias of the component |
68| selector | M | css selector of element |
69
70##Component
71```javascript
72const Component = require("protractor-boilerplate").Component;
73
74class CustomComponent extends Component {
75
76 constructor(alias = "Dashboard", selector = ".div", isCollection = false) {
77 super(alias, selector, isCollection);
78
79 this.defineComponent("Custom Component", new CustomComponent());
80 this.defineElement("Custom Element", "h3");
81 this.defineCollection("Custom Collection", "h3.button");
82 }
83
84}
85```
86###Methods
87* constructor
88
89| param | mandatory | description |
90|--------------|-----------|-------------------------|
91| alias | M | alias of the component |
92| selector | M | css selector of element |
93| isCollection | M | isCollection flag |
94
95* defineComponent
96
97| param | mandatory | description |
98|-----------|-----------|------------------------|
99| alias | M | alias of the component |
100| component | M | component object |
101
102* defineElement
103
104| param | mandatory | description |
105|----------|-----------|-------------------------|
106| alias | M | alias of the component |
107| selector | M | css selector of element |
108
109* defineCollection
110
111| param | mandatory | description |
112|----------|-----------|-------------------------|
113| alias | M | alias of the component |
114| selector | M | css selector of element |
115
116# Memory
117##Memory
118
119```javascript
120const Memory = require("protractor-boilerplate").Memory;
121
122defineSupportCode(({setDefaultTimeout, When}) => {
123
124 When(/^I remember "(.+)" value as "(.+)"$/, (alias, key) => {
125 const page = State.getPage();
126
127 return page.getElement(alias).getText()
128 .then((text) => {
129 Memory.setValue(key, text);
130 })
131 });
132}
133```
134
135###Methods
136* setValue
137
138| param | mandatory | description |
139|--------------|-----------|----------------------|
140| key | M | key of stored item |
141| value | M | value of stored item |
142
143* parseValue
144returns value by provided key, otherwise returns key
145
146| param | mandatory | description |
147|--------------|-----------|-----------------------|
148| value | M | a key or simple value |
\No newline at end of file