Use the page’s real input[type='file'] element and send it an absolute, readable file path. Protractor/Selenium sends that path directly to Chrome’s file control, so no operating-system file picker is needed. Headless Chrome uses the same WebDriver upload path as headed Chrome. After setting the file, trigger the page’s upload action and wait for the application’s success state.
The supported fix: send an absolute path to the file input
Selenium’s file-upload API is designed for this case: when the target is an input element whose type is file, sendKeys receives the full path of the file to upload. In Protractor, locate that element directly instead of clicking a styled “Choose file” button.
const path = require('path');
const imagePath = path.resolve(__dirname, 'fixtures/photo.png');
const fileInput = element(by.css("input[type='file']"));
fileInput.sendKeys(imagePath);
// Trigger the page's submit/upload action, then wait for its success indicator.
The selector and final action are application-specific. Some pages upload immediately when the input changes; others require a Submit, Upload, or Continue button. The supported part is assigning the absolute path to the actual file input.
Why this works without opening a dialog
The native picker belongs to the operating system, not to the DOM. WebDriver does not need to control that window. Sending keys to the file input supplies the browser with the file selection through its automation interface, then the page receives the normal change event. This is why GUI automation workarounds such as simulated mouse clicks, clipboard tricks, or desktop-only dialog libraries are unnecessary and unreliable in headless runs.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Make the Protractor test deterministic
Resolve and validate the fixture before WebDriver runs
A relative path depends on the process working directory. Resolve it from a known location, normally the test file or repository fixture directory, and log it while diagnosing CI failures.
const fs = require('fs');
const path = require('path');
const imagePath = path.resolve(__dirname, 'fixtures/photo.png');
console.log(`Uploading fixture: ${imagePath}`);
if (!fs.existsSync(imagePath)) {
throw new Error(`Upload fixture is missing: ${imagePath}`);
}
const fileInput = element(by.css("input[type='file']"));
fileInput.sendKeys(imagePath);
The path must exist on the machine that can provide the file to the browser session. Checking it before sendKeys turns an obscure WebDriver failure into a useful test error.
Wait for the control, then perform the page action
Do not race the application’s rendering. Wait until the input is present and usable, assign the file, click the application’s upload control if one exists, and wait for a success condition owned by the page.
const EC = protractor.ExpectedConditions;
const fileInput = element(by.css("input[type='file']"));
const uploadButton = element(by.css('[data-test="upload-submit"]'));
const successMessage = element(by.css('[data-test="upload-success"]'));
browser.wait(EC.presenceOf(fileInput), 10000, 'File input was not rendered');
browser.wait(EC.elementToBeClickable(uploadButton), 10000, 'Upload action is not clickable');
fileInput.sendKeys(imagePath);
uploadButton.click();
browser.wait(EC.visibilityOf(successMessage), 30000, 'Upload did not reach the success state');
Replace the data-test selectors with selectors from your application. If selecting a file automatically starts the upload, omit the button click and wait for the request-complete indicator instead. A fixed sleep can help prove that timing is the problem, but a condition tied to the page’s actual state is the production solution.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Use a complete headless configuration
Modern Chrome headless shares Chrome’s normal browser code and WebDriver behavior. Switching from headed to headless therefore should not change the upload API.
// protractor.conf.js
exports.config = {
framework: 'jasmine',
specs: ['specs/upload.e2e.js'],
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
}
}
};
The important setting for uploads is not a special headless flag; it is targeting the file input and supplying a path that the browser session can read.
Hidden and styled file controls
Many interfaces hide the real input and style a label or button. Target the hidden input itself. Selenium documents strictFileInteractability as the capability that controls strict interaction checks for file inputs; strict checks are off by default. In that common configuration, sending the path directly works even when the input is visually hidden.
If your session enables strict file interactability or the application’s JavaScript requires the control to be enabled, make the smallest application-level change needed: render the real input, enable it, or adjust the test fixture so the control is available. Do not replace it with an operating-system dialog script. Preserve the real input[type='file'], because that is the element WebDriver knows how to upload to.
Recommended Free Tools
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
CI and remote Chrome: the path must reach the browser host
A local run often uses one machine for the test process and Chrome. A Remote WebDriver run may use separate machines or containers. A path such as /home/runner/work/app/fixtures/photo.png can exist on the test client while being absent from the worker running Chrome. In that case, correct selectors still produce a failed upload.
Use a Local File Detector for remote sessions
Selenium’s JavaScript bindings can bundle a local file and transfer it to the remote browser host when a Local File Detector is configured. Set the detector on the WebDriver instance before calling sendKeys.
const webdriver = require('selenium-webdriver');
const path = require('path');
// Configure this for a Remote WebDriver session.
browser.setFileDetector(new webdriver.remote.FileDetector());
const imagePath = path.resolve(__dirname, 'fixtures/photo.png');
element(by.css("input[type='file']")).sendKeys(imagePath);
The exact construction can vary with the selenium-webdriver package version used by your Protractor installation, so keep the detector API aligned with that binding. The requirement does not change: the remote session needs a detector that transfers the local fixture, or the fixture must already be mounted where the browser runs.
CI checklist
- Print the resolved absolute path in the job log.
- Confirm the fixture is checked out or generated in the job workspace.
- Check file permissions and readability for the test process.
- Determine whether Chrome runs in the same container, a Selenium node, or another host.
- Configure a JavaScript Local File Detector for a remote session, or mount/copy the fixture to the browser host.
- Keep the file input selector and the post-upload success selector independent of visual styling.
Diagnose failures by symptom
| Symptom | Likely cause | Fix |
|---|---|---|
sendKeys reports that the element is not a file input |
The selector found a label, button, wrapper, or a text input. | Inspect the DOM and select the actual input[type='file']. If there are several, scope the selector to the correct form. |
| Works locally but fails in CI | The absolute path points to a file that is not present or readable in the CI workspace. | Resolve from the checked-out workspace, log the path, verify the fixture before the test, and check permissions. |
| Remote session says the file cannot be found | The path exists on the client but not on the machine running Chrome. | Set a Local File Detector in the JavaScript binding or make the fixture available on the browser host. |
| The page shows no uploaded image | The input was set, but the application still requires a submit/change action or client-side processing has not finished. | Invoke the page’s upload action when required and wait for its processing-complete or success indicator. |
| A hidden input is rejected by the session | Strict file-interaction checks or application logic requires a usable control. | Check the session’s strictFileInteractability setting and make the smallest DOM/application change that leaves the real input available. |
| Intermittent timeout after a successful selection | The test is synchronized to elapsed time rather than an application condition. | Wait for a specific upload status, preview, network-complete state exposed by the app, or success message; use sleeps only for diagnosis. |
| The test opens a picker and hangs in headless mode | The test clicked a native-dialog trigger instead of using WebDriver’s file-input API. | Stop automating the desktop dialog. Send the absolute path directly to the file input. |
Compare the possible fixes before changing code
When choosing between a selector change, a headless configuration change, and a remote-session change, evaluate the five conditions that determine whether an upload can work:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
| Check | What “correct” looks like | What failure indicates |
|---|---|---|
| Element target | The command addresses the real input[type='file']. |
You are automating a visual wrapper or the wrong form. |
| Path | The path is absolute and readable before WebDriver is called. | The fixture location or permissions are wrong. |
| Remote transfer | The browser host has the file, or a Local File Detector transfers it. | Client and browser machines do not share the filesystem. |
| Hidden-control policy | The session’s strict interaction policy permits the operation, and the input is enabled as required by the app. | Interaction checks or application JavaScript are blocking the input. |
| Post-upload synchronization | The test waits for the application’s real success state. | The upload may be correct but the assertion runs too early. |
When to use each approach
- Local headed or headless Chrome: select the file input and send an absolute path. No file detector is needed when the test and browser share a filesystem.
- Remote WebDriver: use the same selector and path logic, plus a Local File Detector or a fixture mounted on the browser host.
- Hidden input: target the input directly; only alter visibility or enabled state when strict interaction or application code requires it.
- Unstable result: improve condition-based waits and assert an application-level success state instead of adding longer sleeps.
Or skip the browser setup
If your goal is a clean screenshot of a page after an upload workflow—not to test the upload itself—ScreenshotNeo can capture the page with one HTTP request. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
See the ScreenshotNeo API documentation for all options, then call the endpoint with your target URL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo supports full-page and element captures, lazy-image loading, device presets and custom viewports, retina scale, PDF output, custom CSS and JavaScript, clicks, selector waits, delays, network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to try it without a card.
Free tools Windows power users keep installed
One-click scans. No signup required.
Frequently Asked Questions
Why does clicking the upload button fail only in headless Chrome?
A click may be trying to open a native operating-system picker, which headless Chrome cannot display. Send the path to the file input instead; the upload API does not require the picker.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Should I use a relative or absolute path in sendKeys?
Use an absolute path. Resolve it in code and verify that the file exists before calling sendKeys, especially in a CI workspace.
What should I assert after selecting the image?
Assert the application’s own completion state, such as a success message, completed preview, or upload status. File selection alone does not prove that client-side processing or the server upload finished.
Do I need a Local File Detector for every Protractor test?
No. It is needed when the WebDriver session is remote and the fixture is local to the test client. A same-host headed or headless session can read a shared local path directly.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

