webship-js 1.0.34 → 1.0.35
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/.github/workflows/github-actions.yml +1 -1
- package/examples/test--when--i-attach-file-to-feild.html +21 -3
- package/package.json +1 -1
- package/tests/features/test--when--i-attach-file-to-feild.feature +7 -6
- package/tests/features/test--when--i-press-button-by-attribute.feature +7 -3
- package/tests/step-definitions/webship.js +11 -5
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
- name: Install/Update Google Chrome browser
|
|
15
15
|
run: |
|
|
16
16
|
sudo apt install libu2f-udev
|
|
17
|
-
sudo apt-get install
|
|
17
|
+
sudo apt-get install libappindicator3-1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
|
|
18
18
|
export CHROME_BIN=/usr/bin/google-chrome
|
|
19
19
|
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
20
20
|
sudo dpkg -i google-chrome-stable_current_amd64.deb
|
|
@@ -11,11 +11,28 @@
|
|
|
11
11
|
</style>
|
|
12
12
|
<script>
|
|
13
13
|
function onClick() {
|
|
14
|
-
const
|
|
14
|
+
const imageUpload = document.getElementById("fileUpload");
|
|
15
15
|
const element = document.getElementById("result");
|
|
16
|
-
const
|
|
17
|
-
const filePathArr = myfile.value.split('\\');
|
|
16
|
+
const filePathArr = imageUpload.value.split('\\');
|
|
18
17
|
element.innerText = filePathArr[filePathArr.length - 1];
|
|
18
|
+
|
|
19
|
+
const file = imageUpload.files[0];
|
|
20
|
+
|
|
21
|
+
// Create a FileReader object
|
|
22
|
+
const reader = new FileReader();
|
|
23
|
+
|
|
24
|
+
// Set up the reader's onload event handler
|
|
25
|
+
reader.onload = function(e) {
|
|
26
|
+
// Get the image data URL
|
|
27
|
+
const imageDataUrl = e.target.result;
|
|
28
|
+
|
|
29
|
+
// Display the uploaded image
|
|
30
|
+
const imagePreview = document.getElementById('imagePreview');
|
|
31
|
+
imagePreview.src = imageDataUrl;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Read the selected file as Data URL
|
|
35
|
+
reader.readAsDataURL(file);
|
|
19
36
|
|
|
20
37
|
}
|
|
21
38
|
</script>
|
|
@@ -24,6 +41,7 @@
|
|
|
24
41
|
<body>
|
|
25
42
|
<label for="myfile">Select a file:</label>
|
|
26
43
|
<input type="file" id="fileUpload" name="fileUpload"><br><br>
|
|
44
|
+
<img id="imagePreview" src="#" width="150" height="150" />
|
|
27
45
|
<div id="result" class="style"></div><br />
|
|
28
46
|
<input type="submit" value="Submit" onclick="onClick()">
|
|
29
47
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Feature: An example of checking the attachment of a file to a field
|
|
1
|
+
Feature: An example of checking the attachment of a file to a field
|
|
2
2
|
|
|
3
3
|
As a tester,
|
|
4
4
|
I want to be able to attach a file (e.g., images) to a field
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
Scenario: Checking the attachment of an image to a field
|
|
7
|
+
Given I am on "/test--when--i-attach-file-to-feild.html"
|
|
8
|
+
When I attach the file "webshipco.png" to "#fileUpload"
|
|
9
|
+
And I press "Submit" by attr
|
|
10
|
+
And I wait 2 second
|
|
11
|
+
Then I should see "webshipco.png"
|
|
@@ -3,13 +3,17 @@ Feature: An example of pressing a button using its attributes.
|
|
|
3
3
|
As a tester,
|
|
4
4
|
I want to be able to press a button using its attributes.
|
|
5
5
|
|
|
6
|
-
Scenario: Verify that you can click a button
|
|
6
|
+
Scenario: Verify that you can click a button by specifying its ID with the '#' sign.
|
|
7
|
+
Given I am on "/test--when--i-press-button.html"
|
|
8
|
+
When I press "#btn-pressid" by attr
|
|
9
|
+
Then I should see "Button Pressed Successfully"
|
|
10
|
+
|
|
11
|
+
Scenario: Verify that you can click a button by specifying the 'ID' attribute without the '#' sign.
|
|
7
12
|
Given I am on "/test--when--i-press-button.html"
|
|
8
13
|
When I press "btn-pressid" by "id" attr
|
|
9
14
|
Then I should see "Button Pressed Successfully"
|
|
10
15
|
|
|
11
|
-
Scenario: Verify that you can click a button using
|
|
16
|
+
Scenario: Verify that you can click a button without specifying any attributes or signs, using only the value of one of its attributes.
|
|
12
17
|
Given I am on "/test--when--i-press-button.html"
|
|
13
18
|
When I press "btn-pressname" by attr
|
|
14
19
|
Then I should see "Button Pressed Successfully"
|
|
15
|
-
|
|
@@ -122,9 +122,12 @@ When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase, element) {
|
|
|
122
122
|
When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, itsCase, attr, attrCase) {
|
|
123
123
|
|
|
124
124
|
const hasASpace = attrValue.indexOf(' ');
|
|
125
|
-
|
|
126
125
|
var selector = '';
|
|
127
|
-
|
|
126
|
+
|
|
127
|
+
if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
|
|
128
|
+
selector = attrValue;
|
|
129
|
+
}
|
|
130
|
+
else if (!attr && hasASpace == -1){
|
|
128
131
|
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
129
132
|
}
|
|
130
133
|
else if (!attr && hasASpace > -1){
|
|
@@ -134,7 +137,7 @@ When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, func
|
|
|
134
137
|
selector = '[' + attr + '="' + attrValue + '"]';
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
browser.click(selector);
|
|
140
|
+
return browser.click(selector);
|
|
138
141
|
});
|
|
139
142
|
|
|
140
143
|
/**
|
|
@@ -730,11 +733,14 @@ Then(/^the "([^"]*)?" element should not contain "([^"]*)?"$/, function (selecto
|
|
|
730
733
|
|
|
731
734
|
/**
|
|
732
735
|
* Attaches file to field
|
|
733
|
-
* Example: When I attach the file "profileIcon.jpg" to "profileIconUpload"
|
|
736
|
+
* Example: When I attach the file "profileIcon.jpg" to "#profileIconUpload"
|
|
734
737
|
*
|
|
735
738
|
*/
|
|
736
739
|
When(/^(I|we)* attach the file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCase, fileUrl, element) {
|
|
737
|
-
|
|
740
|
+
var dirname = __dirname + '';
|
|
741
|
+
dirname = dirname.substring(0, dirname.lastIndexOf("/"));
|
|
742
|
+
|
|
743
|
+
return browser.setValue(element, dirname + '/assets/' + fileUrl);
|
|
738
744
|
});
|
|
739
745
|
|
|
740
746
|
/**
|