webship-js 1.0.11 → 1.0.13
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 +15 -8
- package/.github/workflows/github-actions.yml +13 -10
- package/.gitlab-ci.yml +1 -0
- package/.travis-ci.yml +0 -0
- package/README.md +1 -1
- package/assets/config_templates/circleci-linux-chrome.conf.js +103 -0
- package/assets/config_templates/github-linux-chrome.conf.js +114 -0
- package/{bitbucket-pipelines.yml → bitbucket-pipelines-test.yml} +0 -0
- package/examples/about-us.html +10 -0
- package/examples/contact-us.html +10 -0
- package/examples/index.html +27 -0
- package/examples/main.js +17 -0
- package/examples/test--then--i-should--not--see-text-in-element.html +48 -0
- package/examples/test--when--i-check-uncheck-checkbox.html +45 -0
- package/examples/test--when--i-fill-in.html +48 -0
- package/examples/test--when--i-follow-link.html +18 -0
- package/examples/test--when--i-press-button.html +27 -0
- package/examples/test--when--i-reload-page.html +27 -0
- package/examples/test--when--i-select-option-from-selectbox.html +35 -0
- package/lib/custom-assertions/smartElementContains.js +54 -0
- package/lib/custom-commands/smartCheckItem.js +39 -0
- package/lib/custom-commands/smartSelectOption.js +33 -0
- package/lib/custom-commands/smartUncheckItem.js +45 -0
- package/lib/get-element.js +65 -0
- package/nightwatch.conf.js +27 -259
- package/package.json +11 -4
- package/src/index.js +10 -0
- package/tests/features/test--given--i-am-on-homepage.feature +12 -0
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +13 -0
- package/tests/features/test--then--i-should-be-on-page.feature +10 -0
- package/tests/features/test--then--i-should-be-on-the-homepage.feature +9 -0
- package/tests/features/test--then--the-response-should-contain.feature +12 -0
- package/tests/features/test--when--i-check-checkbox.feature +17 -0
- package/tests/features/test--when--i-fill-in.feature +36 -0
- package/tests/features/test--when--i-follow-link.feature +11 -0
- package/tests/features/test--when--i-move-forward-backward-one-page.feature +14 -0
- package/tests/features/test--when--i-press-button.feature +11 -0
- package/tests/features/test--when--i-reload-page.feature +14 -0
- package/tests/features/test--when--i-select-option-from-selectbox.feature +13 -0
- package/tests/features/test--when--i-uncheck-checkbox.feature +20 -0
- package/tests/reports/cucumber-report.html +0 -0
- package/tests/reports/cucumber-report.json +0 -0
- package/tests/step-definitions/webship.js +232 -11
- package/webpack.config.js +17 -0
- package/webship-init.js +75 -0
- package/tests/features/check-webshipco-site.feature +0 -8
package/.circleci/config.yml
CHANGED
|
@@ -40,6 +40,7 @@ commands:
|
|
|
40
40
|
- run:
|
|
41
41
|
name: Install/Update Google Chrome browser
|
|
42
42
|
command: |
|
|
43
|
+
sudo apt install libu2f-udev
|
|
43
44
|
sudo apt-get install libappindicator1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
|
|
44
45
|
export CHROME_BIN=/usr/bin/google-chrome
|
|
45
46
|
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
@@ -57,11 +58,6 @@ commands:
|
|
|
57
58
|
sudo mv -f chromedriver /usr/bin/
|
|
58
59
|
rm chromedriver_linux64.zip
|
|
59
60
|
|
|
60
|
-
## Setup Apache2
|
|
61
|
-
- run:
|
|
62
|
-
name: Setup Apache2
|
|
63
|
-
command: |
|
|
64
|
-
sudo apt install -yqq apache2
|
|
65
61
|
## Run Selenium Standalone server.
|
|
66
62
|
- run:
|
|
67
63
|
name: Run Selenium Standalone server
|
|
@@ -70,7 +66,7 @@ commands:
|
|
|
70
66
|
cd /home/circleci/
|
|
71
67
|
java -jar selenium-server-standalone-3.141.59.jar -port 4444
|
|
72
68
|
background: true
|
|
73
|
-
|
|
69
|
+
|
|
74
70
|
jobs:
|
|
75
71
|
webship-js-testing:
|
|
76
72
|
<<: *defaults
|
|
@@ -78,10 +74,21 @@ jobs:
|
|
|
78
74
|
- webship-js-build
|
|
79
75
|
## Automated Functional Acceptance Testing
|
|
80
76
|
- run:
|
|
81
|
-
name:
|
|
82
|
-
no_output_timeout: 30m
|
|
77
|
+
name: Install yarn
|
|
83
78
|
command: |
|
|
84
79
|
yarn install
|
|
80
|
+
- run:
|
|
81
|
+
name: Configure nightwatch.conf.js for Circle CI
|
|
82
|
+
command: |
|
|
83
|
+
node webship-init -ci circleci -os linux -b chrome
|
|
84
|
+
- run:
|
|
85
|
+
name: Start virtual server
|
|
86
|
+
command: |
|
|
87
|
+
yarn start
|
|
88
|
+
background: true
|
|
89
|
+
- run:
|
|
90
|
+
name: Test
|
|
91
|
+
command: |
|
|
85
92
|
yarn test
|
|
86
93
|
workflows:
|
|
87
94
|
version: 2
|
|
@@ -8,21 +8,24 @@ jobs:
|
|
|
8
8
|
runs-on: ubuntu-latest
|
|
9
9
|
|
|
10
10
|
env:
|
|
11
|
-
TEST_BASE_URL:
|
|
11
|
+
TEST_BASE_URL: http://localhost:8080/
|
|
12
12
|
SELENIUM_HOST: http://selenium:4444/wd/hub
|
|
13
13
|
|
|
14
|
-
services:
|
|
15
|
-
selenium:
|
|
16
|
-
image: selenium/standalone-chrome
|
|
17
|
-
# options: --health-cmd "curl http://selenium:4444" --health-interval=5s
|
|
18
|
-
ports:
|
|
19
|
-
- 4444:4444
|
|
20
|
-
|
|
21
14
|
steps:
|
|
15
|
+
- name: Install Chrome
|
|
16
|
+
run: |
|
|
17
|
+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
18
|
+
sudo dpkg -i google-chrome-stable_current_amd64.deb
|
|
22
19
|
- uses: actions/checkout@v3
|
|
23
20
|
- name: Use Node.js
|
|
24
21
|
uses: actions/setup-node@v3
|
|
25
22
|
with:
|
|
26
23
|
node-version: '16.x'
|
|
27
|
-
-
|
|
28
|
-
|
|
24
|
+
- name: Install
|
|
25
|
+
run: yarn install
|
|
26
|
+
- name: Configure nightwatch.conf.js for Github
|
|
27
|
+
run: node webship-init -ci github -os linux -b chrome
|
|
28
|
+
- name: Start
|
|
29
|
+
run: yarn start &
|
|
30
|
+
- name: Test
|
|
31
|
+
run: yarn test
|
package/.gitlab-ci.yml
CHANGED
package/.travis-ci.yml
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Webship JS has a ready step definitions for automated functional testing.
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
### Webship-js Documentations
|
|
15
|
-
All you need to know about [webship-js Docs](https://
|
|
15
|
+
All you need to know about [webship-js Docs](https://github.com/webship/webship-js/wiki/).
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
## How to configure your project to test using webship-js steps
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const Services = {}; loadServices();
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
// An array of folders (excluding subfolders) where your tests are located;
|
|
5
|
+
// if this is not specified, the test source must be passed as the second argument to the test runner.
|
|
6
|
+
src_folders: ['tests/step-definitions'],
|
|
7
|
+
|
|
8
|
+
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
|
|
9
|
+
custom_commands_path: './lib/custom-commands',
|
|
10
|
+
|
|
11
|
+
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
|
|
12
|
+
custom_assertions_path: './lib/custom-assertions',
|
|
13
|
+
|
|
14
|
+
test_runner: {
|
|
15
|
+
type: 'cucumber',
|
|
16
|
+
options: {
|
|
17
|
+
feature_path: 'tests/features/*.feature',
|
|
18
|
+
additional_config: '',
|
|
19
|
+
parallel: 2,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
test_settings: {
|
|
24
|
+
default: {
|
|
25
|
+
launch_url: 'http://localhost:8080/',
|
|
26
|
+
selenium_port: 4444,
|
|
27
|
+
selenium_host: '127.0.0.1',
|
|
28
|
+
silent: true,
|
|
29
|
+
screenshots: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
path: './reports/screenshots',
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
desiredCapabilities: {
|
|
35
|
+
browserName: 'chrome',
|
|
36
|
+
'goog:chromeOptions': {
|
|
37
|
+
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
|
|
38
|
+
//
|
|
39
|
+
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
|
|
40
|
+
w3c: false,
|
|
41
|
+
args: [
|
|
42
|
+
'--headless',
|
|
43
|
+
'--start-maximized',
|
|
44
|
+
'--disable-gpu',
|
|
45
|
+
'--window-size=1600,1200',
|
|
46
|
+
'--no-sandbox',
|
|
47
|
+
'--disable-dev-shm-usage',
|
|
48
|
+
'--disable-setuid-sandbox',
|
|
49
|
+
'--disable-web-security',
|
|
50
|
+
'--DNS-prefetch-disable',
|
|
51
|
+
'--disable-translate',
|
|
52
|
+
'--ignore-certificate-errors',
|
|
53
|
+
'--test-type',
|
|
54
|
+
'--disable-extensions',
|
|
55
|
+
'--incognito',
|
|
56
|
+
'--disable-infobars',
|
|
57
|
+
'--remote-debugging-port=9222',
|
|
58
|
+
'--allowed-ips=*',
|
|
59
|
+
'--whitelisted-ips=*',
|
|
60
|
+
'--allow-insecure-localhost',
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
selenium_server: {
|
|
68
|
+
// Selenium Server is running locally and is managed by Nightwatch
|
|
69
|
+
selenium: {
|
|
70
|
+
start_process: true,
|
|
71
|
+
port: 4444,
|
|
72
|
+
server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
|
|
73
|
+
cli_args: {
|
|
74
|
+
'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
|
|
75
|
+
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
'selenium.chrome': {
|
|
81
|
+
extends: 'selenium_server',
|
|
82
|
+
desiredCapabilities: {
|
|
83
|
+
browserName: 'chrome',
|
|
84
|
+
chromeOptions: {
|
|
85
|
+
w3c: true,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
function loadServices() {
|
|
92
|
+
try {
|
|
93
|
+
Services.seleniumServer = require('selenium-server');
|
|
94
|
+
} catch (err) {}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
Services.chromedriver = require('chromedriver');
|
|
98
|
+
} catch (err) {}
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
Services.geckodriver = require('geckodriver');
|
|
102
|
+
} catch (err) {}
|
|
103
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const Services = {}; loadServices();
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
// An array of folders (excluding subfolders) where your tests are located;
|
|
5
|
+
// if this is not specified, the test source must be passed as the second argument to the test runner.
|
|
6
|
+
src_folders: ['tests/step-definitions'],
|
|
7
|
+
|
|
8
|
+
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
|
|
9
|
+
custom_commands_path: './lib/custom-commands',
|
|
10
|
+
|
|
11
|
+
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
|
|
12
|
+
custom_assertions_path: './lib/custom-assertions',
|
|
13
|
+
|
|
14
|
+
webdriver: {
|
|
15
|
+
start_process: true,
|
|
16
|
+
port: 4444,
|
|
17
|
+
server_path: require('chromedriver').path,
|
|
18
|
+
cli_args: [
|
|
19
|
+
// very verbose geckodriver logs
|
|
20
|
+
// '-vv'
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
test_runner: {
|
|
25
|
+
type: 'cucumber',
|
|
26
|
+
options: {
|
|
27
|
+
feature_path: 'tests/features/*.feature',
|
|
28
|
+
additional_config: '',
|
|
29
|
+
parallel: 2,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
test_settings: {
|
|
35
|
+
default: {
|
|
36
|
+
launch_url: 'http://localhost:8080/',
|
|
37
|
+
selenium_port: 4444,
|
|
38
|
+
selenium_host: '127.0.0.1',
|
|
39
|
+
silent: true,
|
|
40
|
+
screenshots: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
path: './reports/screenshots',
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
desiredCapabilities: {
|
|
46
|
+
browserName: 'chrome',
|
|
47
|
+
'goog:chromeOptions': {
|
|
48
|
+
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
|
|
49
|
+
//
|
|
50
|
+
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
|
|
51
|
+
w3c: false,
|
|
52
|
+
args: [
|
|
53
|
+
'--headless',
|
|
54
|
+
'--start-maximized',
|
|
55
|
+
'--disable-gpu',
|
|
56
|
+
'--window-size=1600,1200',
|
|
57
|
+
'--no-sandbox',
|
|
58
|
+
'--disable-dev-shm-usage',
|
|
59
|
+
'--disable-setuid-sandbox',
|
|
60
|
+
'--disable-web-security',
|
|
61
|
+
'--DNS-prefetch-disable',
|
|
62
|
+
'--disable-translate',
|
|
63
|
+
'--ignore-certificate-errors',
|
|
64
|
+
'--test-type',
|
|
65
|
+
'--disable-extensions',
|
|
66
|
+
'--incognito',
|
|
67
|
+
'--disable-infobars',
|
|
68
|
+
'--remote-debugging-port=9222',
|
|
69
|
+
'--allowed-ips=*',
|
|
70
|
+
'--whitelisted-ips=*',
|
|
71
|
+
'--allow-insecure-localhost',
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
selenium_server: {
|
|
79
|
+
// Selenium Server is running locally and is managed by Nightwatch
|
|
80
|
+
selenium: {
|
|
81
|
+
start_process: true,
|
|
82
|
+
port: 4444,
|
|
83
|
+
server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
|
|
84
|
+
cli_args: {
|
|
85
|
+
'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
|
|
86
|
+
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
'selenium.chrome': {
|
|
92
|
+
extends: 'selenium_server',
|
|
93
|
+
desiredCapabilities: {
|
|
94
|
+
browserName: 'chrome',
|
|
95
|
+
chromeOptions: {
|
|
96
|
+
w3c: true,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
function loadServices() {
|
|
103
|
+
try {
|
|
104
|
+
Services.seleniumServer = require('selenium-server');
|
|
105
|
+
} catch (err) { }
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
Services.chromedriver = require('chromedriver');
|
|
109
|
+
} catch (err) { }
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
Services.geckodriver = require('geckodriver');
|
|
113
|
+
} catch (err) { }
|
|
114
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>Webship-js Examples</title>
|
|
6
|
+
<style>
|
|
7
|
+
a:link{font-size: 30px; text-decoration: none;}
|
|
8
|
+
a:active {color: blue;}
|
|
9
|
+
a:visited {color: blue;}
|
|
10
|
+
</style>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<h1>Step Definitions Examples:</h1>
|
|
14
|
+
<h3>Welcome to the homepage of the Webship-js Examples</h3>
|
|
15
|
+
<ul>
|
|
16
|
+
<li><a href="/">Given I go to homepage</a></li>
|
|
17
|
+
<li><a href="about-us.html">When I move forward/backward one page</a></li>
|
|
18
|
+
<li><a href="test--when--i-press-button.html">When I press "Button"</a></li>
|
|
19
|
+
<li><a href="test--when--i-reload-page.html">When I go reload page</a></li>
|
|
20
|
+
<li><a href="test--when--i-follow-link.html">When I go follow "link"</a></li>
|
|
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-select.box.html">When I select option from select box</a></li>
|
|
23
|
+
<li><a href="test--then--i-should--not--see-text-in-element.html">When I select option from select box</a></li>
|
|
24
|
+
</ul>
|
|
25
|
+
<script src="main.js"></script>
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
package/examples/main.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
3
|
+
* This devtool is not neither made for production nor for readable output files.
|
|
4
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
5
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
6
|
+
* or disable the default devtool with "devtool: false".
|
|
7
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
8
|
+
*/
|
|
9
|
+
/******/ (() => { // webpackBootstrap
|
|
10
|
+
/*!**********************!*\
|
|
11
|
+
!*** ./src/index.js ***!
|
|
12
|
+
\**********************/
|
|
13
|
+
/*! unknown exports (runtime-defined) */
|
|
14
|
+
/*! runtime requirements: */
|
|
15
|
+
eval("function component() {\n const element = document.createElement('div');\n\n //Lodash, now imported by this script\n element.innerHTML = _.join(['Hello', 'webpack'], ' ');\n\n return element;\n}\n\ndocument.body.appendChild(component());\n\n//# sourceURL=webpack://webship-js/./src/index.js?");
|
|
16
|
+
/******/ })()
|
|
17
|
+
;
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
.style{
|
|
13
|
+
width: 400px;
|
|
14
|
+
height: 50px;
|
|
15
|
+
font-size: 18px;
|
|
16
|
+
line-height: 50px;
|
|
17
|
+
text-align: center;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
function onClick(){
|
|
23
|
+
const username = document.getElementById("uname");
|
|
24
|
+
const password = document.getElementById("pword");
|
|
25
|
+
const element = document.getElementById("result");
|
|
26
|
+
element.innerText = "You enter Username: " + username.value + " and Password: " + password.value;
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<h1>Login</h1>
|
|
33
|
+
|
|
34
|
+
<div class="container">
|
|
35
|
+
<p><label for="uname"><b>Username</b></label></p>
|
|
36
|
+
<p><input id="uname" class="unamecss" type="text" placeholder="Enter Username" name="username"></p>
|
|
37
|
+
|
|
38
|
+
<p><label for="pword"><b>Password</b></label></p>
|
|
39
|
+
<p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
|
|
40
|
+
|
|
41
|
+
<p><input id="reset" type="reset" value="Reset"><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()"></p>
|
|
42
|
+
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<div id="result" class="style"></div><br/>
|
|
46
|
+
|
|
47
|
+
</body>
|
|
48
|
+
</html>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
|
+
<title>Check Item</title>
|
|
7
|
+
<style>
|
|
8
|
+
.style {
|
|
9
|
+
height: 50px;
|
|
10
|
+
font-size: 26px;
|
|
11
|
+
line-height: 50px;
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
<script>
|
|
15
|
+
function onClick() {
|
|
16
|
+
var vehicle = document.forms[0];
|
|
17
|
+
var txt = "";
|
|
18
|
+
var i;
|
|
19
|
+
for (i = 0; i < vehicle.length; i++) {
|
|
20
|
+
if (vehicle[i].checked) {
|
|
21
|
+
txt = txt + vehicle[i].value + " ";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const element = document.getElementById("result");
|
|
25
|
+
element.innerText = "You have a " + txt;
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
</head>
|
|
29
|
+
|
|
30
|
+
<body>
|
|
31
|
+
<h1>Check Option</h1>
|
|
32
|
+
<form>
|
|
33
|
+
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
|
|
34
|
+
<label for="vehicle1"> I have a bike</label><br>
|
|
35
|
+
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
|
|
36
|
+
<label for="vehicle2"> I have a car</label><br>
|
|
37
|
+
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
|
|
38
|
+
<label for="vehicle3"> I have a boat</label><br>
|
|
39
|
+
</form>
|
|
40
|
+
|
|
41
|
+
<input id="btnClick" class="btnClick" name="btnClick" type="button" value="Submit" onclick="onClick()">
|
|
42
|
+
<div id="result" class="style"></div><br />
|
|
43
|
+
</body>
|
|
44
|
+
|
|
45
|
+
</html>
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
.style{
|
|
13
|
+
width: 400px;
|
|
14
|
+
height: 50px;
|
|
15
|
+
font-size: 18px;
|
|
16
|
+
line-height: 50px;
|
|
17
|
+
text-align: center;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
function onClick(){
|
|
23
|
+
const username = document.getElementById("uname");
|
|
24
|
+
const password = document.getElementById("pword");
|
|
25
|
+
const element = document.getElementById("result");
|
|
26
|
+
element.innerText = "You enter Username: " + username.value + " and Password: " + password.value;
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<h1>Login</h1>
|
|
33
|
+
|
|
34
|
+
<div class="container">
|
|
35
|
+
<p><label for="uname"><b>Username</b></label></p>
|
|
36
|
+
<p><input id="uname" class="unamecss" type="text" placeholder="Enter Username" name="username"></p>
|
|
37
|
+
|
|
38
|
+
<p><label for="pword"><b>Password</b></label></p>
|
|
39
|
+
<p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
|
|
40
|
+
|
|
41
|
+
<p><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()"></p>
|
|
42
|
+
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<div id="result" class="style"></div><br/>
|
|
46
|
+
|
|
47
|
+
</body>
|
|
48
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<title>Follow Link</title>
|
|
6
|
+
<style>
|
|
7
|
+
.style{
|
|
8
|
+
font-size: 26px;
|
|
9
|
+
}
|
|
10
|
+
</style>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<h1>Follow Link</h1>
|
|
14
|
+
<div id="result" class="style">
|
|
15
|
+
Please click <a href="about-us.html">About us link</a> for more information.
|
|
16
|
+
</div>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<title>Press Button</title>
|
|
6
|
+
<style>
|
|
7
|
+
.style{
|
|
8
|
+
width: 400px;
|
|
9
|
+
height: 50px;
|
|
10
|
+
font-size: 26px;
|
|
11
|
+
line-height: 50px;
|
|
12
|
+
text-align: center;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
<script>
|
|
16
|
+
function onClick(){
|
|
17
|
+
const element = document.getElementById("result");
|
|
18
|
+
element.innerText = "Button Pressed Successfully";
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<h1>Press Button</h1>
|
|
24
|
+
<div id="result" class="style"></div><br/>
|
|
25
|
+
<input id="btnClick" class="btnClick" name="btnClick" type="button" value="Click Button" onclick="onClick()">
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<title>Press Button</title>
|
|
6
|
+
<style>
|
|
7
|
+
.style{
|
|
8
|
+
width: 400px;
|
|
9
|
+
height: 50px;
|
|
10
|
+
font-size: 26px;
|
|
11
|
+
line-height: 50px;
|
|
12
|
+
text-align: center;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
<script>
|
|
16
|
+
function onClick(){
|
|
17
|
+
const element = document.getElementById("result");
|
|
18
|
+
element.innerText = "Button Pressed Successfully";
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<h1>Press Button</h1>
|
|
24
|
+
<div id="result" class="style"></div><br/>
|
|
25
|
+
<input id="btnClick" class="btnClick" name="btnClick" type="button" value="Click Button" onclick="onClick()">
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset='utf-8'>
|
|
5
|
+
<title>Select Option</title>
|
|
6
|
+
<style>
|
|
7
|
+
.style{
|
|
8
|
+
height: 50px;
|
|
9
|
+
font-size: 26px;
|
|
10
|
+
line-height: 50px;
|
|
11
|
+
}
|
|
12
|
+
</style>
|
|
13
|
+
<script>
|
|
14
|
+
function onClick(){
|
|
15
|
+
const cars = document.getElementById("cars");
|
|
16
|
+
const selectedOption = cars.options[cars.selectedIndex].text;
|
|
17
|
+
const element = document.getElementById("result");
|
|
18
|
+
element.innerText = "Option ( " + selectedOption + " ) has been selected successfully";
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<h1>Select Option</h1>
|
|
24
|
+
<label for="cars">Choose a car:</label>
|
|
25
|
+
|
|
26
|
+
<select name="cars" id="cars">
|
|
27
|
+
<option value="volvo">Volvo</option>
|
|
28
|
+
<option value="saab">Saab</option>
|
|
29
|
+
<option value="mercedes">Mercedes</option>
|
|
30
|
+
<option value="audi">Audi</option>
|
|
31
|
+
</select>
|
|
32
|
+
<input id="btnClick" class="btnClick" name="btnClick" type="button" value="Check select" onclick="onClick()">
|
|
33
|
+
<div id="result" class="style"></div><br/>
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|