webship-js 1.0.13 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/about-us.html +1 -0
- package/examples/index.html +3 -2
- package/examples/test--then--the-element-should_not-contain-cssproperty.html +47 -0
- package/examples/test--when--i-press-button.html +2 -1
- package/lib/custom-assertions/smartElementContainsCss.js +62 -0
- package/lib/custom-commands/smartCheckItem.js +5 -5
- package/lib/custom-commands/smartFillTextInput.js +56 -0
- package/lib/custom-commands/smartLinkClick.js +12 -0
- package/lib/custom-commands/smartPressButton.js +12 -0
- package/lib/custom-commands/smartUncheckItem.js +0 -6
- package/nightwatch.conf.js +1 -0
- package/package.json +1 -1
- package/tests/features/test--then--i-should-see-an-element.feature +9 -0
- package/tests/features/test--then--i-should-see-text-matching.feature +8 -0
- package/tests/features/test--then--the-element-should_not-contain-cssproperty.feature +12 -0
- package/tests/step-definitions/webship.js +52 -12
- package/lib/get-element.js +0 -65
- package/tests/reports/cucumber-report.html +0 -48
- package/tests/reports/cucumber-report.json +0 -66
package/examples/about-us.html
CHANGED
package/examples/index.html
CHANGED
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
<li><a href="test--when--i-reload-page.html">When I go reload page</a></li>
|
|
20
20
|
<li><a href="test--when--i-follow-link.html">When I go follow "link"</a></li>
|
|
21
21
|
<li><a href="test--when--i-fill-in.html">When I fill in input text with value</a></li>
|
|
22
|
-
<li><a href="test--when--i-select-option-from-
|
|
23
|
-
<li><a href="test--then--i-should--not--see-text-in-element.html">
|
|
22
|
+
<li><a href="test--when--i-select-option-from-selectbox.html">When I select option from select box</a></li>
|
|
23
|
+
<li><a href="test--then--i-should--not--see-text-in-element.html">Then I sould (not) see test in element</a></li>
|
|
24
|
+
<li><a href="test--then--the-element-should_not-contain-cssproperty.html">Then the element should (not) contain css property</a></li>
|
|
24
25
|
</ul>
|
|
25
26
|
<script src="main.js"></script>
|
|
26
27
|
</body>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<title>Press Button</title>
|
|
6
|
+
<style>
|
|
7
|
+
.container,
|
|
8
|
+
.container input,
|
|
9
|
+
.container button{
|
|
10
|
+
font-size: 26px;
|
|
11
|
+
}
|
|
12
|
+
body{
|
|
13
|
+
background-color: lightcoral;
|
|
14
|
+
}
|
|
15
|
+
.unamecss{
|
|
16
|
+
border: solid 5px red;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
</style>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
function onClick(){
|
|
23
|
+
const username = document.getElementById("uname");
|
|
24
|
+
username.style.borderColor = "green";
|
|
25
|
+
document.body.style.backgroundColor = "white";
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<h1>Login</h1>
|
|
32
|
+
|
|
33
|
+
<div class="container">
|
|
34
|
+
<p><label for="uname"><b>Username</b></label></p>
|
|
35
|
+
<p><input id="uname" class="unamecss" type="text" placeholder="Enter Username" name="username"></p>
|
|
36
|
+
|
|
37
|
+
<p><label for="pword"><b>Password</b></label></p>
|
|
38
|
+
<p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
|
|
39
|
+
|
|
40
|
+
<p><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Submit" onclick="onClick()"></p>
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div id="result" class="style"></div><br/>
|
|
45
|
+
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
<body>
|
|
23
23
|
<h1>Press Button</h1>
|
|
24
24
|
<div id="result" class="style"></div><br/>
|
|
25
|
-
<
|
|
25
|
+
<label for="btnClickid">Press button</label>
|
|
26
|
+
<input id="btnClickid" class="btnClickclass" name="btnClickname" type="button" value="Click Button" onclick="onClick()">
|
|
26
27
|
</body>
|
|
27
28
|
</html>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.assertion = function (element, negativeCase, elementCss) {
|
|
3
|
+
|
|
4
|
+
elementCss = elementCss.replace(";", '');
|
|
5
|
+
const cssPropertyArr = elementCss.split(":");
|
|
6
|
+
|
|
7
|
+
const cssProperty = cssPropertyArr[0].trim();
|
|
8
|
+
const propertyVal = cssPropertyArr[1].trim();
|
|
9
|
+
|
|
10
|
+
browser.element('css selector', element, function (result) {
|
|
11
|
+
if (result.status === 0) {
|
|
12
|
+
if (negativeCase) {
|
|
13
|
+
return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
14
|
+
}
|
|
15
|
+
return browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
16
|
+
} else {
|
|
17
|
+
browser.element('css selector', '#' + element, function (result) {
|
|
18
|
+
if (result.status === 0) {
|
|
19
|
+
if (negativeCase) {
|
|
20
|
+
return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
21
|
+
}
|
|
22
|
+
return browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
23
|
+
} else {
|
|
24
|
+
browser.element('css selector', 'input[name="' + element + '"]', function (result) {
|
|
25
|
+
if (result.status === 0) {
|
|
26
|
+
if (negativeCase) {
|
|
27
|
+
return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
28
|
+
}
|
|
29
|
+
return browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
30
|
+
} else {
|
|
31
|
+
browser.element('css selector', 'input[value="' + element + '"]', function (result) {
|
|
32
|
+
if (result.status === 0) {
|
|
33
|
+
if (negativeCase) {
|
|
34
|
+
return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
35
|
+
}
|
|
36
|
+
return browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
37
|
+
} else {
|
|
38
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
39
|
+
elements.value.forEach(function (elementsObj) {
|
|
40
|
+
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
41
|
+
if (result.value == element) {
|
|
42
|
+
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
43
|
+
|
|
44
|
+
console.log('#' + forVal.value, cssProperty, propertyVal);
|
|
45
|
+
if (negativeCase) {
|
|
46
|
+
return browser.assert.not.cssProperty('#' + forVal.value, cssProperty, propertyVal);
|
|
47
|
+
}
|
|
48
|
+
return browser.assert.cssProperty('#' + forVal.value, cssProperty, propertyVal);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -3,26 +3,26 @@ module.exports.command = function (item) {
|
|
|
3
3
|
|
|
4
4
|
browser.element('css selector', item, function (result) {
|
|
5
5
|
if (result.status === 0) {
|
|
6
|
-
return browser.
|
|
6
|
+
return browser.click(item);
|
|
7
7
|
} else {
|
|
8
8
|
browser.element('css selector', '#' + item, function (result) {
|
|
9
9
|
if (result.status === 0) {
|
|
10
|
-
return browser.
|
|
10
|
+
return browser.click('#' + item);
|
|
11
11
|
} else {
|
|
12
12
|
browser.element('css selector', 'input[name="' + item + '"]', function (result) {
|
|
13
13
|
if (result.status === 0) {
|
|
14
|
-
return browser.
|
|
14
|
+
return browser.click('input[name="' + item + '"]');
|
|
15
15
|
} else {
|
|
16
16
|
browser.element('css selector', 'input[value="' + item + '"]', function (result) {
|
|
17
17
|
if (result.status === 0) {
|
|
18
|
-
return browser.
|
|
18
|
+
return browser.click('input[value="' + item + '"]');
|
|
19
19
|
} else {
|
|
20
20
|
browser.elements('css selector', 'label', function (elements) {
|
|
21
21
|
elements.value.forEach(function (elementsObj) {
|
|
22
22
|
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
23
23
|
if (result.value == item) {
|
|
24
24
|
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
25
|
-
return browser.
|
|
25
|
+
return browser.click('#' + forVal.value);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module.exports.command = function (field, value) {
|
|
2
|
+
let element = null;
|
|
3
|
+
let selector = field;
|
|
4
|
+
|
|
5
|
+
browser.element('css selector', selector, function (result) {
|
|
6
|
+
if (result.status == 0) {
|
|
7
|
+
return browser.setValue(selector, value);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
selector = '#' + field;
|
|
11
|
+
browser.element('css selector', selector, function (result) {
|
|
12
|
+
if (result.status == 0) {
|
|
13
|
+
return browser.setValue(selector, value);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
selector = '.' + field;
|
|
17
|
+
browser.element('css selector', selector, function (result) {
|
|
18
|
+
if (result.status == 0) {
|
|
19
|
+
return browser.setValue(selector, value);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
selector = 'input[name=' + field + ']';
|
|
23
|
+
browser.element('css selector', selector, function (result) {
|
|
24
|
+
if (result.status == 0) {
|
|
25
|
+
return browser.setValue(selector, value);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
selector = "input[placeholder='" + field + "']";
|
|
29
|
+
browser.element('css selector', selector, function (result) {
|
|
30
|
+
if (result.status == 0) {
|
|
31
|
+
return browser.setValue(selector, value);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
35
|
+
for (let i = 0; i < elements.value.length; i++) {
|
|
36
|
+
this.elementIdText(elements.value[i].ELEMENT, function (result) {
|
|
37
|
+
if (result.value === field) {
|
|
38
|
+
element = elements.value[i].ELEMENT;
|
|
39
|
+
browser.elementIdAttribute(element, 'for', function (eleAttribute) {
|
|
40
|
+
return browser.setValue('#' + eleAttribute.value, value);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.command = function (elementValue) {
|
|
3
|
+
|
|
4
|
+
browser.element('css selector', elementValue, function (result) {
|
|
5
|
+
if (result.status === 0) {
|
|
6
|
+
return browser.click(elementValue);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
browser.click("link text", elementValue);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.command = function (elementValue) {
|
|
3
|
+
|
|
4
|
+
browser.element('css selector', elementValue, function (result) {
|
|
5
|
+
if (result.status === 0) {
|
|
6
|
+
return browser.click(elementValue);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
return browser.click("[value='" + elementValue + "']");
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -3,23 +3,18 @@ module.exports.command = function (item) {
|
|
|
3
3
|
|
|
4
4
|
browser.element('css selector', item, function (result) {
|
|
5
5
|
if (result.status === 0) {
|
|
6
|
-
browser.setAttribute(item, 'checked', false);
|
|
7
6
|
return browser.click(item);
|
|
8
7
|
} else {
|
|
9
8
|
browser.element('css selector', '#' + item, function (result) {
|
|
10
9
|
if (result.status === 0) {
|
|
11
|
-
browser.setAttribute('#' + item, 'checked', false);
|
|
12
10
|
return browser.click('#' + item);
|
|
13
11
|
} else {
|
|
14
12
|
browser.element('css selector', 'input[name=' + item + ']', function (result) {
|
|
15
13
|
if (result.status === 0) {
|
|
16
|
-
browser.setAttribute('input[name=' + item + ']', 'checked', false);
|
|
17
14
|
return browser.click('input[name=' + item + ']');
|
|
18
|
-
|
|
19
15
|
} else {
|
|
20
16
|
browser.element('css selector', 'input[value="' + item + '"]', function (result) {
|
|
21
17
|
if (result.status === 0) {
|
|
22
|
-
browser.setAttribute('input[value="' + item + '"]', 'checked', false);
|
|
23
18
|
return browser.click('input[value="' + item + '"]');
|
|
24
19
|
} else {
|
|
25
20
|
browser.elements('css selector', 'label', function (elements) {
|
|
@@ -27,7 +22,6 @@ module.exports.command = function (item) {
|
|
|
27
22
|
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
28
23
|
if (result.value == item) {
|
|
29
24
|
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
30
|
-
browser.setAttribute('#' + forVal.value, 'checked', false);
|
|
31
25
|
return browser.click('#' + forVal.value);
|
|
32
26
|
});
|
|
33
27
|
}
|
package/nightwatch.conf.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Feature: Example test for "Then I should see an "element" element"
|
|
2
|
+
As a tester
|
|
3
|
+
I want to make sure that when I'm on a particular page, I should see a specific element
|
|
4
|
+
|
|
5
|
+
Scenario: Check "Then I should see an 'element' element" step definition
|
|
6
|
+
Given I am on the homepage
|
|
7
|
+
When I go to "about-us.html"
|
|
8
|
+
Then I should see a "body" element
|
|
9
|
+
And I should see a "#paragraphid" element
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Feature: Example test for I should see text matching "some text"
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to text matching in a page
|
|
4
|
+
|
|
5
|
+
Scenario: Check I should see text matching "some text"
|
|
6
|
+
Given I am on the homepage
|
|
7
|
+
When I go to "about-us.html"
|
|
8
|
+
Then I should see text matching "About Us"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Feature: Example test element contains Css property and property value expected
|
|
2
|
+
As a developer
|
|
3
|
+
I want to be able to test if element contains Css property and property value expected
|
|
4
|
+
|
|
5
|
+
Scenario: Check element if contains Css property and property value expected
|
|
6
|
+
Given I am on homepage
|
|
7
|
+
When I go to "test--then--the-element-should_not-contain-cssproperty.html"
|
|
8
|
+
Then the "body" element should contain "background-color: lightcoral;"
|
|
9
|
+
And the "Username" element should contain "border: solid 5px red;"
|
|
10
|
+
When I press "Submit"
|
|
11
|
+
Then the "body" element should contain "background-color: white;"
|
|
12
|
+
And the "Username" element should contain "border: solid 5px green;"
|
|
@@ -2,8 +2,6 @@ const { Given } = require('@cucumber/cucumber');
|
|
|
2
2
|
const { When, Before } = require('@cucumber/cucumber');
|
|
3
3
|
const { Then } = require('@cucumber/cucumber');
|
|
4
4
|
|
|
5
|
-
const lib = require('../../lib/get-element.js');
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* Opens homepage.
|
|
9
7
|
*
|
|
@@ -93,6 +91,7 @@ When(/^I move backward one page$/, function () {
|
|
|
93
91
|
*/
|
|
94
92
|
When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
95
93
|
return browser.click("[value='" + elementValue + "']");
|
|
94
|
+
// return browser.smartPressButton(elementValue);
|
|
96
95
|
});
|
|
97
96
|
|
|
98
97
|
/**
|
|
@@ -103,7 +102,8 @@ When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
|
103
102
|
* @When /^I follow "([^"]*)?"$/
|
|
104
103
|
*/
|
|
105
104
|
When(/^I follow "([^"]*)?"$/, function (elementValue) {
|
|
106
|
-
|
|
105
|
+
browser.click("link text", elementValue);
|
|
106
|
+
// return browser.smartLinkClick(elementValue);
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -124,7 +124,7 @@ When(/^I reload( the)* page$/, function (url) {
|
|
|
124
124
|
* @When /^I fill in "([^"]*)?" with "([^"]*)?"$/
|
|
125
125
|
*/
|
|
126
126
|
When(/^I fill in "([^"]*)?" with "([^"]*)?"$/, function (field, value) {
|
|
127
|
-
|
|
127
|
+
browser.smartFillTextInput(field, value);
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
/**
|
|
@@ -134,7 +134,7 @@ When(/^I fill in "([^"]*)?" with "([^"]*)?"$/, function (field, value) {
|
|
|
134
134
|
* @When /^I fill in "([^"]*)?" with:$/
|
|
135
135
|
*/
|
|
136
136
|
When(/^I fill in "([^"]*)?" with:$/, function (field) {
|
|
137
|
-
|
|
137
|
+
browser.smartFillTextInput(field, '');
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
/**
|
|
@@ -144,7 +144,7 @@ When(/^I fill in "([^"]*)?" with:$/, function (field) {
|
|
|
144
144
|
* @When /^I fill in "([^"]*)?" for "([^"]*)?"$/
|
|
145
145
|
*/
|
|
146
146
|
When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
147
|
-
|
|
147
|
+
browser.smartFillTextInput(field, value);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
/**
|
|
@@ -160,9 +160,9 @@ When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
|
160
160
|
*/
|
|
161
161
|
When(/^I fill in the following:$/, function (table) {
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
browser.smartFillTextInput(table.rawTable[0][0], table.rawTable[0][1]);
|
|
164
164
|
table.rows().forEach(row => {
|
|
165
|
-
|
|
165
|
+
browser.smartFillTextInput(row[0], row[1]);
|
|
166
166
|
});
|
|
167
167
|
});
|
|
168
168
|
|
|
@@ -174,7 +174,7 @@ When(/^I fill in the following:$/, function (table) {
|
|
|
174
174
|
* @When /^I select "([^"]*)?" from "([^"]*)?"$/
|
|
175
175
|
*/
|
|
176
176
|
When(/^I select "([^"]*)?" from "([^"]*)?"$/, function (option, selectBox) {
|
|
177
|
-
browser.
|
|
177
|
+
browser.smartSelectOption(option, selectBox);
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
/**
|
|
@@ -207,7 +207,7 @@ When(/^I uncheck "([^"]*)?"$/, function (item) {
|
|
|
207
207
|
* @Then /^I should be on( the)* homepage$/
|
|
208
208
|
*/
|
|
209
209
|
Then(/^I should be on( the)* homepage$/, function (url) {
|
|
210
|
-
|
|
210
|
+
return browser.assert.urlEquals(browser.launch_url);
|
|
211
211
|
});
|
|
212
212
|
|
|
213
213
|
/**
|
|
@@ -245,5 +245,45 @@ Then(/^the response should( not)* contain "([^"]*)?"$/, function (negativeCase,
|
|
|
245
245
|
* @Then /^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/
|
|
246
246
|
*/
|
|
247
247
|
Then(/^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/, function (negativeCase, expectedText, element) {
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
return browser.assert.smartElementContains(negativeCase, expectedText, element);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Checks, that page contains text matching specified pattern
|
|
253
|
+
* Example: Then I should see text matching "Bruce Wayne, the vigilante"
|
|
254
|
+
* Example: And I should not see "Bruce Wayne, the vigilante"
|
|
255
|
+
*
|
|
256
|
+
* @Then /^I should( not)* see text matching "([^"]*)?"$/
|
|
257
|
+
*/
|
|
258
|
+
Then(/^I should( not)* see text matching "([^"]*)?"$/, function (negativeCase, expectedText) {
|
|
259
|
+
if (negativeCase) {
|
|
260
|
+
return browser.assert.not.textContains('html', expectedText);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return browser.assert.textContains('html', expectedText);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Checks, that element with specified CSS exists on page
|
|
268
|
+
* Example: Then I should see a "body" element
|
|
269
|
+
* Example: And I should see a "body" element
|
|
270
|
+
*
|
|
271
|
+
* @Then /^I should( not)* see a(n)* "([^"]*)?" element$/
|
|
272
|
+
*/
|
|
273
|
+
Then(/^I should( not)* see a(n)* "([^"]*)?" element$/, function (negativeCase, identification, element) {
|
|
274
|
+
if (negativeCase) {
|
|
275
|
+
return browser.verify.not.visible(element);
|
|
276
|
+
}
|
|
277
|
+
return browser.verify.visible(element);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Checks, that element with specified CSS contains specified HTML
|
|
282
|
+
* Example: Then the "body" element should contain "color:black;"
|
|
283
|
+
* Example: And the "body" element should contain "color:black;"
|
|
284
|
+
*
|
|
285
|
+
* @Then /^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/
|
|
286
|
+
*/
|
|
287
|
+
Then(/^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/, function (element, negativeCase, elementCss) {
|
|
288
|
+
return browser.assert.smartElementContainsCss(element, negativeCase, elementCss);
|
|
289
|
+
});
|
package/lib/get-element.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
/**
|
|
3
|
-
* Fill the Input Box With the Value
|
|
4
|
-
*
|
|
5
|
-
* Function to find input by
|
|
6
|
-
* id|class|name|placeholder|label
|
|
7
|
-
* and fill it with sent value
|
|
8
|
-
*/
|
|
9
|
-
fillInputWithValue: function (field, value) {
|
|
10
|
-
let element = null;
|
|
11
|
-
let selector = field;
|
|
12
|
-
|
|
13
|
-
browser.element('css selector', selector, function(result){
|
|
14
|
-
if(result.status == 0){
|
|
15
|
-
return browser.setValue(selector, value);
|
|
16
|
-
}
|
|
17
|
-
else{
|
|
18
|
-
selector = '#' + field;
|
|
19
|
-
browser.element('css selector', selector, function(result){
|
|
20
|
-
if(result.status == 0){
|
|
21
|
-
return browser.setValue(selector, value);
|
|
22
|
-
}
|
|
23
|
-
else{
|
|
24
|
-
selector = '.' + field;
|
|
25
|
-
browser.element('css selector', selector, function(result){
|
|
26
|
-
if(result.status == 0){
|
|
27
|
-
return browser.setValue(selector, value);
|
|
28
|
-
}
|
|
29
|
-
else{
|
|
30
|
-
selector = 'input[name=' + field + ']';
|
|
31
|
-
browser.element('css selector', selector, function(result){
|
|
32
|
-
if(result.status == 0){
|
|
33
|
-
return browser.setValue(selector, value);
|
|
34
|
-
}
|
|
35
|
-
else{
|
|
36
|
-
selector = "input[placeholder='" + field + "']";
|
|
37
|
-
browser.element('css selector', selector, function(result){
|
|
38
|
-
if(result.status == 0){
|
|
39
|
-
return browser.setValue(selector, value);
|
|
40
|
-
}
|
|
41
|
-
else{
|
|
42
|
-
browser.elements('css selector', 'label', function (elements) {
|
|
43
|
-
for (let i = 0; i < elements.value.length; i++) {
|
|
44
|
-
this.elementIdText(elements.value[i].ELEMENT, function (result) {
|
|
45
|
-
if (result.value === field) {
|
|
46
|
-
element = elements.value[i].ELEMENT;
|
|
47
|
-
browser.elementIdAttribute(element, 'for', function(eleAttribute){
|
|
48
|
-
return browser.setValue('#' + eleAttribute.value, value);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
};
|