Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File upload is not working when using Web driver when running test on Sauce Lab or Remote Grid #2541

Open
djasani opened this issue Apr 1, 2024 · 7 comments

Comments

@djasani
Copy link

djasani commented Apr 1, 2024

We can use input method on file input element and set file path as value. This approach works fine If you are running browser locally as it can find the file but when running same tests it does not work.

This is done in Selenium Web Driver using http Rest call. We can use similar implementation on Karate side to support this feature.

We can have something like,

driver.upload(input element, filePath) and implemented this.

I am able to make this work using workaround but this will be great if file upload on remote execution host is supported out of the box in Karate framework

@ptrthomas
Copy link
Member

tagging this as help wanted. personally I feel workarounds are fine, refer: https://stackoverflow.com/a/61393515/143475

@djasani
Copy link
Author

djasani commented Apr 2, 2024

Thanks @ptrthomas for the response. The problem with Robot workaround is, it only works if file exists on the host where tests are executing. We execute our test suite on Saucelab from the pipeline. Currently as a workaround, we are using RemoteWebDriver's hidden API to post attachement to the remote host and then upload file from remote host location. I did cloned Karate code today and was able to make file upload working for both WebDriver and DevToolsDriver.

@ptrthomas
Copy link
Member

@djasani yes if you can submit a PR, that would be the best option

@djasani
Copy link
Author

djasani commented Apr 3, 2024

@ptrthomas After finishing my implementation I realized that you have already implemented this feature for DevToolsDriver. It's has been implemented in the method "inputFile". I did not find similar method for WebDriver and PlaywrightDriver so I will implement and create PR after that.

Somehow I am not able to run using PlaywrightDriver from Karate-Core. It opens Chromium but just keeps waiting after WebSocket connection is established. However I am able to make it work for Playwright Driver in Karate-Playwright module.

@djasani
Copy link
Author

djasani commented Apr 4, 2024

@ptrthomas I have executed LocalParallelRunner, PlaywrightRunner and LocalSingleRunner (chromedriver) after my changes. Previously we were only performing file upload when browserType was only Chrome. I have commented following line in the feature file 08.feature so file upload occurs for all different browserType.

#* if (driverType != 'chrome') karate.abort()

I also had to refactor 09.feature file to make this run in playwright. I believe playwright is handling frames differently.

Please find attached here are the results for karate-e2e-tests
karate-reports-LocalParallelRunner.zip
karate-reports-PlaywrightRunner.zip
karate-reports-chromedriver-LocalSingleRunner.zip

@ptrthomas
Copy link
Member

@djasani thanks ! I'm a little extra busy at the moment so will request if @f-delahaye can take a look

@f-delahaye
Copy link
Contributor

@ptrthomas Will do.
@djasani out of curiosity, any idea what was not working/was changed in 09.feature for Playwright?

@ptrthomas ptrthomas added the bug label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants