Migrating from appium-windows-driver
Client-side migration guide for test suites written against the deprecated
appium-windows-driver
(a proxy to Microsoft's WinAppDriver) that now run on Appium WinCore Driver.
Code samples use the Appium .NET client
(Appium.WebDriver); the same changes apply to any WebDriver client, since
they are about capabilities, locators and executeScript arguments.
For most suites the migration is a handful of one-line changes. Start with the checklist.
What changes under the hood¶
appium-windows-driver |
Appium WinCore Driver | |
|---|---|---|
| Automation backend | WinAppDriver (WinAppDriver.exe, separate install, unmaintained) |
Built-in .NET UI Automation server, spawned per session |
| Appium server | Appium 3 (driver 5.x); not compatible with Appium 4 | Appium 4 (driver 4.x); Appium 3 needs driver 3.x |
| Extra host setup | Developer Mode, WinAppDriver install (install-wad), APPIUM_WAD_PATH |
None |
automationName |
Windows |
Wincore |
Everything WinAppDriver-specific (Developer Mode, install-wad,
APPIUM_WAD_PATH, systemPort, wadUrl) is no longer needed. The wire
protocol is plain W3C WebDriver, so your client library does not change.
Migration checklist¶
- Install the new driver:
appium driver install --source=npm appium-wincore-driver(Appium 4). Uninstall the old one if it is still present. - Set
AutomationNametoWincore. - Remove capabilities that no longer exist (table).
- Replace
remotePathwithpathinwindows: deleteFile/windows: deleteFolder(and expand%TEMP%-style variables yourself), andfpswithvideoFpsinwindows: startRecordingScreen(details). - Write
windows: <command>with a space (windows:closeAppis not recognised; see .NET client notes). - Re-run your suite. XPath is now 2.0, with stricter types, so a few expressions may need a tweak, and XPath-heavy tests may need anchoring for speed (locators).
Session setup¶
Before (appium-windows-driver)¶
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
var options = new AppiumOptions
{
PlatformName = "Windows",
AutomationName = "Windows",
App = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App",
};
options.AddAdditionalAppiumOption("ms:waitForAppLaunch", 5);
var driver = new WindowsDriver(new Uri("http://127.0.0.1:4723/"), options);
After (WinCore)¶
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
var options = new AppiumOptions
{
PlatformName = "Windows",
AutomationName = "Wincore", // was "Windows"
App = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App",
};
options.AddAdditionalAppiumOption("ms:waitForAppLaunch", 5);
var driver = new WindowsDriver(new Uri("http://127.0.0.1:4723/"), options);
app accepts the same values as before: a UWP AUMID, an .exe path, or
Root for the desktop.
Capabilities¶
Capabilities not listed here (platformName, app, appTopLevelWindow,
appArguments, appWorkingDir, ms:forcequit, prerun, postrun,
newCommandTimeout) work as before.
| Capability | Status | Notes |
|---|---|---|
appium:automationName |
Changed | Wincore |
appium:ms:waitForAppLaunch |
Changed | Seconds (<=120) or milliseconds (>120); the old limit was 50 s. It is now an upper limit while the driver polls for the app window, not a fixed wait, so it usually returns sooner. A default wait applies when unset |
appium:ms:experimental-webdriver, appium:deviceName |
Ignored | Accepted so existing suites keep working, but they have no effect |
appium:systemPort |
Ignored | There is no HTTP listener; the driver talks to its server over stdin/stdout. A log line notes the capability is ignored |
appium:createSessionTimeout |
Removed | A WinAppDriver start-up workaround |
appium:wadUrl |
Removed | There is no WinAppDriver to point at |
appium:shouldCloseApp |
New | Close the window at session end. Default true |
appium:isolatedScriptExecution |
New | Skip the user profile for PowerShell scripts |
appium:smoothPointerMove, delayBeforeClick, delayAfterClick |
New | Mouse easing and click delays |
appium:webviewEnabled and related |
New | WebView2 / Chrome / Edge via CDP |
appium:perfMetrics |
New | Per-session performance counters |
See the Capabilities reference for the full list.
Locators¶
accessibility id, name, class name and id (decimal RuntimeId) work
as before. What differs:
| Strategy | .NET | Change |
|---|---|---|
tag name |
MobileBy.TagName("Button") |
PascalCase now matches ControlType; see below |
-windows uiautomation |
MobileBy.WindowsAutomation("new PropertyCondition(AutomationElement.NameProperty, 'OK')") |
New. Parsed natively, not executed |
css selector |
By.CssSelector("Button[name='OK']") |
New. Compiled to a native condition |
xpath |
By.XPath("//Button[@Name='OK']") |
XPath 2.0 instead of 1.0, and always evaluated over the whole searched subtree; see below |
tag name. Button (PascalCase) matches the language-neutral
ControlType; lowercase button matches the OS-localized control type, as
the old driver's tag name did. Switch to PascalCase to make a suite
independent of the Windows display language.
By.Id / By.Name / By.ClassName. The .NET client sends these as CSS
selectors (#x, *[name ="x"], .x), which WinCore compiles to
AutomationId, Name and ClassName conditions. By.Id therefore matches
the AutomationId, while MobileBy.Id matches the RuntimeId. Prefer
the MobileBy.* factories to be explicit.
XPath version. WinCore supports XPath 2.0, so matches(), ends-with(),
lower-case() and sequence comparisons are available. The price is stricter
typing: every attribute value is a string and is no longer converted silently.
//Button[@Name = 7] and //*[@Value > 5] fail on windows where some element
has a non-numeric value, and contains(.//Text/@Name, "x") fails when the path
matches several elements. Quote the number (@Name = "7"), convert explicitly
(number(@Value) > 5), or move the condition into a predicate
(.//Text[contains(@Name, "x")]). An expression must also return elements:
count(//Button) is an invalid selector. See the
XPath section for details.
XPath speed. WinCore evaluates XPath against an XML snapshot of the whole
search-root subtree, so an absolute //... query on a very large window can
be slow, while the other strategies are native UIA searches. Anchor with a
native locator and run XPath relative to it:
var grid = driver.FindElement(MobileBy.AccessibilityId("ServersGrid"));
var row = grid.FindElement(By.XPath(".//DataItem[starts-with(@LegacyValue, 'db-01;')]"));
Details and timings: Absolute vs. relative lookup.
New element attributes. Every element exposes Value, LegacyValue,
LegacyName, LegacyDescription, LegacyRole and LegacyState, which make
content of MSAA grids (DevExpress, DataGridView, VB6, Delphi) locatable
without extra setup. See Standard accessibility values and the
element attributes reference.
Extension commands¶
Call them through ExecuteScript exactly as before. Pass a single
dictionary (or an element for commands that take only elementId):
// Element-only commands: pass the element
driver.ExecuteScript("windows: invoke", driver.FindElement(MobileBy.AccessibilityId("num5Button")));
// Everything else: one dictionary of named arguments
var icon = driver.FindElement(MobileBy.Name("Notepad"));
driver.ExecuteScript("windows: click", new Dictionary<string, object>
{
["elementId"] = icon.Id,
["times"] = 2,
["interClickDelayMs"] = 100,
});
Unchanged¶
windows: click, scroll, hover, keys, getClipboard, setClipboard,
launchApp, closeApp, stopRecordingScreen and powerShell keep their
names and arguments.
Changed arguments¶
| Command | Old | New |
|---|---|---|
windows: deleteFile |
remotePath; environment variables such as %TEMP% expanded |
path; no variable expansion; throws File not found if the file is missing |
windows: deleteFolder |
remotePath; environment variables such as %TEMP% expanded |
path; no variable expansion |
windows: startRecordingScreen |
fps |
videoFps (also new: outputPath, audioInput) |
windows: clickAndDrag |
durationMs was the pause between pressing the button and starting the move (default 5000) |
durationMs is how long the move itself takes (default 500); there is no pause before moving |
// Before
driver.ExecuteScript("windows: deleteFile", new Dictionary<string, object> { ["remotePath"] = @"C:\temp\a.txt" });
// After
driver.ExecuteScript("windows: deleteFile", new Dictionary<string, object> { ["path"] = @"C:\temp\a.txt" });
deleteFile / deleteFolder still need the modify_fs insecure feature
(appium --allow-insecure=wincore:modify_fs).
Expand variables yourself before the call (e.g. build the path from
Environment.GetEnvironmentVariable("TEMP")). For a hold-then-drag, use W3C
Actions with a pause between the button press and the move.
PowerShell¶
var output = driver.ExecuteScript("powerShell", new Dictionary<string, object>
{
["script"] = "Get-Process notepad -ErrorAction SilentlyContinue",
});
Same call as before (script or command; a plain string also works).
Differences:
- WinCore does not gate
powerShellbehind thepower_shellinsecure feature. Anyone who can reach the Appium server can run PowerShell, so keep the server off untrusted networks. - Any stderr output fails the command with that text, even when the exit
code is 0. The old driver failed only on a non-zero exit code. Scripts
using
Write-Errorwith-ErrorAction Continue, or native tools that write progress to stderr, now fail.
New commands worth adopting¶
| Command | Use |
|---|---|
windows: setValue, getValue |
Set/read a value through ValuePattern |
windows: selectFromCombobox |
Open a combo/list/tree, pick an entry by exact text, close it |
windows: select, expand, collapse, toggle, scrollIntoView, setFocus |
UIA patterns, with success verification on MSAA controls |
windows: getWindows, switchToWindowByTitle |
Find windows with no title or by partial title |
windows: cacheRequest |
Expose RawView elements |
windows: getMonitors, getDpiScale, getDeviceTime |
Environment info |
windows: getNativeChildren |
Walk the MSAA tree for legacy controls |
Full reference: Execute methods.
Windows, input and the rest of the WebDriver surface¶
- Window handles.
driver.WindowHandleslists only windows with a title.windows: getWindowsreturns every visible top-level window as{ handle, title, className }; passhandletodriver.SwitchTo().Window(...).SwitchTo().Window("root")returns to the desktop. - Actions. Selenium's
ActionBuilder/PerformActionswork against mouse, keyboard and wheel sources. Touch and pen pointers are not supported (the Sticky Notes pen sample from the old test suite will not port as is). See W3C Actions. - Element click vs. invoke.
element.Click()simulates a mouse click. For controls that ignore pointer events,windows: invokecalls the UIAInvokePatterndirectly (the Calculator sample does this). - Typing.
element.SendKeys(...)focuses the element and types independently of the keyboard layout.
.NET client notes¶
- Package.
Appium.WebDriver(current major: 9.x). The bundled Calculator sample uses 7.2.0. Both work; use whichever your suite is already on. - Driver class.
WindowsDriverandAppiumOptionsare unchanged. The class only setsplatformName;AutomationNameis yours to set. windows:needs a space. WinCore matches execute-method names exactly.WindowsDriver.CloseApp()andLaunchApp()send the name without a space (windows:closeApp), which the driver does not map. Call the commands yourself instead:
- Context switching.
WindowsDriver.Contextis hard-wired toNATIVE_APPand its setter throws, so the typed API cannot enter a WebView or IE context. Plain UIA suites are unaffected. - Not applicable on Windows.
HideKeyboard,PressKeyCodeand other mobile-only members were not supported by the old driver either.
Putting it together¶
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
var options = new AppiumOptions
{
PlatformName = "Windows",
AutomationName = "Wincore",
App = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App",
};
var driver = new WindowsDriver(new Uri("http://127.0.0.1:4723/"), options);
try
{
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
foreach (var id in new[] { "num5Button", "plusButton", "num3Button", "equalButton" })
{
driver.ExecuteScript("windows: invoke", driver.FindElement(MobileBy.AccessibilityId(id)));
}
Console.WriteLine(driver.FindElement(MobileBy.AccessibilityId("CalculatorResults")).Text);
}
finally
{
driver.Quit();
}
Troubleshooting¶
| Symptom | Likely cause |
|---|---|
| Session creation fails with an automation-name error | AutomationName is still Windows |
Unsupported execute method 'windows:closeApp' |
Missing space; see .NET client notes |
'path' must be provided. |
deleteFile / deleteFolder still pass remotePath |
windows: deleteFile rejected as insecure |
Start Appium with --allow-insecure=wincore:modify_fs |
| XPath lookups much slower than before | Anchor with a native locator, then query relative to it |
| Invalid selector from an XPath that worked before | XPath 2.0 is stricter about types; see XPath version |
invalid element state from windows: select / expand / collapse |
The MSAA control did not change state; the old driver reported success regardless |