3

I know the question has already been asked, but I’m having trouble uploading a file with karate. I have a file called "example.pdf" in my project. I put this document in a "assets" folder

I tried to build on the example of the documentation here. https://github.com/karatelabs/karate/tree/master/karate-core#file-upload

and here’s my code:

* configure driver = { type: '#(driverType)', executable: '#(driverExecutable)', addOptions: #(driverOptions), headless: #(driverHeadless), webDriverSession: #(webDriverSession), showDriverLog: true }
    Given waitFor('#upload)
    And driver.inputFile('#upload', '../assets/pdf-exemple.pdf')

My browser is chrome what am I missing ?

Thanks for your help

EDIT: Thank you for your feedback, I’ll try to clarify. Meanwhile I have some details. In fact the browser is chromedriver and geckodriver

const drivers = {
    path: "./src/test/java/drivers/",
    chromedriver: "95.0.4638.69",
    geckodriver: "0.30.0",
};

So I think I have to use the approach "multipart file". I tried this code, and my test passes without error, but does not handle the expected functionality (uploading an attachment)

And url 'https://url file file to upload/test'  //page where is the area to upload a file
And waitFor(data.inputPJ).click() //area where you click on the application to upload a file
And multipart file file = { read: '../../assets/pdf-exemple.pdf', filename: '../../assets/pdf-exemple.pdf' }
And method post

But in my application this code has no effect, in the application I should have : enter image description here

But the uploaded file doesn't appear, and I have:

enter image description here

The difficulty here is that I have no mistake. I will continue to try to understand the doc

I am at your disposal to provide more information

Olivier
  • 343
  • 2
  • 16
  • What steps have you taken to diagnose the problem? What did you expect to happen, and what happened instead? Currently, your question only explains that you are having trouble. Details on the trouble would help us help you. – tucuxi Dec 10 '21 at 16:13
  • Also please specify karate version. Ideally, you would provide a minimal example that reproduces the problem, so we do not have to guess everything that is missing. – tucuxi Dec 10 '21 at 16:16
  • the only suggestion I have is to read this: https://stackoverflow.com/a/61393515/143475 – Peter Thomas Dec 11 '21 at 05:31
  • I have tried to provide more details and continue to work on the documentation. Thank you for your answers – Olivier Dec 11 '21 at 15:27
  • Have you looked at https://github.com/karatelabs/karate#multipart-field? – George Artemiou Nov 28 '22 at 11:00

0 Answers0