Skip to content

Commit

Permalink
Updated documentation - changed export in Page Objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tgorskievo committed Oct 10, 2017
1 parent 0e1b00c commit ace3889
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- updated libs (e.g. cucumber js)
- `isExternal` is no longer required in Page Objects (Angular)
- locators are no longer supported in Page Objects
- export `module.exports` has been changed in Page Objects
- removed `| element | value |` headers from first row in a steps
- `.gitkeep` is automatically created in reports catalog
- `RELOAD_FIXTURES_URL` has been moved to advanced configuration
Expand Down
15 changes: 14 additions & 1 deletion MIGRATION-2.0.MD
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,20 @@ class ExamplePage extends BasePage {
}
```
4. Change `dictionaries`, example:
4. Change `exports` in Page Objects:
The last line in each of the page objects
```javascript
module.exports = new ExamplePage();
```
needs to be changed to:
```javascript
module.exports = ExamplePage;
```
5. Change `dictionaries`, example:
```javascript
const { dictionaries } = require('kakunin');

Expand Down
2 changes: 1 addition & 1 deletion docs-src/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class MyPageObject extends BasePage {
}
}

module.exports = new MyPageObject();
module.exports = MyPageObject;
```

### Matchers
Expand Down
10 changes: 5 additions & 5 deletions docs-src/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DashboardPage extends BasePage {
}
}

module.exports = new DashboardPage();
module.exports = DashboardPage;
```

As you can see a basic Page Object must extend one of the Kakunin's Objects and needs to have url field defined (`this.url`).
Expand Down Expand Up @@ -95,23 +95,23 @@ Defining elements is very simple. Let's say we have such page object:
```
const { BasePage } = require('kakunin');
class DashboardPage extends FromPage {
class DashboardPage extends BasePage {
constructor() {
super();
this.url = '/dashboard';
}
}
module.exports = new DashboardPage();
module.exports = DashboardPage;
```

Elements should be defined inside `constructor` method. Let's add element for `myName`:

```
const { BasePage } = require('kakunin');
class DashboardPage extends FromPage {
class DashboardPage extends BasePage {
constructor() {
super();
Expand All @@ -121,7 +121,7 @@ class DashboardPage extends FromPage {
}
}
module.exports = new DashboardPage();
module.exports = DashboardPage;
```

As you see we added a single line `this.myName = element(by.css('.myName'));`.
Expand Down
2 changes: 1 addition & 1 deletion docs-src/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class MainPage extends BasePage {
}
}
module.exports = new MainPage();
module.exports = MainPage;
```
Now that we have prepared the locators, we can start writing our test. Let's test adding new todo item.
Expand Down
2 changes: 1 addition & 1 deletion docs/extending/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ <h3 id="page-objects">Page objects</h3>
<span class="p">}</span>
<span class="p">}</span>

<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">MyPageObject</span><span class="p">();</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">MyPageObject</span><span class="p">;</span>
</pre></div>


Expand Down
10 changes: 5 additions & 5 deletions docs/how-it-works/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ <h3 id="page-objects">Page objects</h3>
<span class="p">}</span>
<span class="p">}</span>

<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">DashboardPage</span><span class="p">();</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">DashboardPage</span><span class="p">;</span>
</pre></div>


Expand Down Expand Up @@ -477,22 +477,22 @@ <h3 id="elements-and-locators">Elements and locators</h3>
<p>Defining elements is very simple. Let's say we have such page object:</p>
<div class="codehilite"><pre><span></span><span class="kr">const</span> <span class="p">{</span> <span class="nx">BasePage</span> <span class="p">}</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;kakunin&#39;</span><span class="p">);</span>

<span class="kr">class</span> <span class="nx">DashboardPage</span> <span class="kr">extends</span> <span class="nx">FromPage</span> <span class="p">{</span>
<span class="kr">class</span> <span class="nx">DashboardPage</span> <span class="kr">extends</span> <span class="nx">BasePage</span> <span class="p">{</span>
<span class="kr">constructor</span><span class="p">()</span> <span class="p">{</span>
<span class="kr">super</span><span class="p">();</span>

<span class="k">this</span><span class="p">.</span><span class="nx">url</span> <span class="o">=</span> <span class="s1">&#39;/dashboard&#39;</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>

<span class="kr">module</span><span class="nx">.exports</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">DashboardPage</span><span class="p">();</span>
<span class="kr">module</span><span class="nx">.exports</span> <span class="o">=</span> <span class="nx">DashboardPage</span><span class="p">;</span>
</pre></div>


<p>Elements should be defined inside <code>constructor</code> method. Let's add element for <code>myName</code>:</p>
<div class="codehilite"><pre><span></span><span class="kr">const</span> <span class="p">{</span> <span class="nx">BasePage</span> <span class="p">}</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;kakunin&#39;</span><span class="p">);</span>

<span class="kr">class</span> <span class="nx">DashboardPage</span> <span class="kr">extends</span> <span class="nx">FromPage</span> <span class="p">{</span>
<span class="kr">class</span> <span class="nx">DashboardPage</span> <span class="kr">extends</span> <span class="nx">BasePage</span> <span class="p">{</span>
<span class="kr">constructor</span><span class="p">()</span> <span class="p">{</span>
<span class="kr">super</span><span class="p">();</span>

Expand All @@ -502,7 +502,7 @@ <h3 id="elements-and-locators">Elements and locators</h3>
<span class="p">}</span>
<span class="p">}</span>

<span class="kr">module</span><span class="nx">.exports</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">DashboardPage</span><span class="p">();</span>
<span class="kr">module</span><span class="nx">.exports</span> <span class="o">=</span> <span class="nx">DashboardPage</span><span class="p">;</span>
</pre></div>


Expand Down
Loading

0 comments on commit ace3889

Please sign in to comment.