webship-js 1.0.43 → 1.0.44
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/.eslintrc.json +0 -0
- package/CNAME +0 -0
- package/dist/nightwatch.conf.dev.js +93 -0
- package/examples/about-us.html +0 -0
- package/examples/contact-us.html +0 -0
- package/examples/index.html +0 -0
- package/examples/test--then--i-should--see-text-in-element.html +0 -0
- package/examples/test--then--i-should--see-text-matching-pattern.html +0 -0
- package/examples/test--then--the-checkbox-checked.html +0 -0
- package/examples/test--then--the-element-should_not-contain-cssproperty.html +0 -0
- package/examples/test--then--the-link-should-contain.html +0 -0
- package/examples/test--when--i-attach-file-to-feild.html +0 -0
- package/examples/test--when--i-check-uncheck-checkbox.html +0 -0
- package/examples/test--when--i-click-link.html +0 -0
- package/examples/test--when--i-press-button.html +0 -0
- package/examples/test--when--i-reload-page.html +0 -0
- package/examples/test--when--i-scroll-functionality.html +0 -0
- package/examples/test--when--i-scroll-left-right-functionality.html +0 -0
- package/examples/test--when--i-select-option-from-dropdownlist.html +0 -0
- package/examples/test--when-i-wait-max-of-time.html +0 -0
- package/examples/test--when-i-wait-page-until-is-loaded.html +0 -0
- package/examples/test--when-i-wait-specific-time.html +0 -0
- package/generate-reports.js +0 -0
- package/nightwatch.conf.js +1 -1
- package/package.json +1 -1
- package/tests/assets/webshipco.png +0 -0
- package/tests/features/api-step-definitions-individual.feature +185 -0
- package/tests/features/complete-api-testing-examples.feature +205 -0
- package/tests/features/test--given--i-am-on-homepage.feature +2 -2
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +2 -2
- package/tests/features/test--then--i-should--see-text-in-element-by-attr.feature +2 -2
- package/tests/features/test--then--i-should--see-text-in-element.feature +2 -2
- package/tests/features/test--then--i-should--see-text-matching-pattern-in-element.feature +2 -2
- package/tests/features/test--then--i-should--see-text-matching-pattern.feature +2 -2
- package/tests/features/test--then--i-should-be-on-page.feature +2 -2
- package/tests/features/test--then--i-should-be-on-the-homepage.feature +2 -2
- package/tests/features/test--then--i-should-not-see-an-element-by-attr.feature +2 -2
- package/tests/features/test--then--i-should-not-see-an-element.feature +2 -2
- package/tests/features/test--then--i-should-see-an-element-by-attr.feature +2 -2
- package/tests/features/test--then--i-should-see-an-element.feature +2 -2
- package/tests/features/test--then--i-should-see-text-in-table-row.feature +2 -2
- package/tests/features/test--then--the-checkbox-is-checked.feature +2 -2
- package/tests/features/test--then--the-checkbox-should-be-checked.feature +2 -2
- package/tests/features/test--then--the-element-should-contain-cssproperty.feature +2 -2
- package/tests/features/test--then--the-element-should-not-contain-cssproperty.feature +2 -2
- package/tests/features/test--then--the-field-should-contain-value.feature +2 -2
- package/tests/features/test--then--the-response-should-contain.feature +2 -2
- package/tests/features/test--then--the-response-status-code-should-be.feature +2 -2
- package/tests/features/test--then--the-url-should-match.feature +2 -2
- package/tests/features/test--then-the-link-should-contain-by-attribute.feature +2 -2
- package/tests/features/test--then-the-link-should-contain.feature +2 -2
- package/tests/features/test--when--i-attach-file-to-feild.feature +2 -2
- package/tests/features/test--when--i-check-checkbox.feature +2 -2
- package/tests/features/test--when--i-click-link-by-attribute.feature +2 -2
- package/tests/features/test--when--i-click-link.feature +2 -2
- package/tests/features/test--when--i-click-text-in-table-row.feature +21 -21
- package/tests/features/test--when--i-fill-in-by-attr.feature +2 -2
- package/tests/features/test--when--i-fill-in-table-by-attr.feature +2 -2
- package/tests/features/test--when--i-fill-in.feature +2 -2
- package/tests/features/test--when--i-go-to-homepage.feature +3 -3
- package/tests/features/test--when--i-move-forward-backward-one-page.feature +2 -2
- package/tests/features/test--when--i-press-button-by-attribute.feature +2 -2
- package/tests/features/test--when--i-press-button.feature +2 -2
- package/tests/features/test--when--i-reload-page.feature +2 -2
- package/tests/features/test--when--i-scroll-left-right.feature +2 -2
- package/tests/features/test--when--i-scroll.feature +2 -2
- package/tests/features/test--when--i-select-option-from-dropdownlist.feature +2 -2
- package/tests/features/test--when--i-wait-page-is-loaded.feature +2 -2
- package/tests/features/test--when--i-wait-time.feature +2 -2
- package/tests/step-definitions/webship-api.js +535 -0
package/.eslintrc.json
CHANGED
|
File without changes
|
package/CNAME
CHANGED
|
File without changes
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var Services = {};
|
|
4
|
+
loadServices();
|
|
5
|
+
require('events').EventEmitter.defaultMaxListeners = 1000;
|
|
6
|
+
module.exports = {
|
|
7
|
+
// An array of folders (excluding subfolders) where your tests are located;
|
|
8
|
+
// if this is not specified, the test source must be passed as the second argument to the test runner.
|
|
9
|
+
src_folders: ['./tests/step-definitions'],
|
|
10
|
+
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
|
|
11
|
+
custom_commands_path: './lib/custom-commands',
|
|
12
|
+
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
|
|
13
|
+
custom_assertions_path: './lib/custom-assertions',
|
|
14
|
+
test_runner: {
|
|
15
|
+
type: 'cucumber',
|
|
16
|
+
options: {
|
|
17
|
+
feature_path: './tests/features/*.feature',
|
|
18
|
+
additional_config: '',
|
|
19
|
+
parallel: 1
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
globals: {
|
|
23
|
+
assets_folder: "/test/assets/",
|
|
24
|
+
min_wait_time: {
|
|
25
|
+
page: 10000,
|
|
26
|
+
before_scenario: 0,
|
|
27
|
+
after_scenario: 0,
|
|
28
|
+
before_step: 0,
|
|
29
|
+
after_step: 1000
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
test_settings: {
|
|
33
|
+
"default": {
|
|
34
|
+
launch_url: 'http://localhost:8080',
|
|
35
|
+
selenium_port: 4444,
|
|
36
|
+
selenium_host: '127.0.0.1',
|
|
37
|
+
silent: true,
|
|
38
|
+
output: false,
|
|
39
|
+
screenshots: {
|
|
40
|
+
enabled: true,
|
|
41
|
+
path: './reports/screenshots'
|
|
42
|
+
},
|
|
43
|
+
desiredCapabilities: {
|
|
44
|
+
browserName: 'chrome',
|
|
45
|
+
'goog:chromeOptions': {
|
|
46
|
+
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
|
|
47
|
+
//
|
|
48
|
+
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
|
|
49
|
+
w3c: true,
|
|
50
|
+
args: ['--headless', '--start-maximized', '--disable-gpu', '--window-size=1600,1200', '--no-sandbox', '--disable-dev-shm-usage', '--disable-setuid-sandbox', '--disable-web-security', '--DNS-prefetch-disable', '--disable-translate', '--ignore-certificate-errors', '--test-type', '--disable-extensions', '--incognito', '--disable-infobars', '--remote-debugging-port=9222', '--allowed-ips=*', '--whitelisted-ips=*', '--allow-insecure-localhost']
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
selenium_server: {
|
|
56
|
+
// Selenium Server is running locally and is managed by Nightwatch
|
|
57
|
+
selenium: {
|
|
58
|
+
start_process: true,
|
|
59
|
+
port: 4444,
|
|
60
|
+
server_path: Services.seleniumServer ? Services.seleniumServer.path : '',
|
|
61
|
+
cli_args: {
|
|
62
|
+
'webdriver.gecko.driver': Services.geckodriver ? Services.geckodriver.path : '',
|
|
63
|
+
'webdriver.chrome.driver': Services.chromedriver ? Services.chromedriver.path : ''
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
webdriver: {
|
|
67
|
+
start_process: false
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
'selenium.chrome': {
|
|
71
|
+
"extends": 'selenium_server',
|
|
72
|
+
desiredCapabilities: {
|
|
73
|
+
browserName: 'chrome',
|
|
74
|
+
chromeOptions: {
|
|
75
|
+
w3c: false
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function loadServices() {
|
|
82
|
+
try {
|
|
83
|
+
Services.seleniumServer = require('selenium-server');
|
|
84
|
+
} catch (err) {}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
Services.chromedriver = require('chromedriver');
|
|
88
|
+
} catch (err) {}
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
Services.geckodriver = require('geckodriver');
|
|
92
|
+
} catch (err) {}
|
|
93
|
+
}
|
package/examples/about-us.html
CHANGED
|
File without changes
|
package/examples/contact-us.html
CHANGED
|
File without changes
|
package/examples/index.html
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/generate-reports.js
CHANGED
|
File without changes
|
package/nightwatch.conf.js
CHANGED
package/package.json
CHANGED
|
File without changes
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Feature: API Step Definitions Individual
|
|
2
|
+
As a developer,
|
|
3
|
+
I want to see individual examples of each API step definition
|
|
4
|
+
So that I can understand how to use each one.
|
|
5
|
+
|
|
6
|
+
# ======================
|
|
7
|
+
# SETUP STEP DEFINITIONS
|
|
8
|
+
# ======================
|
|
9
|
+
|
|
10
|
+
Scenario: Authentication Step
|
|
11
|
+
# Basic Authentication
|
|
12
|
+
Given I am authenticating as "admin" with "password123" password
|
|
13
|
+
|
|
14
|
+
Scenario: Base URL Setup
|
|
15
|
+
# Different ways to set base URL
|
|
16
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
17
|
+
# Alternative syntax:
|
|
18
|
+
# Given I set the API base URL to "https://api.example.com/v1"
|
|
19
|
+
# Given the base URL is "http://localhost:3000/api"
|
|
20
|
+
|
|
21
|
+
Scenario: Single Header Setup
|
|
22
|
+
# Different ways to set headers
|
|
23
|
+
Given I set header "Content-Type" with value "application/json"
|
|
24
|
+
# Alternative syntax:
|
|
25
|
+
# Given I set the header "Authorization" to "Bearer token123"
|
|
26
|
+
# Given the header "Accept" is "application/json"
|
|
27
|
+
|
|
28
|
+
Scenario: Multiple Headers Setup
|
|
29
|
+
Given I set the following headers:
|
|
30
|
+
| Content-Type | application/json |
|
|
31
|
+
| Authorization | Bearer token123 |
|
|
32
|
+
| Accept | application/json |
|
|
33
|
+
|
|
34
|
+
Scenario: Request Body with JSON String
|
|
35
|
+
Given I set the request body to '{"name": "John", "email": "john@example.com"}'
|
|
36
|
+
|
|
37
|
+
Scenario: Request Body with Table
|
|
38
|
+
Given I set the request body with:
|
|
39
|
+
| name | John Doe |
|
|
40
|
+
| email | john@example.com |
|
|
41
|
+
| age | 30 |
|
|
42
|
+
|
|
43
|
+
Scenario: Placeholder Setup
|
|
44
|
+
Given I set placeholder "{{userId}}" to "123"
|
|
45
|
+
Given I set placeholder "{{baseUrl}}" to "https://api.example.com"
|
|
46
|
+
|
|
47
|
+
# ======================
|
|
48
|
+
# WHEN STEP DEFINITIONS (HTTP Requests)
|
|
49
|
+
# ======================
|
|
50
|
+
|
|
51
|
+
Scenario: Basic HTTP Requests
|
|
52
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
53
|
+
# Different HTTP methods
|
|
54
|
+
When I send a GET request to "/users"
|
|
55
|
+
When I send a POST request to "/posts"
|
|
56
|
+
When I send a PUT request to "/users/1"
|
|
57
|
+
When I send a DELETE request to "/posts/1"
|
|
58
|
+
When I send a PATCH request to "/users/1"
|
|
59
|
+
|
|
60
|
+
Scenario: Request with Values Table
|
|
61
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
62
|
+
When I send a POST request to "/users" with values:
|
|
63
|
+
| name | John Doe |
|
|
64
|
+
| email | john@example.com |
|
|
65
|
+
| age | 30 |
|
|
66
|
+
|
|
67
|
+
Scenario: Request with Body DocString
|
|
68
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
69
|
+
When I send a POST request to "/users" with body:
|
|
70
|
+
"""
|
|
71
|
+
{
|
|
72
|
+
"name": "John Doe",
|
|
73
|
+
"email": "john@example.com"
|
|
74
|
+
}
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
Scenario: Request with Form Data
|
|
78
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
79
|
+
When I send a POST request to "/login" with form data:
|
|
80
|
+
"""
|
|
81
|
+
username=admin
|
|
82
|
+
password=secret
|
|
83
|
+
remember=true
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
# ======================
|
|
87
|
+
# THEN STEP DEFINITIONS (Assertions)
|
|
88
|
+
# ======================
|
|
89
|
+
|
|
90
|
+
Scenario: Status Code Assertions
|
|
91
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
92
|
+
When I send a GET request to "/posts/1"
|
|
93
|
+
Then the API response code should be 200
|
|
94
|
+
# Alternative syntax:
|
|
95
|
+
# Then API response code should be 404
|
|
96
|
+
|
|
97
|
+
Scenario: Content Assertions
|
|
98
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
99
|
+
When I send a GET request to "/posts/1"
|
|
100
|
+
Then the API response should contain "userId"
|
|
101
|
+
Then the API response should not contain "password"
|
|
102
|
+
# Alternative syntax:
|
|
103
|
+
# Then API response should contain "John Doe"
|
|
104
|
+
# Then API response should not contain "failed"
|
|
105
|
+
|
|
106
|
+
Scenario: JSON Structure Assertions
|
|
107
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
108
|
+
When I send a GET request to "/posts/1"
|
|
109
|
+
Then the response should be valid JSON
|
|
110
|
+
Then the JSON response should have property "id"
|
|
111
|
+
Then the JSON response should not have property "password"
|
|
112
|
+
# Alternative syntax:
|
|
113
|
+
# Then the API response should be valid JSON
|
|
114
|
+
# Then the API response should contain property "user.email"
|
|
115
|
+
# Then the API response should not contain property "secret"
|
|
116
|
+
|
|
117
|
+
Scenario: JSON Property Value Assertions
|
|
118
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
119
|
+
When I send a GET request to "/posts/1"
|
|
120
|
+
Then the JSON property "userId" should be 1
|
|
121
|
+
Then the JSON property "id" equal to 1
|
|
122
|
+
# Alternative syntax:
|
|
123
|
+
# Then the JSON response should have "name" should be "John"
|
|
124
|
+
# Then the API response should have "active" equal to true
|
|
125
|
+
|
|
126
|
+
Scenario: JSON Content Assertion with DocString
|
|
127
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
128
|
+
And I set the request body to '{"title": "Test Post", "body": "Test content", "userId": 1}'
|
|
129
|
+
When I send a POST request to "/posts"
|
|
130
|
+
Then the API response should contain json:
|
|
131
|
+
"""
|
|
132
|
+
{
|
|
133
|
+
"title": "Test Post",
|
|
134
|
+
"body": "Test content",
|
|
135
|
+
"userId": 1
|
|
136
|
+
}
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
Scenario: Header Assertions
|
|
140
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
141
|
+
When I send a GET request to "/posts/1"
|
|
142
|
+
Then the response header "Content-Type" should be "application/json"
|
|
143
|
+
# Alternative syntax:
|
|
144
|
+
# Then the header "Cache-Control" should contain "no-cache"
|
|
145
|
+
|
|
146
|
+
Scenario: Debug Step
|
|
147
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
148
|
+
When I send a GET request to "/posts/1"
|
|
149
|
+
Then print API response
|
|
150
|
+
|
|
151
|
+
# ======================
|
|
152
|
+
# COMPLETE WORKFLOW EXAMPLES
|
|
153
|
+
# ======================
|
|
154
|
+
|
|
155
|
+
Scenario: Complete CRUD Operations
|
|
156
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
157
|
+
|
|
158
|
+
# CREATE
|
|
159
|
+
And I set the request body to '{"title": "New Post", "body": "Post content", "userId": 1}'
|
|
160
|
+
When I send a POST request to "/posts"
|
|
161
|
+
Then the API response code should be 201
|
|
162
|
+
And the API response should contain "New Post"
|
|
163
|
+
|
|
164
|
+
# READ
|
|
165
|
+
When I send a GET request to "/posts/1"
|
|
166
|
+
Then the API response code should be 200
|
|
167
|
+
And the JSON response should have property "title"
|
|
168
|
+
|
|
169
|
+
# UPDATE
|
|
170
|
+
And I set the request body to '{"id": 1, "title": "Updated Post", "body": "Updated content", "userId": 1}'
|
|
171
|
+
When I send a PUT request to "/posts/1"
|
|
172
|
+
Then the API response code should be 200
|
|
173
|
+
|
|
174
|
+
# DELETE
|
|
175
|
+
When I send a DELETE request to "/posts/1"
|
|
176
|
+
Then the API response code should be 200
|
|
177
|
+
|
|
178
|
+
Scenario: Using Placeholders
|
|
179
|
+
Given I set placeholder "{{userId}}" to "1"
|
|
180
|
+
And I set placeholder "{{postTitle}}" to "Dynamic Title"
|
|
181
|
+
And the API base URL is "https://jsonplaceholder.typicode.com"
|
|
182
|
+
And I set the request body to '{"title": "{{postTitle}}", "body": "Content", "userId": {{userId}}}'
|
|
183
|
+
When I send a POST request to "/posts"
|
|
184
|
+
Then the API response code should be 201
|
|
185
|
+
And the API response should contain "Dynamic Title"
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Feature: Complete API Testing Examples - All Step Definitions
|
|
2
|
+
As a developer,
|
|
3
|
+
I want to test all available API step definitions
|
|
4
|
+
So that I can verify comprehensive API testing capabilities.
|
|
5
|
+
|
|
6
|
+
Background:
|
|
7
|
+
Given the API base URL is "https://jsonplaceholder.typicode.com"
|
|
8
|
+
|
|
9
|
+
Scenario: Basic Authentication and Headers
|
|
10
|
+
Given I am authenticating as "admin" with "password123" password
|
|
11
|
+
And I set header "Content-Type" with value "application/json"
|
|
12
|
+
And I set header "Accept" with value "application/json"
|
|
13
|
+
When I send a GET request to "/posts/1"
|
|
14
|
+
Then the API response code should be 200
|
|
15
|
+
|
|
16
|
+
Scenario: Alternative Header Syntax
|
|
17
|
+
Given I set the header "Content-Type" to "application/json"
|
|
18
|
+
And the header "Accept" is "application/json"
|
|
19
|
+
When I send a GET request to "/posts/1"
|
|
20
|
+
Then the API response code should be 200
|
|
21
|
+
|
|
22
|
+
Scenario: Multiple Headers Using Table
|
|
23
|
+
Given I set the following headers:
|
|
24
|
+
| Content-Type | application/json |
|
|
25
|
+
| Accept | application/json |
|
|
26
|
+
| User-Agent | WebshipJS/1.0 |
|
|
27
|
+
When I send a GET request to "/posts"
|
|
28
|
+
Then the API response code should be 200
|
|
29
|
+
|
|
30
|
+
Scenario: GET Request with Response Validation
|
|
31
|
+
When I send a GET request to "/posts/1"
|
|
32
|
+
Then the API response code should be 200
|
|
33
|
+
And the API response should contain "userId"
|
|
34
|
+
And the API response should contain "title"
|
|
35
|
+
And the API response should not contain "password"
|
|
36
|
+
|
|
37
|
+
Scenario: POST Request with JSON Body (String)
|
|
38
|
+
Given I set the request body to '{"title": "Test Post", "body": "This is a test post", "userId": 1}'
|
|
39
|
+
When I send a POST request to "/posts"
|
|
40
|
+
Then the API response code should be 201
|
|
41
|
+
And the API response should contain "Test Post"
|
|
42
|
+
|
|
43
|
+
Scenario: POST Request with Table Body
|
|
44
|
+
Given I set the request body with:
|
|
45
|
+
| title | My New Post |
|
|
46
|
+
| body | This is the content |
|
|
47
|
+
| userId | 1 |
|
|
48
|
+
When I send a POST request to "/posts"
|
|
49
|
+
Then the API response code should be 201
|
|
50
|
+
|
|
51
|
+
Scenario: POST Request with Values Table
|
|
52
|
+
When I send a POST request to "/posts" with values:
|
|
53
|
+
| title | Table Post |
|
|
54
|
+
| body | Created with table |
|
|
55
|
+
| userId | 1 |
|
|
56
|
+
Then the API response code should be 201
|
|
57
|
+
And the API response should contain "Table Post"
|
|
58
|
+
|
|
59
|
+
Scenario: POST Request with DocString Body
|
|
60
|
+
When I send a POST request to "/posts" with body:
|
|
61
|
+
"""
|
|
62
|
+
{
|
|
63
|
+
"title": "DocString Post",
|
|
64
|
+
"body": "Created with docstring",
|
|
65
|
+
"userId": 1
|
|
66
|
+
}
|
|
67
|
+
"""
|
|
68
|
+
Then the API response code should be 201
|
|
69
|
+
And the API response should contain "DocString Post"
|
|
70
|
+
|
|
71
|
+
Scenario: Form Data Request
|
|
72
|
+
When I send a POST request to "/posts" with form data:
|
|
73
|
+
"""
|
|
74
|
+
title=Form Data Post
|
|
75
|
+
body=Created with form data
|
|
76
|
+
userId=1
|
|
77
|
+
"""
|
|
78
|
+
Then the API response code should be 201
|
|
79
|
+
|
|
80
|
+
Scenario: PUT Request for Update
|
|
81
|
+
Given I set the request body to '{"id": 1, "title": "Updated Post", "body": "Updated content", "userId": 1}'
|
|
82
|
+
When I send a PUT request to "/posts/1"
|
|
83
|
+
Then the API response code should be 200
|
|
84
|
+
And the API response should contain "Updated Post"
|
|
85
|
+
|
|
86
|
+
Scenario: PATCH Request
|
|
87
|
+
Given I set the request body to '{"title": "Patched Title"}'
|
|
88
|
+
When I send a PATCH request to "/posts/1"
|
|
89
|
+
Then the API response code should be 200
|
|
90
|
+
|
|
91
|
+
Scenario: DELETE Request
|
|
92
|
+
When I send a DELETE request to "/posts/1"
|
|
93
|
+
Then the API response code should be 200
|
|
94
|
+
|
|
95
|
+
Scenario: JSON Response Structure Validation
|
|
96
|
+
When I send a GET request to "/posts/1"
|
|
97
|
+
Then the API response code should be 200
|
|
98
|
+
And the response should be valid JSON
|
|
99
|
+
And the JSON response should have property "id"
|
|
100
|
+
And the JSON response should have property "title"
|
|
101
|
+
And the JSON response should have property "body"
|
|
102
|
+
And the JSON response should have property "userId"
|
|
103
|
+
And the JSON response should not have property "password"
|
|
104
|
+
|
|
105
|
+
Scenario: Specific JSON Property Values
|
|
106
|
+
When I send a GET request to "/posts/1"
|
|
107
|
+
Then the API response code should be 200
|
|
108
|
+
And the JSON property "userId" should be 1
|
|
109
|
+
And the JSON property "id" should be 1
|
|
110
|
+
|
|
111
|
+
Scenario: JSON Structure Validation with DocString
|
|
112
|
+
When I send a POST request to "/posts" with body:
|
|
113
|
+
"""
|
|
114
|
+
{
|
|
115
|
+
"title": "Test Title",
|
|
116
|
+
"body": "Test Body",
|
|
117
|
+
"userId": 1
|
|
118
|
+
}
|
|
119
|
+
"""
|
|
120
|
+
Then the API response code should be 201
|
|
121
|
+
And the API response should contain json:
|
|
122
|
+
"""
|
|
123
|
+
{
|
|
124
|
+
"title": "Test Title",
|
|
125
|
+
"body": "Test Body",
|
|
126
|
+
"userId": 1
|
|
127
|
+
}
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
Scenario: Response Header Validation
|
|
131
|
+
When I send a GET request to "/posts/1"
|
|
132
|
+
Then the API response code should be 200
|
|
133
|
+
And the response header "Content-Type" should be "application/json"
|
|
134
|
+
|
|
135
|
+
Scenario: Placeholder Usage
|
|
136
|
+
Given I set placeholder "{{postId}}" to "1"
|
|
137
|
+
And I set placeholder "{{userId}}" to "1"
|
|
138
|
+
When I send a GET request to "/posts/{{postId}}"
|
|
139
|
+
Then the API response code should be 200
|
|
140
|
+
And the JSON property "userId" should be {{userId}}
|
|
141
|
+
And the JSON property "id" should be {{postId}}
|
|
142
|
+
|
|
143
|
+
Scenario: Complex Scenario with All Features
|
|
144
|
+
Given I set placeholder "{{newTitle}}" to "Complex API Test"
|
|
145
|
+
And I set placeholder "{{newBody}}" to "Testing all features together"
|
|
146
|
+
And I set the following headers:
|
|
147
|
+
| Content-Type | application/json |
|
|
148
|
+
| Accept | application/json |
|
|
149
|
+
| User-Agent | WebshipJS-Testing/1.0 |
|
|
150
|
+
And I set the request body to '{"title": "{{newTitle}}", "body": "{{newBody}}", "userId": 1}'
|
|
151
|
+
When I send a POST request to "/posts"
|
|
152
|
+
Then the API response code should be 201
|
|
153
|
+
And the response should be valid JSON
|
|
154
|
+
And the API response should contain "Complex API Test"
|
|
155
|
+
And the API response should contain "Testing all features together"
|
|
156
|
+
And the JSON response should have property "id"
|
|
157
|
+
And the JSON response should have property "title"
|
|
158
|
+
And the JSON response should have property "body"
|
|
159
|
+
And the JSON response should have property "userId"
|
|
160
|
+
And print API response
|
|
161
|
+
|
|
162
|
+
Scenario: Error Handling Test
|
|
163
|
+
When I send a GET request to "/posts/999999"
|
|
164
|
+
Then the API response code should be 404
|
|
165
|
+
|
|
166
|
+
Scenario: Array Response Testing
|
|
167
|
+
When I send a GET request to "/posts"
|
|
168
|
+
Then the API response code should be 200
|
|
169
|
+
And the response should be valid JSON
|
|
170
|
+
|
|
171
|
+
Scenario: Different HTTP Methods Testing
|
|
172
|
+
# Test all supported HTTP methods
|
|
173
|
+
When I send a GET request to "/posts/1"
|
|
174
|
+
Then the API response code should be 200
|
|
175
|
+
|
|
176
|
+
Given I set the request body to '{"title": "Test", "body": "Test", "userId": 1}'
|
|
177
|
+
When I send a POST request to "/posts"
|
|
178
|
+
Then the API response code should be 201
|
|
179
|
+
|
|
180
|
+
Given I set the request body to '{"id": 1, "title": "Updated", "body": "Updated", "userId": 1}'
|
|
181
|
+
When I send a PUT request to "/posts/1"
|
|
182
|
+
Then the API response code should be 200
|
|
183
|
+
|
|
184
|
+
Given I set the request body to '{"title": "Patched"}'
|
|
185
|
+
When I send a PATCH request to "/posts/1"
|
|
186
|
+
Then the API response code should be 200
|
|
187
|
+
|
|
188
|
+
When I send a DELETE request to "/posts/1"
|
|
189
|
+
Then the API response code should be 200
|
|
190
|
+
|
|
191
|
+
Scenario: Nested JSON Property Testing
|
|
192
|
+
When I send a GET request to "/users/1"
|
|
193
|
+
Then the API response code should be 200
|
|
194
|
+
And the JSON response should have property "address.city"
|
|
195
|
+
And the JSON response should have property "company.name"
|
|
196
|
+
|
|
197
|
+
Scenario: Boolean and Number Property Testing
|
|
198
|
+
Given I set the request body with:
|
|
199
|
+
| title | Test Post |
|
|
200
|
+
| body | Test content |
|
|
201
|
+
| userId | 1 |
|
|
202
|
+
| published | true |
|
|
203
|
+
| views | 100 |
|
|
204
|
+
When I send a POST request to "/posts"
|
|
205
|
+
Then the API response code should be 201
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example of testing for being on the homepage.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As an anonymous user,
|
|
3
|
+
I want to be able to navigate to the homepage
|
|
4
4
|
so that I can check the welcome message on the homepage.
|
|
5
5
|
|
|
6
6
|
Scenario: Ensure that you are on the homepage by using 'the' before the word 'homepage'.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example to ensure that the input text does not contain a specific value based on its attribute
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As a tester,
|
|
3
|
+
I want to ensure that the textbox does not contain a specific value based on its attributes.
|
|
4
4
|
|
|
5
5
|
Scenario: Ensuring that a textbox does not contain a specific value based on its attributes.
|
|
6
6
|
Given I am on "/test--then--i-should--not--see-text-in-element.html"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example to ensure that the input text contain a specific value based on its attribute
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As a tester,
|
|
3
|
+
I want to ensure that the textbox contain a specific value based on its attributes.
|
|
4
4
|
|
|
5
5
|
Scenario: Ensuring that a textbox contain a specific value based on its attributes.
|
|
6
6
|
Given I am on "/test--then--i-should--not--see-text-in-element.html"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example to ensure that the input text contain a specific value based on its label
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As a tester,
|
|
3
|
+
I want to ensure thlabelat the textbox does not contain a specific value based on its label
|
|
4
4
|
|
|
5
5
|
Scenario: Ensuring that a textbox does not contain a specific value based on its label.
|
|
6
6
|
Given I am on "/test--then--i-should--not--see-text-in-element.html"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example of ensuring that a pattern matches the text in a specific element
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As a developer,
|
|
3
|
+
I want to ensure that a pattern matches the text in a specific element.
|
|
4
4
|
|
|
5
5
|
Scenario: Ensuring that the text in an element matches the 12-hour time format pattern
|
|
6
6
|
Given I am on "/test--then--i-should--see-text-matching-pattern.html"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example of ensuring that a pattern matches the text on a specific page.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As a developer,
|
|
3
|
+
I want to ensure that a pattern matches the text in a specific page.
|
|
4
4
|
|
|
5
5
|
Scenario: Ensure that there is a text matching the pattern of text starting with 'T' on a specific page
|
|
6
6
|
Given I am on "/test--then--i-should--see-text-matching-pattern.html"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example to ensure that you are on a specific page
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As an anonymous user,
|
|
3
|
+
I want to ensure that I am on a specific page
|
|
4
4
|
|
|
5
5
|
Scenario: Ensure that you are on a specific page
|
|
6
6
|
Given I am on the homepage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example to ensure that you are on the homepage
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As an anonymous user,
|
|
3
|
+
I want to ensure that I am on the homepage
|
|
4
4
|
|
|
5
5
|
Scenario: Ensure that you are on the homepage
|
|
6
6
|
Given I am on the homepage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example to ensure that a specific element is not visible on the current page by its attribute
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As a user,
|
|
3
|
+
I want to ensure that when I'm on a particular page, I do not see a specific element identified by its attribute
|
|
4
4
|
|
|
5
5
|
Scenario: Ensure that a specific element is not visible based on its attribute
|
|
6
6
|
Given I am on "/test--then--i-should--see-text-in-element.html"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Feature: An example to ensure that a specific element is not visible on the current page by its label
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
As a user,
|
|
3
|
+
I want to ensure that when I'm on a particular page, I do not see a specific element by its label
|
|
4
4
|
|
|
5
5
|
Scenario: Ensure to test that a specific element is not visible by its label
|
|
6
6
|
Given I am on "/test--then--i-should--see-text-in-element.html"
|