I am working on an automation project that requires a file upload using Karate UI. Me and my team tried a few alternatives and using driver.inputFile()
seemed to work just fine. However, we also run tests on headless mode with Browserstack, where we noticed the same line would not work, giving the following error:
js failed:
>>>>
01: driver.inputFile(cleoPortal.inputBox, "C:\\Users\\hello\\Documents\\documents\\text-sample1.txt")
<<<<
org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (inputFile) on com.intuit.karate.driver.chrome.ChromeWebDriver@4cfcac13 failed due to: Unknown identifier: inputFile
- <js>.:program(Unnamed:1)
After looking at the trace, it looks to me that, for some reason, when running headless, the driver does not have this method defined. When investigating, I also confirmed that the 2 ways of running initialize different driver objects, com.intuit.karate.driver.chrome.Chrome
for the local run and com.intuit.karate.driver.chrome.ChromeWebDriver
for the headless.
Headless: Headless run report img
Local: Local run report img
After digging a little into the karate source code, I found that ChromeWebDriver.java extends the WebDriver class, while Chrome.java extends DevToolsDriver, and that the former does not have the method inputFile() that we're trying to use.
Considering this, my question is: Would it be possible to implement this method in WebDriver? Or are there any alternatives we can try? I would also like to point out that I tried regular input() but it didn't work.
I did not setup any demo project since I am not really sure how to reproduce the issue without heavy configuration and the aid of other tools, but I'm open to suggestions in case it helps solving the problem. Sorry about that!
Thanks in advance for the help!