问题
I'm testing a file upload feature and trying to upload remote files(e.g. https://s3.amazonaws.com/some_dir/some_file). Using type() throws an error stating the path is not absolute. Is this supported by intern? If yes, how should it be done?
回答1:
Leadfoot handles file uploads like this:
- The test calls
type
on a file input element with the local (to Intern) path of a file. This file must exist on the system running Intern. You can get an absolute path to it by usingrequire.toUrl
(e.g.,element.type(require.toUrl('./someFile.txt'))
). - Leadfoot silently uploads the file to the remote Selenium/WebDriver server and determines its path on the remote system.
- Leadfoot calls
sendKeys
on the input element using the path of the newly uploaded file on the remote server.
The end goal is for the remote browser to be able to select a file for a file input and send it somewhere. For that to work, the file must exist on the remote system (the one running the browser being tested).
来源:https://stackoverflow.com/questions/37217884/can-you-upload-remote-files-with-intern-leadfoot