Is there a specific way to manage remote file uploads using selenium-webdriver in typescript?
Here is code that functions in javascript for this purpose:
import remote from 'selenium-webdriver/remote';
// import * as remote from 'selenium-webdriver/remote'; // used for typescript
browser.setFileDetector(new remote.FileDetector());
uploadElement.sendKeys(path.resolve(__dirname, f));
However, when attempting to implement this in typescript, the error
Property 'FileDetector' does not exist on type 'typeof remote'
is encountered. Both @types/selenium-webdriver
and selenium-webdriver
are already installed.
"@types/selenium-webdriver": "^2.53.39",
"selenium-webdriver": "^3.0.1"
Edit: Update based on bcherny's suggestion
import { FileDetector } from 'selenium-webdriver';
return fileDetector.handleFile(browser.driver, f).then((fPath) => {
browser.setFileDetector(fileDetector);
return uploadElement.sendKeys(path.resolve(__dirname, fPath))
}
Edit: Code that works
import * as remote from 'selenium-webdriver/remote';
browser.setFileDetector(new remote.FileDetector());
return uploadElement.sendKeys(path.resolve(__dirname, f))