Recommended Free Tools
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
After AutoIt submits a native Windows authentication dialog, return control to Selenium in three deliberate steps: wait until the dialog is gone, select the intended browser window, and set focus on the next DOM element. WinActive, ControlFocus, and ControlSend operate on native Windows windows and controls; SeleniumLibrary’s Set Focus To Element operates inside the browser DOM. Treating those as separate focus domains prevents the next Selenium keyword from targeting the wrong window or doing nothing.
Why Selenium appears to lose focus
A Windows authentication prompt is a native top-level window. It is not an element in the page DOM, so Selenium locators cannot inspect or type into it. AutoIt communicates with that window through the Windows desktop and its child controls. SeleniumLibrary communicates with WebDriver, browser windows, tabs, frames, and DOM elements.
When the prompt closes, desktop focus can remain on another window while the browser is still navigating. Even after WebDriver is pointed at the correct tab, the page may have no focused element. These are separate recovery operations:
- Native focus: identify, wait for, activate, and operate the authentication window with AutoIt.
- Browser-window focus: select the intended Selenium window or tab when more than one exists.
- DOM focus: use
Set Focus To Elementafter the browser is selected and the page is ready.
Prerequisites and dialog discovery
- Install SeleniumLibrary and AutoItLibrary in the same Robot Framework environment that runs the test.
- Run AutoIt’s Window Info Tool against the authentication prompt. Record a stable title or visible text, the window class, and control identifiers such as class and instance.
- Keep titles, control selectors, timeouts, and credentials in variables. Titles and visible text can change with localization, browser versions, and enterprise policy.
- Check the installed AutoItLibrary HTML help before copying keyword spellings. AutoItLibrary wraps AutoIt through the AutoItX COM interface, but argument conventions can differ between library versions.
Do not guess selectors such as [CLASS:Edit; INSTANCE:1]. Confirm each control with the Window Info Tool on the machine that runs the test, then replace the sample values below.
#1 Best Overall
- KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
- EASY SETUP: Experience simple installation with the USB wired connection
- VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
- SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
- FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.
The reliable hand-off sequence
- Wait for the native prompt. Use
Win Wait Active(or an equivalent wait) with a bounded timeout. A test that types immediately after navigation is racing the browser and Windows. - Focus the username control. Use
Control Focuswith the verified control selector, thenControl Sendthe username. Control-level input avoids sending keystrokes to whichever window happens to be active. - Focus and fill the password control. Repeat the same pair for the password control. Do not rely on tab order unless the dialog has no stable control identifiers.
- Submit at control level. Use
Control Clickor send the appropriate key to the submit control. AutoIt notes that some controls ignore clicks unless their parent window is active, so activate the window first when a click is not accepted. - Wait for disappearance. Poll until
Win Activereturns zero (or another explicit closed-window condition). This wait must finish before Selenium is used again. - Select the browser window. If authentication opened a new tab or window, use SeleniumLibrary’s window-selection keywords to choose the original or intended handle.
- Wait for page readiness. Wait for a page-specific element, URL, or other navigation condition rather than assuming that dialog closure means the DOM is ready.
- Restore DOM focus only when needed. Call
Set Focus To Elementwith a locator for the next field or control. It executes JavaScript focus on that element; it does not activate a Windows top-level window. - Continue with Selenium. Click, type, or assert only after the native-window, browser-window, and page-readiness waits have completed.
Complete Robot Framework pattern
The following is a template, not a universal dialog definition. Replace the title, control selectors, credentials, and final page locator with values from your environment.
*** Settings ***
Library SeleniumLibrary
Library AutoItLibrary
*** Variables ***
${AUTH_TITLE} Authentication Required
${USERNAME} %{AUTH_USERNAME}
${PASSWORD} %{AUTH_PASSWORD}
${PAGE_READY} css:body
${AUTH_TIMEOUT} 20s
*** Keywords ***
Authenticate With Native Dialog And Resume Browser
Win Wait Active ${AUTH_TITLE} timeout=${AUTH_TIMEOUT}
Control Focus ${AUTH_TITLE} ${EMPTY} [CLASS:Edit; INSTANCE:1]
Control Send ${AUTH_TITLE} ${EMPTY} [CLASS:Edit; INSTANCE:1] ${USERNAME}
Control Focus ${AUTH_TITLE} ${EMPTY} [CLASS:Edit; INSTANCE:2]
Control Send ${AUTH_TITLE} ${EMPTY} [CLASS:Edit; INSTANCE:2] ${PASSWORD}
Control Click ${AUTH_TITLE} ${EMPTY} [CLASS:Button; INSTANCE:1]
Wait Until Keyword Succeeds ${AUTH_TIMEOUT} 500ms Dialog Should Be Closed
Select Window MAIN
Wait Until Page Contains Element ${PAGE_READY} timeout=${AUTH_TIMEOUT}
Set Focus To Element ${PAGE_READY}
Dialog Should Be Closed
${active}= Win Active ${AUTH_TITLE}
Should Be Equal As Integers ${active} 0
*** Test Cases ***
Protected Page Can Be Used After Authentication
Open Browser https://example.test chrome
Authenticate With Native Dialog And Resume Browser
Click Element css:button[data-action="continue"]
Win Active returns a window handle when the specified window is active and zero when it is not. The sample’s polling keyword therefore checks a concrete state instead of sleeping for an arbitrary duration. If your AutoItLibrary version exposes slightly different names or argument order, use its installed HTML help and keep the same sequence.
Choosing selectors that survive environment changes
Prefer control identity over coordinates
Coordinates depend on display scaling, remote-desktop dimensions, window placement, and timing. A class-and-instance selector or another identifier reported by Window Info Tool targets the control itself. Keep the selector in a variable so a localized or redesigned dialog can be updated without rewriting the flow.
Rank #2
- Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
- Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
- Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
- Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
- Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites
Use titles carefully
A title containing a stable substring can be more resilient than an exact localized caption, but broad matching can select the wrong window. If several prompts share a title, add class or text criteria and verify the resulting handle before sending credentials.
Keep credentials out of source
The example reads credentials from environment variables. Use your CI secret store or Robot Framework variable files with equivalent protection; never print the password or include it in failure screenshots and logs.
Window and DOM focus are different operations
Select Window changes which browser window WebDriver commands address. It does not guarantee that a text input in the page has keyboard focus. Set Focus To Element locates an element and runs its DOM focus() method. Conversely, setting DOM focus cannot bring a minimized or background browser window to the foreground.
Rank #3
- All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
- Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
- Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
- Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
- Plastic parts in K120 include 51% certified post-consumer recycled plastic*
When a flow has multiple tabs, select by a known window name, handle, title, or URL instead of assuming that the newest handle is correct. After selection, wait for a page-specific readiness condition. Only then set focus on the element that receives the next keystrokes.
Troubleshooting by symptom
| Symptom | Likely cause | Fix |
|---|---|---|
| Credentials are typed nowhere | The dialog is not active, or the control selector is wrong. | Inspect the prompt with Window Info Tool; wait with Win Wait Active, then run Control Focus before Control Send. |
| Text goes to the wrong field | Global keystrokes or an unstable instance number were used. | Target each edit control directly and verify its class/instance on the test host. |
| The submit click is ignored | The parent window is not active or the control does not accept a background click. | Activate the dialog first, then use Control Click or send the submit key to the identified control. |
| The next Selenium keyword addresses another tab | WebDriver is still attached to a different window handle. | Explicitly select the intended window with SeleniumLibrary before locating page elements. |
Set Focus To Element fails immediately |
The native prompt is still closing or navigation has not produced the target DOM. | Wait for the dialog to be closed and for a page-specific readiness locator before setting DOM focus. |
Global Send is flaky |
Send goes to whichever window is active at that instant. |
Prefer ControlSend after ControlFocus whenever the control can be identified. |
| A selector works on one machine only | Titles, localization, browser builds, or policy changed. | Move environment-specific values to variables and re-capture identifiers with Window Info Tool on each supported image. |
| The test times out waiting for closure | Authentication failed, a second prompt appeared, or the title no longer matches. | Capture diagnostic window information, verify credentials and title matching, and distinguish a failure prompt from the expected authenticated window. |
When a different approach is better
| Approach | Scope | Strength | Trade-off |
|---|---|---|---|
| AutoIt control targeting | Native Windows dialog and controls | Deterministic input without depending on foreground coordinates | Requires Windows desktop access and environment-specific identifiers |
AutoIt global Send |
Currently active window | Simple for quick experiments | Race-prone when activation changes; less reliable than control-level sending |
| Pure Selenium | Browser DOM | Simpler and usually portable when login is an HTML form | Cannot locate a true native Windows authentication prompt |
If the application can expose credentials through an HTML login form instead of a desktop prompt, remove the AutoIt layer and keep the flow in Selenium. If the prompt is unavoidable, control-level AutoIt operations plus explicit waits are generally more stable than coordinate clicks or global keystrokes.
Reliability, timing, and diagnostics
- Use bounded waits rather than fixed sleeps. A wait can finish as soon as the state is true and fail with a useful timeout when it is not.
- Log window titles, handles, and selected browser-window identifiers, but redact credentials.
- Keep the authentication keyword small and reusable. A single keyword should own native-dialog handling, closure polling, browser selection, and page readiness.
- Run the same selector discovery and timing checks on every supported Windows image, especially when tests execute through remote desktop or under a different locale.
- When a failure is intermittent, record whether it occurred before activation, during control input, after submit, during window selection, or while waiting for the DOM. Those boundaries identify the focus domain that actually failed.
Or skip the browser setup
If your end goal is a website screenshot rather than a desktop authentication test, ScreenshotNeo can take the capture through one API request instead of requiring a local Selenium and AutoIt browser session. Its cleanup step accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response reports the page verdict and billing status in X-Page-Verdict and X-Billed headers.
For a direct capture, see the ScreenshotNeo API documentation and run:
Rank #4
- 【Dreamy Rainbow Gaming Keyboard】K521 Gaming Keyboard Adopts a Different LED Backlight Design, Upgraded on the Traditional LED Backlight Effect, Making the Light More Penetrating, Giving You a More Dazzling Visual Effect, Making Your Gaming Process More Enjoyable
- 【One Touch Opens & Visual Feast】The K521 Red Dragon Keyboard has a One-Touch on/off Lighting Button for Added Convenience. It also has a Three-Position Adjustable Breathing Mode and a Four-Position Adjustable Brightness Lighting Mode
- 【Mechanical Feeling & Fast Tapping】The PC Keyboard Keys are Designed for Mechanical Feeling, Giving You a Better Feel During Use and the Ability to Trigger Keys Quickly, Allowing You to Win All Your Games
- 【19 Keys Anti-Ghosting Keyboard】Anti-Ghosting Ensures Every Button Can Be Triggered. This Allows You to Trigger Key Combinations In The Game Accurately, And Each Skill Can Be Accurately Released to Increase Your Winning Rate. Redragon K521 Will Be Your Perfect Partner
- 【12 Multimedia Combination Keys】The K521 Wired Gaming Keyboard is Equipped with 12 Multimedia Keys That Can Greatly Enhance Your Gaming/Office Efficiency and Make It More Convenient to Use
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same request in 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)
And in 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 also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The service includes full-page captures with lazy images loaded, CSS-selector element captures, device presets and custom viewports, dark mode, retina scale, PDF controls, custom CSS and JavaScript, pre-capture clicks, selector hiding, selector/delay/network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone and geolocation settings, transparent backgrounds, resizing, configurable-TTL caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting, an OpenAPI specification, and compatibility with parameter names used by other screenshot APIs.
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000 per month | $0; no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing provides two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to get 1,000 screenshots each month without a card.
Frequently Asked Questions
Can I call Set Focus To Element while the native dialog is still open?
No. Selenium is addressing the browser DOM while AutoIt is addressing the Windows dialog. Finish the native interaction and confirm the dialog has closed before attempting DOM focus.
Best Value
- All-day Comfort: This USB keyboard creates a comfortable and familiar typing experience thanks to the deep-profile keys and standard full-size layout with all F-keys, number pad and arrow keys
- Built to Last: The spill-proof (2) design and durable print characters keep you on track for years to come despite any on-the-job mishaps; it’s a reliable partner for your desk at home, or at work
- Long-lasting Battery Life: A 24-month battery life (4) means you can go for 2 years without the hassle of changing batteries of your wireless full-size keyboard
- Simply plug the USB receiver into a USB port on your desktop, laptop or netbook computer and start using the keyboard right away without any software installation
- Simply Wireless: Forget about drop-outs and delays thanks to a strong, reliable wireless connection with up to 33 ft range (5); K270 is compatible with Windows 7, 8, 10 or later
What should I preserve when upgrading AutoItLibrary?
Preserve the verified Window Info Tool selectors and the state sequence, then check the installed library’s HTML help for any changed keyword spelling or argument order.
Why does a successful authentication still produce a stale page?
Authentication completion and page navigation are separate events. Select the intended browser window and wait for a locator, URL, or other application-specific readiness condition before interacting with the page.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →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.

