-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathfileUpload.spec.js
35 lines (26 loc) · 1.16 KB
/
fileUpload.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { suite } = require('selenium-webdriver/testing');
const {Browser, By, until} = require("selenium-webdriver");
const path = require("path");
const assert = require('node:assert');
suite(function(env) {
describe('File Upload Test', function() {
let driver;
before(async function() {
driver = await env.builder().build();
});
after(() => driver.quit());
it('Should be able to upload a file successfully', async function() {
const image = path.resolve('./test/resources/selenium-snapshot.png')
await driver.manage().setTimeouts({implicit: 5000});
// Navigate to URL
await driver.get('https://the-internet.herokuapp.com/upload');
// Upload snapshot
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!`);
});
});
}, { browsers: [Browser.CHROME, Browser.FIREFOX]});