Method Signature
await opensteer . uploadFile ( options : FileUploadOptions ): Promise < ActionResult >
Uploads files to a file input element (<input type="file">). Supports both single and multiple file uploads.
Local-only feature: This method is only available in local mode and is not supported in cloud mode. File paths must be accessible on the local filesystem where the browser is running.
Parameters
options
FileUploadOptions
required
Configuration for the file upload action Show FileUploadOptions properties
Array of absolute file paths to upload. For single file uploads, provide an array with one path.
Natural language description of the file input element. Used for AI-powered element resolution when element or selector are not provided.
Counter number from snapshot HTML to identify the exact file input element.
CSS selector to identify the file input element.
wait
false | ActionWaitOptions
Post-action wait configuration. Set to false to disable waiting, or provide options to customize wait behavior.
Returns
Show ActionResult properties
The action method name (“uploadFile”)
The namespace identifier for this session
Whether the element path was successfully persisted for future use
Path to the file where element path is stored
The actual selector used to find the element
Examples
Upload Single File
import path from 'path'
// Upload a single file
await opensteer . uploadFile ({
description: 'Profile picture upload' ,
paths: [ path . resolve ( __dirname , 'avatar.png' )]
})
Upload Multiple Files
import path from 'path'
// Upload multiple files to input with 'multiple' attribute
await opensteer . uploadFile ({
description: 'Document upload' ,
paths: [
path . resolve ( __dirname , 'document1.pdf' ),
path . resolve ( __dirname , 'document2.pdf' ),
path . resolve ( __dirname , 'document3.pdf' )
]
})
Upload with Selector
import path from 'path'
// Use CSS selector to identify file input
await opensteer . uploadFile ({
selector: 'input[type="file"]' ,
description: 'File upload input' ,
paths: [ path . resolve ( __dirname , 'data.csv' )]
})
Upload with Element Counter
import path from 'path'
// Use element counter from snapshot
await opensteer . uploadFile ({
element: 27 ,
description: 'Resume upload' ,
paths: [ path . resolve ( __dirname , 'resume.pdf' )]
})
import path from 'path'
// Upload file and submit form
await opensteer . uploadFile ({
description: 'File attachment' ,
paths: [ path . resolve ( __dirname , 'attachment.zip' )]
})
// Click submit button
await opensteer . click ({
description: 'Upload button'
})
Upload with Absolute Paths
// Using absolute paths directly
await opensteer . uploadFile ({
description: 'Image upload' ,
paths: [ '/Users/username/Pictures/photo.jpg' ]
})
Dynamic File Upload
import path from 'path'
import fs from 'fs'
// Get files from directory
const uploadsDir = path . resolve ( __dirname , 'uploads' )
const files = fs . readdirSync ( uploadsDir )
. map ( file => path . join ( uploadsDir , file ))
. filter ( file => fs . statSync ( file ). isFile ())
// Upload all files
await opensteer . uploadFile ({
description: 'Bulk file upload' ,
paths: files
})
Important Notes
Cloud Mode: This method throws an error in cloud mode because file paths must be accessible on the browser runtime, which is remote in cloud mode.
File Paths: Always use absolute file paths. Use path.resolve() or path.join() from Node.js to construct proper absolute paths.
Multiple Files: The file input element must have the multiple attribute to accept multiple files. If uploading multiple files to a single-file input, only the first file will be used.
Common Use Cases
Uploading profile pictures or avatars
Attaching documents to forms
Importing CSV or data files
Uploading images to galleries
Submitting file-based applications
click - Click upload buttons after selecting files
input - Fill other form fields
state - Check page state after upload