Skip to content

Commit

Permalink
[JS]: fix file upload example and add assertions [deploy site]
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha509 committed Oct 7, 2023
1 parent 51a6801 commit 470e0c9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
14 changes: 7 additions & 7 deletions examples/javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions examples/javascript/test/elements/fileUpload.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { suite } = require('selenium-webdriver/testing');
const {Browser, By} = require("selenium-webdriver");
const {Browser, By, until} = require("selenium-webdriver");
const path = require("path");
const assert = require('node:assert');

suite(function(env) {
describe('File Upload Test', function() {
Expand All @@ -18,10 +19,16 @@ suite(function(env) {
await driver.manage().setTimeouts({implicit: 5000});

// Navigate to URL
await driver.get('https://www.selenium.dev/selenium/web/upload.html');
await driver.get('https://the-internet.herokuapp.com/upload');
// Upload snapshot
await driver.findElement(By.id("upload")).sendKeys(image);
await driver.findElement(By.id("go")).submit();
await driver.findElement(By.id("file-upload")).sendKeys(image);
await driver.findElement(By.id("file-submit")).submit();

const revealed = await driver.findElement(By.id('uploaded-files'))
await driver.wait(until.elementIsVisible(revealed), 2000);
const data = await driver.findElement(By.css('h3'));

assert.equal(await data.getText(), `File Uploaded!`);
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ end
{{< /tab >}}

{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L21-L24">}}
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L22-L25">}}
{{< /tab >}}

{{< tab header="Kotlin" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ end
{{< /tab >}}

{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L21-L24">}}
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L22-L25">}}
{{< /tab >}}

{{< tab header="Kotlin" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ end
{{< /tab >}}

{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L21-L24">}}
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L22-L25">}}
{{< /tab >}}

{{< tab header="Kotlin" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ end
{{< /tab >}}

{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L21-L24">}}
{{< gh-codeblock path="/examples/javascript/test/elements/fileUpload.spec.js#L22-L25">}}
{{< /tab >}}

{{< tab header="Kotlin" >}}
Expand Down

0 comments on commit 470e0c9

Please sign in to comment.