I am struggling to upload a file using qawolf and puppeteer through an input. According to qawolf, they plan to develop their own upload file feature, so in the meantime I need to use the one from puppeteer's (which qawolf is dependent of).
However, I keep running into the error:
FAIL .qawolf/uploadDataSetInProject.test.js (17.394 s)
✕ uploadDataSetInProject (13354 ms)
● uploadDataSetInProject
TypeError: uploadElement.uploadFile is not a function
42 | await page.fill('[placeholder="Data set description"]', "I am a dataset description");
43 | const uploadElement = await page.$('#dataset-inputs > div.project-upload-container > div.project-upload-dataset > input[type=file]');
> 44 | await uploadElement.uploadFile('../assets/TestFile10Mo.csv');
| ^
45 | await qawolf.scroll(page, "html", { x: 0, y: 571 });
46 | await page.click(".button-save");
47 | await page.click(".comments-button");
at Object.test (uploadDataSetInProject.test.js:44:23)
Whereas the puppeteer's docs clearly state that the function uploadFile
exists !
Where does this problem come from ? How come uploadFile is not a function ?
Here is my code:
const qawolf = require("qawolf");
let browser;
let context;
beforeAll(async () => {
browser = await qawolf.launch();
context = await browser.newContext();
await qawolf.register(context);
});
afterAll(async () => {
await qawolf.stopVideos();
await browser.close();
});
test("uploadDataSetInProject", async () => {
const page = await context.newPage();
[...]
await page.click('[placeholder="Data set description"]');
await page.fill('[placeholder="Data set description"]', "I am a dataset description");
const uploadElement = await page.$('#dataset-inputs > div.project-upload-container > div.project-upload-dataset > input[type=file]');
await uploadElement.uploadFile('../assets/TestFile10Mo.csv'); // The test crashes here
await page.click(".button-save");
await page.click(".comments-button");
await page.click(".size");
await page.click(".off");
});
Aucun commentaire:
Enregistrer un commentaire