I'm using Browserstack to perform some test on a web app hosted on my local machine (Windows 10). I've written tests using Mocha and selenium-webdriver.
I need to test a fileUpload, picking a file from my local environment. Browsing on Browserstack documentation I think I've found which should be the solution and it's working both with Windows and Mac OS configurations.
First of all I'm using a FileDetector
driver.setFileDetector(new remote.FileDetector);
Then I'm using sendKeys() on the fileInput WebElement
fileInput.sendKeys(imageFilePath);
Instead, when I run a test session on a real iOS device (iOS 13 - iPhone 8.0) I get:
WebDriverError: Appium error: File upload is not supported on real iOS devices
at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: remote.FileDetector.handleFile(/home/admin/BuildAgent/work/491c0dc9a984bb27/test/resources/images/imageUploader/partImage02.jpg)
at WebDriver.schedule (node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at zip.addFile.then.then.then.encodedZip (node_modules/selenium-webdriver/remote/index.js:586:27)
From: Task: WebElement.sendKeys()
at WebElement.sendKeys (node_modules/selenium-webdriver/lib/webdriver.js:2185:43)
at [...]
and on an Android real device (e.g. Android Pixel 4 - default browser):
UnsupportedOperationError: The URL '/wd/hub/session/45359c9c6c467dd8f00f6c1a638c993fe933bf67/file' did not map to a valid resource
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:534:11)
at doSend.then.response (node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: remote.FileDetector.handleFile(/home/admin/BuildAgent/work/491c0dc9a984bb27/test/resources/images/imageUploader/partImage02.jpg)
at WebDriver.schedule (node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at zip.addFile.then.then.then.encodedZip (node_modules/selenium-webdriver/remote/index.js:586:27)
From: Task: WebElement.sendKeys()
at WebElement.sendKeys (node_modules/selenium-webdriver/lib/webdriver.js:2185:43)
at [...]
Should I assume that file upload from local machine is not supported on Android real devices as well as on iOS, using those tools (Browserstack, selenium-webdriver) ?
Thanks
LocalFileDetector supports only desktop browsers and not mobile devices. You can check here: https://github.com/appium/appium/issues/9120