webship-js 1.0.20 → 1.0.23
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/.circleci/config.yml +10 -7
- package/.github/workflows/github-actions.yml +7 -4
- package/.gitlab-ci.yml +23 -35
- package/CNAME +1 -0
- package/bitbucket-pipelines.yml +26 -0
- package/examples/example-api.json +28 -0
- package/examples/existing-page.html +11 -0
- package/examples/index.html +1 -1
- package/examples/test--then--i-should--not--see-text-in-element.html +1 -1
- package/examples/test--then--i-should--see-text-matching-pattern.html +31 -0
- package/examples/test--when--i-press-button.html +1 -1
- package/examples/test--when--i-reload-page.html +1 -1
- package/examples/test-acceptable-url-path.html +11 -0
- package/generate-reports.js +1 -1
- package/lib/custom-assertions/backToHomepage.js +15 -0
- package/lib/custom-assertions/{smartCheckboxChecked.js → checkboxChecked.js} +10 -10
- package/lib/custom-assertions/{smartElementContainsCss.js → elementContainsCss.js} +10 -10
- package/lib/custom-assertions/{smartElementContains.js → elementContainsText.js} +10 -10
- package/lib/custom-assertions/responseStatus.js +13 -0
- package/lib/custom-assertions/shouldVisible.js +8 -0
- package/lib/custom-assertions/textMatching.js +12 -0
- package/lib/custom-commands/{smartUploadFile.js → fileUpload.js} +0 -1
- package/lib/custom-commands/press.js +3 -0
- package/lib/custom-commands/{smartSelectOption.js → selectOption.js} +8 -8
- package/lib/custom-commands/wait.js +12 -0
- package/nightwatch.conf.js +2 -2
- package/package.json +5 -6
- package/tests/features/test--given--i-am-on-homepage.feature +11 -7
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +12 -8
- package/tests/features/test--then--i-should--see-text-matching-pattern-in-element.feature +18 -0
- package/tests/features/test--then--i-should--see-text-matching-pattern.feature +18 -0
- package/tests/features/test--then--i-should-be-on-page.feature +7 -7
- package/tests/features/test--then--i-should-be-on-the-homepage.feature +5 -4
- package/tests/features/test--then--i-should-see-an-element.feature +4 -5
- package/tests/features/test--then--the-checkbox-is-checked.feature +18 -0
- package/tests/features/test--then--the-checkbox-should-be-checked.feature +16 -0
- package/tests/features/test--then--the-element-should_not-contain-cssproperty.feature +11 -8
- package/tests/features/test--then--the-field-should-contain-value.feature +3 -4
- package/tests/features/test--then--the-response-should-contain.feature +3 -3
- package/tests/features/test--then--the-response-status-code-should-be.feature +31 -0
- package/tests/features/test--then--the-url-should-match.feature +7 -0
- package/tests/features/test--when--i-attach-file-to-feild.feature +5 -5
- package/tests/features/test--when--i-check-checkbox.feature +4 -4
- package/tests/features/test--when--i-click-link.feature +6 -7
- package/tests/features/test--when--i-fill-in.feature +13 -18
- package/tests/features/test--when--i-move-forward-backward-one-page.feature +8 -7
- package/tests/features/test--when--i-press-button.feature +7 -9
- package/tests/features/test--when--i-reload-page.feature +5 -7
- package/tests/features/test--when--i-select-option-from-dropdownlist.feature +12 -0
- package/tests/features/test--when--i-uncheck-checkbox.feature +5 -7
- package/tests/features/test--when--i-wait-time.feature +2 -2
- package/tests/step-definitions/webship.js +180 -189
- package/bitbucket-pipelines-test.yml +0 -34
- package/lib/custom-commands/smartPressButton.js +0 -12
- package/tests/features/test--then--i-should-see-text-matching.feature +0 -8
- package/tests/features/test--then--the-checkbox-checked.feature +0 -16
- package/tests/features/test--when--i-select-option-from-selectbox.feature +0 -13
- /package/examples/{test--when--i-select-option-from-selectbox.html → test--when--i-select-option-from-dropdownlist.html} +0 -0
- /package/lib/custom-commands/{smartCheckItem.js → checkItem.js} +0 -0
- /package/lib/custom-commands/{smartClickLink.js → clickLink.js} +0 -0
- /package/lib/custom-commands/{smartFillTextInput.js → fillTextInput.js} +0 -0
- /package/lib/custom-commands/{smartUncheckItem.js → uncheckItem.js} +0 -0
package/.circleci/config.yml
CHANGED
|
@@ -27,7 +27,7 @@ commands:
|
|
|
27
27
|
- run:
|
|
28
28
|
name: Install node js
|
|
29
29
|
command: |
|
|
30
|
-
curl -sL https://deb.nodesource.com/
|
|
30
|
+
curl -sL https://deb.nodesource.com/setup_18.x | sudo bash -
|
|
31
31
|
sudo apt install -y nodejs
|
|
32
32
|
sudo npm install -g yarn
|
|
33
33
|
## Install Java.
|
|
@@ -43,14 +43,16 @@ commands:
|
|
|
43
43
|
sudo apt install libu2f-udev
|
|
44
44
|
sudo apt-get install libappindicator1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
|
|
45
45
|
export CHROME_BIN=/usr/bin/google-chrome
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
CHROME_VERSION="115.0.5790.110-1"
|
|
47
|
+
wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
|
|
48
|
+
sudo dpkg -i google-chrome-stable_${CHROME_VERSION}_amd64.deb
|
|
49
|
+
rm google-chrome-stable_${CHROME_VERSION}_amd64.deb
|
|
50
|
+
|
|
49
51
|
## Install/Update Chrome Driver.
|
|
50
52
|
- run:
|
|
51
53
|
name: Install/Update Chrome Driver
|
|
52
54
|
command: |
|
|
53
|
-
CHROME_DRIVER_VERSION
|
|
55
|
+
CHROME_DRIVER_VERSION=114.0.5735.90;
|
|
54
56
|
echo $CHROME_DRIVER_VERSION;
|
|
55
57
|
wget http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
|
|
56
58
|
unzip chromedriver_linux64.zip
|
|
@@ -62,9 +64,9 @@ commands:
|
|
|
62
64
|
- run:
|
|
63
65
|
name: Run Selenium Standalone server
|
|
64
66
|
command: |
|
|
65
|
-
if [[ ! -f /home/circleci/selenium-server-
|
|
67
|
+
if [[ ! -f /home/circleci/selenium-server-4.1.2.jar ]]; then wget -O /home/circleci/selenium-server-4.1.2.jar https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.1.0/selenium-server-4.1.2.jar; fi
|
|
66
68
|
cd /home/circleci/
|
|
67
|
-
java -jar selenium-server-
|
|
69
|
+
java -jar selenium-server-4.1.2.jar standalone
|
|
68
70
|
background: true
|
|
69
71
|
|
|
70
72
|
jobs:
|
|
@@ -84,6 +86,7 @@ jobs:
|
|
|
84
86
|
- run:
|
|
85
87
|
name: Start virtual server
|
|
86
88
|
command: |
|
|
89
|
+
export NODE_OPTIONS=--openssl-legacy-provider
|
|
87
90
|
yarn start
|
|
88
91
|
background: true
|
|
89
92
|
- run:
|
|
@@ -14,18 +14,21 @@ jobs:
|
|
|
14
14
|
steps:
|
|
15
15
|
- name: Install Chrome
|
|
16
16
|
run: |
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
CHROME_VERSION="117.0.5938.92-1"
|
|
18
|
+
wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
|
|
19
|
+
sudo dpkg -i google-chrome-stable_${CHROME_VERSION}_amd64.deb
|
|
19
20
|
- uses: actions/checkout@v3
|
|
20
21
|
- name: Use Node.js
|
|
21
22
|
uses: actions/setup-node@v3
|
|
22
23
|
with:
|
|
23
|
-
node-version: '
|
|
24
|
+
node-version: '18.x'
|
|
24
25
|
- name: Install
|
|
25
26
|
run: yarn install
|
|
26
27
|
- name: Configure nightwatch.conf.js for Github
|
|
27
28
|
run: node webship-init -ci github -os linux -b chrome
|
|
28
29
|
- name: Start
|
|
29
|
-
run:
|
|
30
|
+
run: |
|
|
31
|
+
export NODE_OPTIONS=--openssl-legacy-provider
|
|
32
|
+
yarn start &
|
|
30
33
|
- name: Test
|
|
31
34
|
run: yarn test
|
package/.gitlab-ci.yml
CHANGED
|
@@ -1,52 +1,40 @@
|
|
|
1
1
|
image: node:16
|
|
2
2
|
|
|
3
3
|
stages:
|
|
4
|
-
-
|
|
4
|
+
- setup
|
|
5
|
+
- test
|
|
5
6
|
|
|
6
7
|
check:
|
|
7
|
-
stage:
|
|
8
|
+
stage: setup
|
|
8
9
|
script:
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
- apt-get
|
|
12
|
-
- apt-get --yes install libnss3
|
|
13
|
-
- apt-get --yes install libgconf-2-4
|
|
10
|
+
# Install Node.js and yarn
|
|
11
|
+
- apt-get update -qy
|
|
12
|
+
- apt-get install -y nodejs yarn
|
|
14
13
|
|
|
15
|
-
# Install
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
- apt-get install -y google-chrome-stable
|
|
14
|
+
# Install Google Chrome and Chromedriver
|
|
15
|
+
- apt-get install -y wget unzip
|
|
16
|
+
- wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
17
|
+
- dpkg -i google-chrome*.deb
|
|
18
|
+
- apt-get -f install -y
|
|
19
|
+
- CHROMEDRIVER_VERSION=$(curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
|
|
20
|
+
- wget -q https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip
|
|
21
|
+
- unzip chromedriver_linux64.zip
|
|
22
|
+
- mv chromedriver /usr/local/bin/
|
|
23
|
+
- chmod +x /usr/local/bin/chromedriver
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
# The `&` at the end causes it to run in the background and not block the following commands
|
|
32
|
-
- nohup chromedriver --port=4444 --url-base=wd/hub &
|
|
33
|
-
- nohup gitlab-selenium-server &
|
|
34
|
-
# Install cucumber & pretty formatter .
|
|
35
|
-
- npm i @cucumber/cucumber
|
|
36
|
-
- npm i @cucumber/pretty-formatter
|
|
37
|
-
|
|
38
|
-
# Run your tests
|
|
39
|
-
- npm start
|
|
40
|
-
- npm test
|
|
25
|
+
# Install dependencies and run Webpack
|
|
26
|
+
- yarn install
|
|
27
|
+
- yarn start
|
|
28
|
+
- yarn test
|
|
41
29
|
|
|
42
30
|
# Show the logs for the GitLab Selenium Server service
|
|
43
|
-
- mkdir -p selenium/ && curl -s http://localhost:
|
|
44
|
-
- mkdir -p selenium/ && curl http://localhost:
|
|
31
|
+
- mkdir -p selenium/ && curl -s http://localhost:8080/logs.tar.gz | tar -xvzf - -C selenium/
|
|
32
|
+
- mkdir -p selenium/ && curl http://localhost:8080/server-log --output selenium/server-log.txt
|
|
45
33
|
artifacts:
|
|
46
34
|
when: always
|
|
47
35
|
paths:
|
|
48
36
|
- selenium/
|
|
49
37
|
variables:
|
|
50
|
-
SELENIUM_REMOTE_URL: http://localhost:
|
|
38
|
+
SELENIUM_REMOTE_URL: http://localhost:8080
|
|
51
39
|
GITLAB_TARGET_SELENIUM_REMOTE_URL: http://localhost:4444/wd/hub
|
|
52
40
|
|
package/CNAME
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
webship.co
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
image: node:16 # Choose an appropriate Node.js version
|
|
2
|
+
|
|
3
|
+
pipelines:
|
|
4
|
+
default:
|
|
5
|
+
- step:
|
|
6
|
+
name: Install and Test
|
|
7
|
+
caches:
|
|
8
|
+
- node
|
|
9
|
+
script:
|
|
10
|
+
- npm install # Install your Node.js dependencies
|
|
11
|
+
- npm install selenium-webdriver --save # Install the Selenium WebDriver
|
|
12
|
+
- npm install chromedriver --save # Install ChromeDriver (for running tests in Chrome)
|
|
13
|
+
# Add other dependencies as needed
|
|
14
|
+
|
|
15
|
+
# Set up your test environment here (e.g., starting a server, configuring the application)
|
|
16
|
+
# For example, if you have a start script defined in your package.json:
|
|
17
|
+
# - npm run start & # Start your server in the background
|
|
18
|
+
|
|
19
|
+
# Run your tests here, assuming you have a test script defined in your package.json:
|
|
20
|
+
- yarn install
|
|
21
|
+
- yarn test
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [{
|
|
3
|
+
"type": "articles",
|
|
4
|
+
"id": "1",
|
|
5
|
+
"attributes": {
|
|
6
|
+
"title": "JSON:API paints my bikeshed!",
|
|
7
|
+
"body": "The shortest article. Ever.",
|
|
8
|
+
"created": "2015-05-22T14:56:29.000Z",
|
|
9
|
+
"updated": "2015-05-22T14:56:28.000Z"
|
|
10
|
+
},
|
|
11
|
+
"relationships": {
|
|
12
|
+
"author": {
|
|
13
|
+
"data": {"id": "42", "type": "people"}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}],
|
|
17
|
+
"included": [
|
|
18
|
+
{
|
|
19
|
+
"type": "people",
|
|
20
|
+
"id": "42",
|
|
21
|
+
"attributes": {
|
|
22
|
+
"name": "John",
|
|
23
|
+
"age": 80,
|
|
24
|
+
"gender": "male"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
package/examples/index.html
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
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-click-link.html">When I click "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-
|
|
22
|
+
<li><a href="test--when--i-select-option-from-dropdownlist.html">When I select option from select box</a></li>
|
|
23
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
24
|
<li><a href="test--then--the-element-should_not-contain-cssproperty.html">Then the element should (not) contain css property</a></li>
|
|
25
25
|
<li><a href="test--then--the-checkbox-checked.html">Then the checkbox (is/should be) (not) checked</a></li>
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
<p><label for="pword"><b>Password</b></label></p>
|
|
39
39
|
<p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
|
|
40
40
|
|
|
41
|
-
<p><input id="reset" type="reset" value="Reset"
|
|
41
|
+
<p><input id="reset" type="reset" value="Reset" /><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()" /></p>
|
|
42
42
|
|
|
43
43
|
</div>
|
|
44
44
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
|
+
<title>Text Matching Pattern</title>
|
|
7
|
+
<style>
|
|
8
|
+
.container,
|
|
9
|
+
.container input,
|
|
10
|
+
.container button {
|
|
11
|
+
font-size: 26px;
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
|
|
15
|
+
</head>
|
|
16
|
+
|
|
17
|
+
<body>
|
|
18
|
+
<h1>Text Matching Pattern</h1>
|
|
19
|
+
|
|
20
|
+
<div class="container">
|
|
21
|
+
<p>Email:</p><p>info@webship.co</p>
|
|
22
|
+
<p>Telephone:</p><p>0796-778899</p>
|
|
23
|
+
<p>Password conditions:</p><p>Pa$$word2023</p>
|
|
24
|
+
<div class="time"><p>Time:</p><p>10:30 AM</p></div>
|
|
25
|
+
<div id="date"><p>Date (Number):</p><p>22-03-2023</p></div>
|
|
26
|
+
<div id="countryCode"><p>Country code:</p><p id="ccode">JOR</p></div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
</body>
|
|
30
|
+
|
|
31
|
+
</html>
|
|
@@ -23,6 +23,6 @@
|
|
|
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="
|
|
26
|
+
<input id="btnClickid" class="btnClickclass" name="btnClickname" type="button" value="Submit" onclick="onClick()">
|
|
27
27
|
</body>
|
|
28
28
|
</html>
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
<body>
|
|
23
23
|
<h1>Press Button</h1>
|
|
24
24
|
<div id="result" class="style"></div><br/>
|
|
25
|
-
<input id="btnClick" class="btnClick" name="btnClick" type="button" value="
|
|
25
|
+
<input id="btnClick" class="btnClick" name="btnClick" type="button" value="Submit" onclick="onClick()">
|
|
26
26
|
</body>
|
|
27
27
|
</html>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
|
6
|
+
<title>Test Acceptable URL Path</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
Example for test acceptable URL path that have "-" between words.
|
|
10
|
+
</body>
|
|
11
|
+
</html>
|
package/generate-reports.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.assertion = function (negativeCase) {
|
|
3
|
+
|
|
4
|
+
browser.getCurrentUrl(function(result) {
|
|
5
|
+
var homepageUrl = browser.launch_url;
|
|
6
|
+
if(endsWith(result.value, "/")){
|
|
7
|
+
homepageUrl += "/";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (negativeCase) {
|
|
11
|
+
return browser.assert.not.urlEquals(homepageUrl).end();
|
|
12
|
+
}
|
|
13
|
+
return browser.assert.urlEquals(homepageUrl).end();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -4,30 +4,30 @@ module.exports.assertion = function (checkbox, negativeCase) {
|
|
|
4
4
|
browser.element('css selector', checkbox, function (result) {
|
|
5
5
|
if (result.status === 0) {
|
|
6
6
|
if (negativeCase) {
|
|
7
|
-
return browser.expect.element(checkbox).to.not.be.selected;
|
|
7
|
+
return browser.expect.element(checkbox).to.not.be.selected.end();
|
|
8
8
|
}
|
|
9
|
-
return browser.expect.element(checkbox).to.be.selected;
|
|
9
|
+
return browser.expect.element(checkbox).to.be.selected.end();
|
|
10
10
|
} else {
|
|
11
11
|
browser.element('css selector', '#' + checkbox, function (result) {
|
|
12
12
|
if (result.status === 0) {
|
|
13
13
|
if (negativeCase) {
|
|
14
|
-
return browser.expect.element('#' + checkbox).to.not.be.selected;
|
|
14
|
+
return browser.expect.element('#' + checkbox).to.not.be.selected.end();
|
|
15
15
|
}
|
|
16
|
-
return browser.expect.element('#' + checkbox).to.be.selected;
|
|
16
|
+
return browser.expect.element('#' + checkbox).to.be.selected.end();
|
|
17
17
|
} else {
|
|
18
18
|
browser.element('css selector', 'input[name="' + checkbox + '"]', function (result) {
|
|
19
19
|
if (result.status === 0) {
|
|
20
20
|
if (negativeCase) {
|
|
21
|
-
return browser.expect.element('input[name="' + checkbox + '"]').to.not.be.selected;
|
|
21
|
+
return browser.expect.element('input[name="' + checkbox + '"]').to.not.be.selected.end();
|
|
22
22
|
}
|
|
23
|
-
return browser.expect.element('input[name="' + checkbox + '"]').to.be.selected;
|
|
23
|
+
return browser.expect.element('input[name="' + checkbox + '"]').to.be.selected.end();
|
|
24
24
|
} else {
|
|
25
25
|
browser.element('css selector', 'input[value="' + checkbox + '"]', function (result) {
|
|
26
26
|
if (result.status === 0) {
|
|
27
27
|
if (negativeCase) {
|
|
28
|
-
return browser.expect.element('input[value="' + checkbox + '"]').to.not.be.selected;
|
|
28
|
+
return browser.expect.element('input[value="' + checkbox + '"]').to.not.be.selected.end();
|
|
29
29
|
}
|
|
30
|
-
return browser.expect.element('input[value="' + checkbox + '"]').to.be.selected;
|
|
30
|
+
return browser.expect.element('input[value="' + checkbox + '"]').to.be.selected.end();
|
|
31
31
|
} else {
|
|
32
32
|
browser.elements('css selector', 'label', function (elements) {
|
|
33
33
|
elements.value.forEach(function (elementsObj) {
|
|
@@ -35,9 +35,9 @@ module.exports.assertion = function (checkbox, negativeCase) {
|
|
|
35
35
|
if (result.value == checkbox) {
|
|
36
36
|
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
37
37
|
if (negativeCase) {
|
|
38
|
-
return browser.expect.element('#' + forVal.value).to.not.be.selected;
|
|
38
|
+
return browser.expect.element('#' + forVal.value).to.not.be.selected.end();
|
|
39
39
|
}
|
|
40
|
-
return browser.expect.element('#' + forVal.value).to.be.selected;
|
|
40
|
+
return browser.expect.element('#' + forVal.value).to.be.selected.end();
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
})
|
|
@@ -10,30 +10,30 @@ module.exports.assertion = function (element, negativeCase, elementCss) {
|
|
|
10
10
|
browser.element('css selector', element, function (result) {
|
|
11
11
|
if (result.status === 0) {
|
|
12
12
|
if (negativeCase) {
|
|
13
|
-
return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
13
|
+
return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
|
|
14
14
|
}
|
|
15
|
-
return browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
15
|
+
return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
|
|
16
16
|
} else {
|
|
17
17
|
browser.element('css selector', '#' + element, function (result) {
|
|
18
18
|
if (result.status === 0) {
|
|
19
19
|
if (negativeCase) {
|
|
20
|
-
return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
20
|
+
return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
|
|
21
21
|
}
|
|
22
|
-
return browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
22
|
+
return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
|
|
23
23
|
} else {
|
|
24
24
|
browser.element('css selector', 'input[name="' + element + '"]', function (result) {
|
|
25
25
|
if (result.status === 0) {
|
|
26
26
|
if (negativeCase) {
|
|
27
|
-
return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
27
|
+
return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
|
|
28
28
|
}
|
|
29
|
-
return browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
29
|
+
return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
|
|
30
30
|
} else {
|
|
31
31
|
browser.element('css selector', 'input[value="' + element + '"]', function (result) {
|
|
32
32
|
if (result.status === 0) {
|
|
33
33
|
if (negativeCase) {
|
|
34
|
-
return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
34
|
+
return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
|
|
35
35
|
}
|
|
36
|
-
return browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
36
|
+
return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
|
|
37
37
|
} else {
|
|
38
38
|
browser.elements('css selector', 'label', function (elements) {
|
|
39
39
|
elements.value.forEach(function (elementsObj) {
|
|
@@ -43,9 +43,9 @@ module.exports.assertion = function (element, negativeCase, elementCss) {
|
|
|
43
43
|
|
|
44
44
|
console.log('#' + forVal.value, cssProperty, propertyVal);
|
|
45
45
|
if (negativeCase) {
|
|
46
|
-
return browser.assert.not.cssProperty('#' + forVal.value, cssProperty, propertyVal);
|
|
46
|
+
return browser.assert.not.cssProperty('#' + forVal.value, cssProperty, propertyVal).end();
|
|
47
47
|
}
|
|
48
|
-
return browser.assert.cssProperty('#' + forVal.value, cssProperty, propertyVal);
|
|
48
|
+
return browser.assert.cssProperty('#' + forVal.value, cssProperty, propertyVal).end();
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
})
|
|
@@ -4,30 +4,30 @@ module.exports.assertion = function (negativeCase, expectedText, element) {
|
|
|
4
4
|
browser.element('css selector', element, function (result) {
|
|
5
5
|
if (result.status === 0) {
|
|
6
6
|
if (negativeCase) {
|
|
7
|
-
return browser.assert.not.textContains(element, expectedText);
|
|
7
|
+
return browser.assert.not.textContains(element, expectedText).end();
|
|
8
8
|
}
|
|
9
|
-
return browser.assert.textContains(element, expectedText);
|
|
9
|
+
return browser.assert.textContains(element, expectedText).end();
|
|
10
10
|
} else {
|
|
11
11
|
browser.element('css selector', '#' + element, function (result) {
|
|
12
12
|
if (result.status === 0) {
|
|
13
13
|
if (negativeCase) {
|
|
14
|
-
return browser.assert.not.textContains(element, expectedText);
|
|
14
|
+
return browser.assert.not.textContains(element, expectedText).end();
|
|
15
15
|
}
|
|
16
|
-
return browser.assert.textContains(element, expectedText);
|
|
16
|
+
return browser.assert.textContains(element, expectedText).end();
|
|
17
17
|
} else {
|
|
18
18
|
browser.element('css selector', 'input[name="' + element + '"]', function (result) {
|
|
19
19
|
if (result.status === 0) {
|
|
20
20
|
if (negativeCase) {
|
|
21
|
-
return browser.assert.not.textContains(element, expectedText);
|
|
21
|
+
return browser.assert.not.textContains(element, expectedText).end();
|
|
22
22
|
}
|
|
23
|
-
return browser.assert.textContains(element, expectedText);
|
|
23
|
+
return browser.assert.textContains(element, expectedText).end();
|
|
24
24
|
} else {
|
|
25
25
|
browser.element('css selector', 'input[value="' + element + '"]', function (result) {
|
|
26
26
|
if (result.status === 0) {
|
|
27
27
|
if (negativeCase) {
|
|
28
|
-
return browser.assert.not.textContains(element, expectedText);
|
|
28
|
+
return browser.assert.not.textContains(element, expectedText).end();
|
|
29
29
|
}
|
|
30
|
-
return browser.assert.textContains(element, expectedText);
|
|
30
|
+
return browser.assert.textContains(element, expectedText).end();
|
|
31
31
|
} else {
|
|
32
32
|
browser.elements('css selector', 'label', function (elements) {
|
|
33
33
|
elements.value.forEach(function (elementsObj) {
|
|
@@ -35,9 +35,9 @@ module.exports.assertion = function (negativeCase, expectedText, element) {
|
|
|
35
35
|
if (result.value == element) {
|
|
36
36
|
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
37
37
|
if (negativeCase) {
|
|
38
|
-
return browser.assert.not.textContains('#' + forVal.value, expectedText);
|
|
38
|
+
return browser.assert.not.textContains('#' + forVal.value, expectedText).end();
|
|
39
39
|
}
|
|
40
|
-
return browser.assert.textContains('#' + forVal.value, expectedText);
|
|
40
|
+
return browser.assert.textContains('#' + forVal.value, expectedText).end();
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const request = require("request");
|
|
2
|
+
|
|
3
|
+
module.exports.assertion = function (negativeCase, expectedStatusCode) {
|
|
4
|
+
|
|
5
|
+
return browser.url(function (currentURL) {
|
|
6
|
+
request(currentURL.value, (error, response, body) => {
|
|
7
|
+
if (negativeCase) {
|
|
8
|
+
return browser.assert.not.equal(response.statusCode, expectedStatusCode).end();
|
|
9
|
+
}
|
|
10
|
+
return browser.assert.equal(response.statusCode, expectedStatusCode).end();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.assertion = function (negativeCase, textPattern, element) {
|
|
3
|
+
|
|
4
|
+
browser.elements('css selector', element, function (elements) {
|
|
5
|
+
elements.value.forEach(function (elementsObj) {
|
|
6
|
+
if (negativeCase) {
|
|
7
|
+
return browser.assert.not.textMatches(elementsObj, textPattern).end();
|
|
8
|
+
}
|
|
9
|
+
return browser.assert.textMatches(elementsObj, textPattern).end();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
module.exports.command = function (option,
|
|
2
|
+
module.exports.command = function (option, dropdownlist) {
|
|
3
3
|
|
|
4
|
-
browser.element('css selector',
|
|
4
|
+
browser.element('css selector', dropdownlist, function (result) {
|
|
5
5
|
if (result.status === 0) {
|
|
6
|
-
return browser.click(
|
|
6
|
+
return browser.click(dropdownlist + ' option[value=' + option + ']');
|
|
7
7
|
} else {
|
|
8
|
-
browser.element('css selector', '#' +
|
|
8
|
+
browser.element('css selector', '#' + dropdownlist, function (result) {
|
|
9
9
|
if (result.status === 0) {
|
|
10
|
-
return browser.click('#' +
|
|
10
|
+
return browser.click('#' + dropdownlist + ' option[value=' + option + ']');
|
|
11
11
|
} else {
|
|
12
|
-
browser.element('css selector', 'select[name=' +
|
|
12
|
+
browser.element('css selector', 'select[name=' + dropdownlist + ']', function (result) {
|
|
13
13
|
if (result.status === 0) {
|
|
14
|
-
return browser.click('select[name=' +
|
|
14
|
+
return browser.click('select[name=' + dropdownlist + ']' + ' option[value=' + option + ']');
|
|
15
15
|
} else {
|
|
16
16
|
browser.elements('css selector', 'label', function (elements) {
|
|
17
17
|
elements.value.forEach(function (elementsObj) {
|
|
18
18
|
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
19
|
-
if (result.value ==
|
|
19
|
+
if (result.value == dropdownlist) {
|
|
20
20
|
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
21
21
|
return browser.click('#' + forVal.value + ' option[value=' + option + ']');
|
|
22
22
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports.command = function (maxof, number, timeType) {
|
|
2
|
+
|
|
3
|
+
var waitTime = number * 1000;
|
|
4
|
+
if(timeType == "m"){
|
|
5
|
+
waitTime = waitTime * 60;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (maxof) {
|
|
9
|
+
return browser.waitForElementPresent('body', waitTime);
|
|
10
|
+
}
|
|
11
|
+
return browser.pause(waitTime);
|
|
12
|
+
}
|
package/nightwatch.conf.js
CHANGED
|
@@ -17,13 +17,13 @@ module.exports = {
|
|
|
17
17
|
options: {
|
|
18
18
|
feature_path: 'tests/features/*.feature',
|
|
19
19
|
additional_config: '',
|
|
20
|
-
parallel:
|
|
20
|
+
parallel: 1,
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
|
|
24
24
|
test_settings: {
|
|
25
25
|
default: {
|
|
26
|
-
launch_url: 'http://localhost:8080
|
|
26
|
+
launch_url: 'http://localhost:8080',
|
|
27
27
|
selenium_port: 4444,
|
|
28
28
|
selenium_host: '127.0.0.1',
|
|
29
29
|
silent: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webship-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "Webship JS automated functional testing.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -37,15 +37,14 @@
|
|
|
37
37
|
"eslint-config-airbnb-base": "~15.0",
|
|
38
38
|
"eslint-plugin-import": "~2.25",
|
|
39
39
|
"lodash": "~4.17.21",
|
|
40
|
-
"webpack": "~5.0"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
40
|
+
"webpack": "~5.0",
|
|
43
41
|
"chromedriver": "*",
|
|
44
42
|
"geckodriver": "*",
|
|
45
43
|
"webpack-cli": "~5.0",
|
|
46
|
-
"webpack-dev-server": "~4.0"
|
|
44
|
+
"webpack-dev-server": "~4.0",
|
|
45
|
+
"request": "~2.0"
|
|
47
46
|
},
|
|
48
47
|
"bin": {
|
|
49
48
|
"steplist": "./steplist.js"
|
|
50
49
|
}
|
|
51
|
-
}
|
|
50
|
+
}
|