This commit is contained in:
dhbrett 2016-07-28 20:31:43 -07:00
Родитель d0daba75ab 7550d46f57
Коммит cde1d3a52e
7 изменённых файлов: 1488 добавлений и 756 удалений

Просмотреть файл

@ -5,6 +5,8 @@ using System.Collections.Generic;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using static Microsoft.Edge.A11y.ElementConverter;
namespace Microsoft.Edge.A11y
{
@ -89,30 +91,29 @@ namespace Microsoft.Edge.A11y
/// <returns>The elements found which match the tag given</returns>
public static List<IUIAutomationElement> SearchChildren(
IUIAutomationElement browserElement,
string controlType,
UIAControlType controlType,
Func<IUIAutomationElement, bool> searchStrategy,
out HashSet<string> foundControlTypes)
out HashSet<UIAControlType> foundControlTypes)
{
var uia = new CUIAutomation8();
var walker = uia.RawViewWalker;
var tosearch = new List<Tuple<IUIAutomationElement, int>>();
var toreturn = new List<IUIAutomationElement>();
foundControlTypes = new HashSet<string>();
foundControlTypes = new HashSet<UIAControlType>();
//We use a 0 here to signify the depth in the BFS search tree. The root element will have depth of 0.
tosearch.Add(new Tuple<IUIAutomationElement, int>(browserElement, 0));
var automationElementConverter = new ElementConverter();
while (tosearch.Any(e => e.Item2 < RECURSIONDEPTH))
{
var current = tosearch.First().Item1;
var currentdepth = tosearch.First().Item2;
var convertedRole = automationElementConverter.GetElementNameFromCode(current.CurrentControlType);
var convertedRole = GetControlTypeFromCode(current.CurrentControlType);
foundControlTypes.Add(convertedRole);
if (searchStrategy == null ? convertedRole.Equals(controlType, StringComparison.OrdinalIgnoreCase) : searchStrategy(current))
if (searchStrategy == null ? convertedRole == controlType : searchStrategy(current))
{
toreturn.Add(current);
}
@ -180,77 +181,14 @@ namespace Microsoft.Edge.A11y
/// <param name="count">The number of times to send tab</param>
public static void SendTabs(this DriverManager driver, string element, int count)
{
driver.SendSpecialKeys(element, String.Concat(Enumerable.Repeat("Tab", count)));
var tabs = new List<WebDriverKey>();
for(var i = 0; i< count; i++)
{
tabs.Add(WebDriverKey.Tab);
}
driver.SendSpecialKeys(element, tabs);
}
/// <summary>
/// This allows the SendSpecialKeys function to take friendly names instead of
/// character codes
/// </summary>
public static Lazy<Dictionary<string, string>> specialKeys = new Lazy<Dictionary<string, string>>(() =>
{
var keys = new Dictionary<string, string>();
keys.Add("Null", '\uE000'.ToString());
keys.Add("Cancel", '\uE001'.ToString());
keys.Add("Help", '\uE002'.ToString());
keys.Add("Back_space", '\uE003'.ToString());
keys.Add("Tab", '\uE004'.ToString());
keys.Add("Clear", '\uE005'.ToString());
keys.Add("Return", '\uE006'.ToString());
keys.Add("Enter", '\uE007'.ToString());
keys.Add("Shift", '\uE008'.ToString());
keys.Add("Control", '\uE009'.ToString());
keys.Add("Alt", '\uE00A'.ToString());
keys.Add("Pause", '\uE00B'.ToString());
keys.Add("Escape", '\uE00C'.ToString());
keys.Add("Space", '\uE00D'.ToString());
keys.Add("Page_up", '\uE00E'.ToString());
keys.Add("Page_down", '\uE00F'.ToString());
keys.Add("End", '\uE010'.ToString());
keys.Add("Home", '\uE011'.ToString());
keys.Add("Arrow_left", '\uE012'.ToString());
keys.Add("Arrow_up", '\uE013'.ToString());
keys.Add("Arrow_right", '\uE014'.ToString());
keys.Add("Arrow_down", '\uE015'.ToString());
keys.Add("Insert", '\uE016'.ToString());
keys.Add("Delete", '\uE017'.ToString());
keys.Add("Semicolon", '\uE018'.ToString());
keys.Add("Equals", '\uE019'.ToString());
keys.Add("Numpad0", '\uE01A'.ToString());
keys.Add("Numpad1", '\uE01B'.ToString());
keys.Add("Numpad2", '\uE01C'.ToString());
keys.Add("Numpad3", '\uE01D'.ToString());
keys.Add("Numpad4", '\uE01E'.ToString());
keys.Add("Numpad5", '\uE01F'.ToString());
keys.Add("Numpad6", '\uE020'.ToString());
keys.Add("Numpad7", '\uE021'.ToString());
keys.Add("Numpad8", '\uE022'.ToString());
keys.Add("Numpad9", '\uE023'.ToString());
keys.Add("Multiply", '\uE024'.ToString());
keys.Add("Add", '\uE025'.ToString());
keys.Add("Separator", '\uE026'.ToString());
keys.Add("Subtract", '\uE027'.ToString());
keys.Add("Decimal", '\uE028'.ToString());
keys.Add("Divide", '\uE029'.ToString());
keys.Add("F1", '\uE031'.ToString());
keys.Add("F2", '\uE032'.ToString());
keys.Add("F3", '\uE033'.ToString());
keys.Add("F4", '\uE034'.ToString());
keys.Add("F5", '\uE035'.ToString());
keys.Add("F6", '\uE036'.ToString());
keys.Add("F7", '\uE037'.ToString());
keys.Add("F8", '\uE038'.ToString());
keys.Add("F9", '\uE039'.ToString());
keys.Add("F10", '\uE03A'.ToString());
keys.Add("F11", '\uE03B'.ToString());
keys.Add("F12", '\uE03C'.ToString());
keys.Add("Meta", '\uE03D'.ToString());
keys.Add("Command", '\uE03D'.ToString());
keys.Add("Zenkaku_hankaku", '\uE040'.ToString());
return keys;
});
/// <summary>
/// A wrapper which converts strings with friendly-named special keys to be
@ -261,22 +199,28 @@ namespace Microsoft.Edge.A11y
/// <param name="driver"></param>
/// <param name="elementId"></param>
/// <param name="keysToSend"></param>
public static void SendSpecialKeys(this DriverManager driver, string elementId, string keysToSend)
public static void SendSpecialKeys(this DriverManager driver, string elementId, List<WebDriverKey> keys)
{
var keystrings = keysToSend.Split(new string[] { "Wait" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var keystring in keystrings)
var stringToSend = new StringBuilder();
foreach (var key in keys)
{
var changedKeystring = keystring;
foreach (var key in specialKeys.Value)
{
changedKeystring = changedKeystring.Replace(key.Key, key.Value);
}
driver.SendKeys(elementId, changedKeystring);
if (keystrings.ToList().IndexOf(keystring) < keystrings.Count() - 1)
if(key == WebDriverKey.Wait)
{
System.Threading.Thread.Sleep(1000);
driver.SendKeys(elementId, stringToSend.ToString());
stringToSend = new StringBuilder();
}
else
{
stringToSend.Append(GetWebDriverKeyString(key));
}
}
driver.SendKeys(elementId, stringToSend.ToString());
}
public static void SendSpecialKeys(this DriverManager driver, string elementId, WebDriverKey key)
{
driver.SendSpecialKeys(elementId, new List<WebDriverKey> { key });
}
/// <summary>

Просмотреть файл

@ -2,6 +2,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static Microsoft.Edge.A11y.ElementConverter;
namespace Microsoft.Edge.A11y
{
@ -11,7 +13,8 @@ namespace Microsoft.Edge.A11y
/// </summary>
internal class EdgeStrategy : TestStrategy
{
public EdgeStrategy(string repositoryPath = "https://cdn.rawgit.com/DHBrett/AT-browser-tests/gh-pages/test-files/", string fileSuffix = ""){
public EdgeStrategy(string repositoryPath = "https://cdn.rawgit.com/DHBrett/AT-browser-tests/gh-pages/test-files/", string fileSuffix = "")
{
_driverManager = new DriverManager(TimeSpan.FromSeconds(10));
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2));//Wait for the browser to load before we start searching
_RepositoryPath = repositoryPath;
@ -34,92 +37,78 @@ namespace Microsoft.Edge.A11y
var browserElement = EdgeA11yTools.FindBrowserDocument(0);
if (browserElement == null)
{
return Fail(testData._TestName, "Unable to find the browser");
return Fail(testData.TestName, "Unable to find the browser");
}
//Find elements using ControlType or the alternate search strategy
HashSet<string> foundControlTypes;
var testElements = EdgeA11yTools.SearchChildren(browserElement, testData._ControlType, testData._SearchStrategy, out foundControlTypes);
HashSet<UIAControlType> foundControlTypes;
var testElements = EdgeA11yTools.SearchChildren(browserElement, testData.ControlType, testData.SearchStrategy, out foundControlTypes);
if (testElements.Count == 0)
{
return Fail(testData._TestName, testData._SearchStrategy == null ?
"Unable to find the element, found these instead: " + foundControlTypes.Aggregate((a, b) => a + ", " + b):
return Fail(testData.TestName, testData.SearchStrategy == null ?
"Unable to find the element, found these instead: " + foundControlTypes.Select(ct => ct.ToString()).Aggregate((a, b) => a + ", " + b) :
"Unable to find the element using the alternate search strategy");
}
new CUIAutomation8().AddStructureChangedEventHandler(browserElement, TreeScope.TreeScope_Subtree, null, new StructureChangedHandler());
string result = "";
//This is used if the test passes but there is something to report
string note = null;
var elementConverter = new ElementConverter();
var moreInfo = new StringBuilder();
//If necessary, check localized control type
if (testData._LocalizedControlType != null)
if (testData.LocalizedControlType != null)
{
foreach (var element in testElements)
{
if (!element.CurrentLocalizedControlType.Equals(testData._LocalizedControlType, StringComparison.OrdinalIgnoreCase))
if (!element.CurrentLocalizedControlType.Equals(testData.LocalizedControlType, StringComparison.OrdinalIgnoreCase))
{
var error = "\nElement did not have the correct localized control type. Expected:" +
testData._LocalizedControlType + " Actual:" + element.CurrentLocalizedControlType;
if (!result.Contains(error))
{
result += error;
}
testData.LocalizedControlType + " Actual:" + element.CurrentLocalizedControlType;
moreInfo.Append(error);
}
}
}
//If necessary, check landmark and localized landmark types
if (testData._LandmarkType != null)
if (testData.LandmarkType != UIALandmarkType.Unknown)
{
foreach (var element in testElements)
{
var five = element as IUIAutomationElement5;
var convertedLandmark = elementConverter.GetElementNameFromCode(five.CurrentLandmarkType);
var convertedLandmark = GetLandmarkTypeFromCode(five.CurrentLandmarkType);
var localizedLandmark = five.CurrentLocalizedLandmarkType;
if (convertedLandmark != testData._LandmarkType)
if (convertedLandmark != testData.LandmarkType)
{
var error = "\nElement did not have the correct landmark type. Expected:" +
testData._LandmarkType + " Actual:" + convertedLandmark + "\n";
if (!result.Contains(error))
{
result += error;
}
testData.LandmarkType + " Actual:" + convertedLandmark + "\n";
moreInfo.Append(error);
}
if (localizedLandmark != testData._LocalizedLandmarkType)
if (localizedLandmark != testData.LocalizedLandmarkType)
{
var error = "\nElement did not have the correct localized landmark type. Expected:" +
testData._LocalizedLandmarkType + " Actual:" + localizedLandmark + "\n";
if (!result.Contains(error))
{
result += error;
}
testData.LocalizedLandmarkType + " Actual:" + localizedLandmark + "\n";
moreInfo.Append(error);
}
}
}
//If necessary, naming and descriptions
//This is done "out of order" since the keyboard checks below invalidate the tree
if(testData._requiredNames != null || testData._requiredDescriptions != null)
if (testData.RequiredNames != null || testData.RequiredDescriptions != null)
{
result += CheckElementNames(testElements,
testData._requiredNames ?? new List<string>(),
testData._requiredDescriptions ?? new List<string>());
moreInfo.Append(CheckElementNames(testElements,
testData.RequiredNames ?? new List<string>(),
testData.RequiredDescriptions ?? new List<string>()));
}
//If necessary, check keboard accessibility
var tabbable = EdgeA11yTools.TabbableIds(_driverManager);
if (testData._KeyboardElements != null && testData._KeyboardElements.Count > 0)
if (testData.KeyboardElements != null && testData.KeyboardElements.Count > 0)
{
foreach (var e in testData._KeyboardElements)
foreach (var e in testData.KeyboardElements)
{
if (!tabbable.Contains(e))
{
result += "\nCould not access element with id: '" + e + "' by tab";
moreInfo.Append("\nCould not access element with id: '" + e + "' by tab");
}
}
}
@ -127,27 +116,28 @@ namespace Microsoft.Edge.A11y
try
{
//If necessary, check any additional requirements
if (testData._AdditionalRequirement != null)
if (testData.AdditionalRequirement != null)
{
testElements = EdgeA11yTools.SearchChildren(browserElement, testData._ControlType, testData._SearchStrategy, out foundControlTypes);
var additionalRequirementResult = testData._AdditionalRequirement(testElements, _driverManager, tabbable).Trim();
if (additionalRequirementResult != "")
testElements = EdgeA11yTools.SearchChildren(browserElement, testData.ControlType, testData.SearchStrategy, out foundControlTypes);
var additionalRequirementResult = testData.AdditionalRequirement(testElements, _driverManager, tabbable);
if (additionalRequirementResult.Result != ResultType.Pass)
{
result += "\n" + additionalRequirementResult;
moreInfo.AppendLine(additionalRequirementResult.MoreInfo);
}
}
}
catch(Exception ex)
catch (Exception ex)
{
result += "\nCaught exception during test execution, ERROR: " + ex.Message + "\nCallStack:\n" + ex.StackTrace;
moreInfo.Append("\nCaught exception during test execution, ERROR: " + ex.Message + "\nCallStack:\n" + ex.StackTrace);
}
if (result != "")
var moreInfoString = moreInfo.ToString();
if (moreInfoString != "")
{
return Half(testData._TestName, result.Trim());
return Half(testData.TestName, moreInfoString.Trim());
}
return Pass(testData._TestName, note);
return Pass(testData.TestName);
}
/// <summary>

Просмотреть файл

@ -7,254 +7,557 @@ namespace Microsoft.Edge.A11y
/// <summary>
/// A tool to convert element names into codes and back again
/// </summary>
public class ElementConverter
public static class ElementConverter
{
Dictionary<int, string> UI8Mapping = new Dictionary<int, string>();
private static Dictionary<int, UIAControlType> _ControlTypeMapping;
private static Dictionary<int, UIAProperty> _PropertyMapping;
private static Dictionary<int, UIALandmarkType> _LandmarkTypeMapping;
private static Dictionary<WebDriverKey, string> _WebDriverKeyMapping;
private static void InitControlTypeMapping()
{
var ControlTypeMapping = new Dictionary<int, UIAControlType>();
ControlTypeMapping.Add(-1, UIAControlType.Unknown);
ControlTypeMapping.Add(50000, UIAControlType.Button);
ControlTypeMapping.Add(50001, UIAControlType.Calendar);
ControlTypeMapping.Add(50002, UIAControlType.Checkbox);
ControlTypeMapping.Add(50003, UIAControlType.Combobox);
ControlTypeMapping.Add(50004, UIAControlType.Edit);
ControlTypeMapping.Add(50005, UIAControlType.Hyperlink);
ControlTypeMapping.Add(50006, UIAControlType.Image);
ControlTypeMapping.Add(50007, UIAControlType.Listitem);
ControlTypeMapping.Add(50008, UIAControlType.List);
ControlTypeMapping.Add(50009, UIAControlType.Menu);
ControlTypeMapping.Add(50010, UIAControlType.Menubar);
ControlTypeMapping.Add(50011, UIAControlType.Menuitem);
ControlTypeMapping.Add(50012, UIAControlType.Progressbar);
ControlTypeMapping.Add(50013, UIAControlType.Radiobutton);
ControlTypeMapping.Add(50014, UIAControlType.Scrollbar);
ControlTypeMapping.Add(50015, UIAControlType.Slider);
ControlTypeMapping.Add(50016, UIAControlType.Spinner);
ControlTypeMapping.Add(50017, UIAControlType.Statusbar);
ControlTypeMapping.Add(50018, UIAControlType.Tab);
ControlTypeMapping.Add(50019, UIAControlType.Tabitem);
ControlTypeMapping.Add(50020, UIAControlType.Text);
ControlTypeMapping.Add(50021, UIAControlType.Toolbar);
ControlTypeMapping.Add(50022, UIAControlType.Tooltip);
ControlTypeMapping.Add(50023, UIAControlType.Tree);
ControlTypeMapping.Add(50024, UIAControlType.Treeitem);
ControlTypeMapping.Add(50025, UIAControlType.Custom);
ControlTypeMapping.Add(50026, UIAControlType.Group);
ControlTypeMapping.Add(50027, UIAControlType.Thumb);
ControlTypeMapping.Add(50028, UIAControlType.Datagrid);
ControlTypeMapping.Add(50029, UIAControlType.Dataitem);
ControlTypeMapping.Add(50030, UIAControlType.Document);
ControlTypeMapping.Add(50031, UIAControlType.Splitbutton);
ControlTypeMapping.Add(50032, UIAControlType.Window);
ControlTypeMapping.Add(50033, UIAControlType.Pane);
ControlTypeMapping.Add(50034, UIAControlType.Header);
ControlTypeMapping.Add(50035, UIAControlType.Headeritem);
ControlTypeMapping.Add(50036, UIAControlType.Table);
ControlTypeMapping.Add(50037, UIAControlType.Titlebar);
ControlTypeMapping.Add(50038, UIAControlType.Separator);
ControlTypeMapping.Add(50039, UIAControlType.Semanticzoom);
ControlTypeMapping.Add(50040, UIAControlType.Appbar);
_ControlTypeMapping = ControlTypeMapping;
}
private static void InitPropertyMapping()
{
var PropertyMapping = new Dictionary<int, UIAProperty>();
PropertyMapping.Add(-1, UIAProperty.Unknown);
PropertyMapping.Add(30000, UIAProperty.RuntimeId);
PropertyMapping.Add(30001, UIAProperty.BoundingRectangle);
PropertyMapping.Add(30002, UIAProperty.ProcessId);
PropertyMapping.Add(30003, UIAProperty.ControlType);
PropertyMapping.Add(30004, UIAProperty.LocalizedControlType);
PropertyMapping.Add(30005, UIAProperty.Name);
PropertyMapping.Add(30006, UIAProperty.AcceleratorKey);
PropertyMapping.Add(30007, UIAProperty.AccessKey);
PropertyMapping.Add(30008, UIAProperty.HasKeyboardFocus);
PropertyMapping.Add(30009, UIAProperty.IsKeyboardFocusable);
PropertyMapping.Add(30010, UIAProperty.IsEnabled);
PropertyMapping.Add(30011, UIAProperty.AutomationId);
PropertyMapping.Add(30012, UIAProperty.ClassName);
PropertyMapping.Add(30013, UIAProperty.HelpText);
PropertyMapping.Add(30014, UIAProperty.ClickablePoint);
PropertyMapping.Add(30015, UIAProperty.Culture);
PropertyMapping.Add(30016, UIAProperty.IsControlElement);
PropertyMapping.Add(30017, UIAProperty.IsContentElement);
PropertyMapping.Add(30018, UIAProperty.LabeledBy);
PropertyMapping.Add(30019, UIAProperty.IsPassword);
PropertyMapping.Add(30020, UIAProperty.NativeWindowHandle);
PropertyMapping.Add(30021, UIAProperty.ItemType);
PropertyMapping.Add(30022, UIAProperty.IsOffscreen);
PropertyMapping.Add(30023, UIAProperty.Orientation);
PropertyMapping.Add(30024, UIAProperty.FrameworkId);
PropertyMapping.Add(30025, UIAProperty.IsRequiredForForm);
PropertyMapping.Add(30026, UIAProperty.ItemStatus);
PropertyMapping.Add(30027, UIAProperty.IsDockPatternAvailable);
PropertyMapping.Add(30028, UIAProperty.IsExpandCollapsePatternAvailable);
PropertyMapping.Add(30029, UIAProperty.IsGridItemPatternAvailable);
PropertyMapping.Add(30030, UIAProperty.IsGridPatternAvailable);
PropertyMapping.Add(30031, UIAProperty.IsInvokePatternAvailable);
PropertyMapping.Add(30032, UIAProperty.IsMultipleViewPatternAvailable);
PropertyMapping.Add(30033, UIAProperty.IsRangeValuePatternAvailable);
PropertyMapping.Add(30034, UIAProperty.IsScrollPatternAvailable);
PropertyMapping.Add(30035, UIAProperty.IsScrollItemPatternAvailable);
PropertyMapping.Add(30036, UIAProperty.IsSelectionItemPatternAvailable);
PropertyMapping.Add(30037, UIAProperty.IsSelectionPatternAvailable);
PropertyMapping.Add(30038, UIAProperty.IsTablePatternAvailable);
PropertyMapping.Add(30039, UIAProperty.IsTableItemPatternAvailable);
PropertyMapping.Add(30040, UIAProperty.IsTextPatternAvailable);
PropertyMapping.Add(30041, UIAProperty.IsTogglePatternAvailable);
PropertyMapping.Add(30042, UIAProperty.IsTransformPatternAvailable);
PropertyMapping.Add(30043, UIAProperty.IsValuePatternAvailable);
PropertyMapping.Add(30044, UIAProperty.IsWindowPatternAvailable);
PropertyMapping.Add(30045, UIAProperty.ValueValue);
PropertyMapping.Add(30046, UIAProperty.ValueIsReadOnly);
PropertyMapping.Add(30047, UIAProperty.RangeValueValue);
PropertyMapping.Add(30048, UIAProperty.RangeValueIsReadOnly);
PropertyMapping.Add(30049, UIAProperty.RangeValueMinimum);
PropertyMapping.Add(30050, UIAProperty.RangeValueMaximum);
PropertyMapping.Add(30051, UIAProperty.RangeValueLargeChange);
PropertyMapping.Add(30052, UIAProperty.RangeValueSmallChange);
PropertyMapping.Add(30053, UIAProperty.ScrollHorizontalScrollPercent);
PropertyMapping.Add(30054, UIAProperty.ScrollHorizontalViewSize);
PropertyMapping.Add(30055, UIAProperty.ScrollVerticalScrollPercent);
PropertyMapping.Add(30056, UIAProperty.ScrollVerticalViewSize);
PropertyMapping.Add(30057, UIAProperty.ScrollHorizontallyScrollable);
PropertyMapping.Add(30058, UIAProperty.ScrollVerticallyScrollable);
PropertyMapping.Add(30059, UIAProperty.SelectionSelection);
PropertyMapping.Add(30060, UIAProperty.SelectionCanSelectMultiple);
PropertyMapping.Add(30061, UIAProperty.SelectionIsSelectionRequired);
PropertyMapping.Add(30062, UIAProperty.GridRowCount);
PropertyMapping.Add(30063, UIAProperty.GridColumnCount);
PropertyMapping.Add(30064, UIAProperty.GridItemRow);
PropertyMapping.Add(30065, UIAProperty.GridItemColumn);
PropertyMapping.Add(30066, UIAProperty.GridItemRowSpan);
PropertyMapping.Add(30067, UIAProperty.GridItemColumnSpan);
PropertyMapping.Add(30068, UIAProperty.GridItemContainingGrid);
PropertyMapping.Add(30069, UIAProperty.DockDockPosition);
PropertyMapping.Add(30070, UIAProperty.ExpandCollapseExpandCollapseState);
PropertyMapping.Add(30071, UIAProperty.MultipleViewCurrentView);
PropertyMapping.Add(30072, UIAProperty.MultipleViewSupportedViews);
PropertyMapping.Add(30073, UIAProperty.WindowCanMaximize);
PropertyMapping.Add(30074, UIAProperty.WindowCanMinimize);
PropertyMapping.Add(30075, UIAProperty.WindowWindowVisualState);
PropertyMapping.Add(30076, UIAProperty.WindowWindowInteractionState);
PropertyMapping.Add(30077, UIAProperty.WindowIsModal);
PropertyMapping.Add(30078, UIAProperty.WindowIsTopmost);
PropertyMapping.Add(30079, UIAProperty.SelectionItemIsSelected);
PropertyMapping.Add(30080, UIAProperty.SelectionItemSelectionContainer);
PropertyMapping.Add(30081, UIAProperty.TableRowHeaders);
PropertyMapping.Add(30082, UIAProperty.TableColumnHeaders);
PropertyMapping.Add(30083, UIAProperty.TableRowOrColumnMajor);
PropertyMapping.Add(30084, UIAProperty.TableItemRowHeaderItems);
PropertyMapping.Add(30085, UIAProperty.TableItemColumnHeaderItems);
PropertyMapping.Add(30086, UIAProperty.ToggleToggleState);
PropertyMapping.Add(30087, UIAProperty.TransformCanMove);
PropertyMapping.Add(30088, UIAProperty.TransformCanResize);
PropertyMapping.Add(30089, UIAProperty.TransformCanRotate);
PropertyMapping.Add(30090, UIAProperty.IsLegacyIAccessiblePatternAvailable);
PropertyMapping.Add(30091, UIAProperty.LegacyIAccessibleChildId);
PropertyMapping.Add(30092, UIAProperty.LegacyIAccessibleName);
PropertyMapping.Add(30093, UIAProperty.LegacyIAccessibleValue);
PropertyMapping.Add(30094, UIAProperty.LegacyIAccessibleDescription);
PropertyMapping.Add(30095, UIAProperty.LegacyIAccessibleRole);
PropertyMapping.Add(30096, UIAProperty.LegacyIAccessibleState);
PropertyMapping.Add(30097, UIAProperty.LegacyIAccessibleHelp);
PropertyMapping.Add(30098, UIAProperty.LegacyIAccessibleKeyboardShortcut);
PropertyMapping.Add(30099, UIAProperty.LegacyIAccessibleSelection);
PropertyMapping.Add(30100, UIAProperty.LegacyIAccessibleDefaultAction);
PropertyMapping.Add(30101, UIAProperty.AriaRole);
PropertyMapping.Add(30102, UIAProperty.AriaProperties);
PropertyMapping.Add(30103, UIAProperty.IsDataValidForForm);
PropertyMapping.Add(30104, UIAProperty.ControllerFor);
PropertyMapping.Add(30105, UIAProperty.DescribedBy);
PropertyMapping.Add(30106, UIAProperty.FlowsTo);
PropertyMapping.Add(30107, UIAProperty.ProviderDescription);
PropertyMapping.Add(30108, UIAProperty.IsItemContainerPatternAvailable);
PropertyMapping.Add(30109, UIAProperty.IsVirtualizedItemPatternAvailable);
PropertyMapping.Add(30110, UIAProperty.IsSynchronizedInputPatternAvailable);
_PropertyMapping = PropertyMapping;
}
private static void InitLandmarkTypeMapping()
{
var LandmarkTypeMapping = new Dictionary<int, UIALandmarkType>();
LandmarkTypeMapping.Add(-1, UIALandmarkType.Unknown);
LandmarkTypeMapping.Add(80000, UIALandmarkType.Custom);
LandmarkTypeMapping.Add(80001, UIALandmarkType.Form);
LandmarkTypeMapping.Add(80002, UIALandmarkType.Main);
LandmarkTypeMapping.Add(80003, UIALandmarkType.Navigation);
LandmarkTypeMapping.Add(80004, UIALandmarkType.Search);
_LandmarkTypeMapping = LandmarkTypeMapping;
}
private static void InitWebDriverKeyMapping()
{
var WebDriverKeyMapping = new Dictionary<WebDriverKey, string>();
WebDriverKeyMapping.Add(WebDriverKey.Wait, null);
WebDriverKeyMapping.Add(WebDriverKey.Null, '\uE000'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Cancel, '\uE001'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Help, '\uE002'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Back_space, '\uE003'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Tab, '\uE004'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Clear, '\uE005'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Return, '\uE006'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Enter, '\uE007'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Shift, '\uE008'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Control, '\uE009'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Alt, '\uE00A'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Pause, '\uE00B'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Escape, '\uE00C'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Space, '\uE00D'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Page_up, '\uE00E'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Page_down, '\uE00F'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.End, '\uE010'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Home, '\uE011'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Arrow_left, '\uE012'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Arrow_up, '\uE013'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Arrow_right, '\uE014'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Arrow_down, '\uE015'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Insert, '\uE016'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Delete, '\uE017'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Semicolon, '\uE018'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Equals, '\uE019'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad0, '\uE01A'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad1, '\uE01B'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad2, '\uE01C'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad3, '\uE01D'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad4, '\uE01E'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad5, '\uE01F'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad6, '\uE020'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad7, '\uE021'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad8, '\uE022'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Numpad9, '\uE023'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Multiply, '\uE024'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Add, '\uE025'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Separator, '\uE026'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Subtract, '\uE027'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Decimal, '\uE028'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Divide, '\uE029'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F1, '\uE031'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F2, '\uE032'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F3, '\uE033'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F4, '\uE034'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F5, '\uE035'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F6, '\uE036'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F7, '\uE037'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F8, '\uE038'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F9, '\uE039'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F10, '\uE03A'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F11, '\uE03B'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.F12, '\uE03C'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Meta, '\uE03D'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Command, '\uE03D'.ToString());
WebDriverKeyMapping.Add(WebDriverKey.Zenkaku_hankaku, '\uE040'.ToString());
_WebDriverKeyMapping = WebDriverKeyMapping;
}
/// <summary>
/// Convert a code into an element name
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static UIAControlType GetControlTypeFromCode(int code)
{
if (_ControlTypeMapping == null)
{
InitControlTypeMapping();
}
return _ControlTypeMapping.ContainsKey(code) ? _ControlTypeMapping[code] : UIAControlType.Unknown;
}
/// <summary>
/// Convert a code into a property
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static UIAProperty GetPropertyFromCode(int code)
{
if (_PropertyMapping == null)
{
InitPropertyMapping();
}
return _PropertyMapping.ContainsKey(code) ? _PropertyMapping[code] : UIAProperty.Unknown;
}
public static int GetPropertyCode(UIAProperty property)
{
if (_PropertyMapping == null)
{
InitPropertyMapping();
}
//will throw if given an invalid code
return _PropertyMapping.Keys.First(k => _PropertyMapping[k] == property);
}
/// <summary>
/// Convert a code into a landmark
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static UIALandmarkType GetLandmarkTypeFromCode(int code)
{
if (_LandmarkTypeMapping == null)
{
InitLandmarkTypeMapping();
}
return _LandmarkTypeMapping.ContainsKey(code) ? _LandmarkTypeMapping[code] : UIALandmarkType.Unknown;
}
/// <summary>
/// Convert a WebDriverKey into its string representation
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public string GetElementNameFromCode(int key)
public static string GetWebDriverKeyString(WebDriverKey key)
{
if (UI8Mapping.ContainsKey(key))
if (_WebDriverKeyMapping == null)
{
return UI8Mapping[key];
}
else
{
return null;
InitWebDriverKeyMapping();
}
return _WebDriverKeyMapping[key];
}
/// <summary>
/// Convert an element name into a code
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public int GetElementCodeFromName(string name)
public enum UIAControlType
{
return UI8Mapping.First(n => n.Value.Equals(name, StringComparison.CurrentCultureIgnoreCase)).Key;
Unknown,
Button,
Calendar,
Checkbox,
Combobox,
Edit,
Hyperlink,
Image,
Listitem,
List,
Menu,
Menubar,
Menuitem,
Progressbar,
Radiobutton,
Scrollbar,
Slider,
Spinner,
Statusbar,
Tab,
Tabitem,
Text,
Toolbar,
Tooltip,
Tree,
Treeitem,
Custom,
Group,
Thumb,
Datagrid,
Dataitem,
Document,
Splitbutton,
Window,
Pane,
Header,
Headeritem,
Table,
Titlebar,
Separator,
Semanticzoom,
Appbar,
}
/// <summary>
/// Create an element converter
/// </summary>
public ElementConverter()
public enum UIAProperty
{
Initialize();
Unknown,
RuntimeId,
BoundingRectangle,
ProcessId,
ControlType,
LocalizedControlType,
Name,
AcceleratorKey,
AccessKey,
HasKeyboardFocus,
IsKeyboardFocusable,
IsEnabled,
AutomationId,
ClassName,
HelpText,
ClickablePoint,
Culture,
IsControlElement,
IsContentElement,
LabeledBy,
IsPassword,
NativeWindowHandle,
ItemType,
IsOffscreen,
Orientation,
FrameworkId,
IsRequiredForForm,
ItemStatus,
IsDockPatternAvailable,
IsExpandCollapsePatternAvailable,
IsGridItemPatternAvailable,
IsGridPatternAvailable,
IsInvokePatternAvailable,
IsMultipleViewPatternAvailable,
IsRangeValuePatternAvailable,
IsScrollPatternAvailable,
IsScrollItemPatternAvailable,
IsSelectionItemPatternAvailable,
IsSelectionPatternAvailable,
IsTablePatternAvailable,
IsTableItemPatternAvailable,
IsTextPatternAvailable,
IsTogglePatternAvailable,
IsTransformPatternAvailable,
IsValuePatternAvailable,
IsWindowPatternAvailable,
ValueValue,
ValueIsReadOnly,
RangeValueValue,
RangeValueIsReadOnly,
RangeValueMinimum,
RangeValueMaximum,
RangeValueLargeChange,
RangeValueSmallChange,
ScrollHorizontalScrollPercent,
ScrollHorizontalViewSize,
ScrollVerticalScrollPercent,
ScrollVerticalViewSize,
ScrollHorizontallyScrollable,
ScrollVerticallyScrollable,
SelectionSelection,
SelectionCanSelectMultiple,
SelectionIsSelectionRequired,
GridRowCount,
GridColumnCount,
GridItemRow,
GridItemColumn,
GridItemRowSpan,
GridItemColumnSpan,
GridItemContainingGrid,
DockDockPosition,
ExpandCollapseExpandCollapseState,
MultipleViewCurrentView,
MultipleViewSupportedViews,
WindowCanMaximize,
WindowCanMinimize,
WindowWindowVisualState,
WindowWindowInteractionState,
WindowIsModal,
WindowIsTopmost,
SelectionItemIsSelected,
SelectionItemSelectionContainer,
TableRowHeaders,
TableColumnHeaders,
TableRowOrColumnMajor,
TableItemRowHeaderItems,
TableItemColumnHeaderItems,
ToggleToggleState,
TransformCanMove,
TransformCanResize,
TransformCanRotate,
IsLegacyIAccessiblePatternAvailable,
LegacyIAccessibleChildId,
LegacyIAccessibleName,
LegacyIAccessibleValue,
LegacyIAccessibleDescription,
LegacyIAccessibleRole,
LegacyIAccessibleState,
LegacyIAccessibleHelp,
LegacyIAccessibleKeyboardShortcut,
LegacyIAccessibleSelection,
LegacyIAccessibleDefaultAction,
AriaRole,
AriaProperties,
IsDataValidForForm,
ControllerFor,
DescribedBy,
FlowsTo,
ProviderDescription,
IsItemContainerPatternAvailable,
IsVirtualizedItemPatternAvailable,
IsSynchronizedInputPatternAvailable,
}
/// <summary>
/// Do the work of creating an element converter for a given browser
/// </summary>
private void Initialize()
public enum UIALandmarkType
{
//PropertyIds
UI8Mapping.Add(30000, "RuntimeId");
UI8Mapping.Add(30001, "BoundingRectangle");
UI8Mapping.Add(30002, "ProcessId");
UI8Mapping.Add(30003, "ControlType");
UI8Mapping.Add(30004, "LocalizedControlType");
UI8Mapping.Add(30005, "Name");
UI8Mapping.Add(30006, "AcceleratorKey");
UI8Mapping.Add(30007, "AccessKey");
UI8Mapping.Add(30008, "HasKeyboardFocus");
UI8Mapping.Add(30009, "IsKeyboardFocusable");
UI8Mapping.Add(30010, "IsEnabled");
UI8Mapping.Add(30011, "AutomationId");
UI8Mapping.Add(30012, "ClassName");
UI8Mapping.Add(30013, "HelpText");
UI8Mapping.Add(30014, "ClickablePoint");
UI8Mapping.Add(30015, "Culture");
UI8Mapping.Add(30016, "IsControlElement");
UI8Mapping.Add(30017, "IsContentElement");
UI8Mapping.Add(30018, "LabeledBy");
UI8Mapping.Add(30019, "IsPassword");
UI8Mapping.Add(30020, "NativeWindowHandle");
UI8Mapping.Add(30021, "ItemType");
UI8Mapping.Add(30022, "IsOffscreen");
UI8Mapping.Add(30023, "Orientation");
UI8Mapping.Add(30024, "FrameworkId");
UI8Mapping.Add(30025, "IsRequiredForForm");
UI8Mapping.Add(30026, "ItemStatus");
UI8Mapping.Add(30027, "IsDockPatternAvailable");
UI8Mapping.Add(30028, "IsExpandCollapsePatternAvailable");
UI8Mapping.Add(30029, "IsGridItemPatternAvailable");
UI8Mapping.Add(30030, "IsGridPatternAvailable");
UI8Mapping.Add(30031, "IsInvokePatternAvailable");
UI8Mapping.Add(30032, "IsMultipleViewPatternAvailable");
UI8Mapping.Add(30033, "IsRangeValuePatternAvailable");
UI8Mapping.Add(30034, "IsScrollPatternAvailable");
UI8Mapping.Add(30035, "IsScrollItemPatternAvailable");
UI8Mapping.Add(30036, "IsSelectionItemPatternAvailable");
UI8Mapping.Add(30037, "IsSelectionPatternAvailable");
UI8Mapping.Add(30038, "IsTablePatternAvailable");
UI8Mapping.Add(30039, "IsTableItemPatternAvailable");
UI8Mapping.Add(30040, "IsTextPatternAvailable");
UI8Mapping.Add(30041, "IsTogglePatternAvailable");
UI8Mapping.Add(30042, "IsTransformPatternAvailable");
UI8Mapping.Add(30043, "IsValuePatternAvailable");
UI8Mapping.Add(30044, "IsWindowPatternAvailable");
UI8Mapping.Add(30045, "ValueValue");
UI8Mapping.Add(30046, "ValueIsReadOnly");
UI8Mapping.Add(30047, "RangeValueValue");
UI8Mapping.Add(30048, "RangeValueIsReadOnly");
UI8Mapping.Add(30049, "RangeValueMinimum");
UI8Mapping.Add(30050, "RangeValueMaximum");
UI8Mapping.Add(30051, "RangeValueLargeChange");
UI8Mapping.Add(30052, "RangeValueSmallChange");
UI8Mapping.Add(30053, "ScrollHorizontalScrollPercent");
UI8Mapping.Add(30054, "ScrollHorizontalViewSize");
UI8Mapping.Add(30055, "ScrollVerticalScrollPercent");
UI8Mapping.Add(30056, "ScrollVerticalViewSize");
UI8Mapping.Add(30057, "ScrollHorizontallyScrollable");
UI8Mapping.Add(30058, "ScrollVerticallyScrollable");
UI8Mapping.Add(30059, "SelectionSelection");
UI8Mapping.Add(30060, "SelectionCanSelectMultiple");
UI8Mapping.Add(30061, "SelectionIsSelectionRequired");
UI8Mapping.Add(30062, "GridRowCount");
UI8Mapping.Add(30063, "GridColumnCount");
UI8Mapping.Add(30064, "GridItemRow");
UI8Mapping.Add(30065, "GridItemColumn");
UI8Mapping.Add(30066, "GridItemRowSpan");
UI8Mapping.Add(30067, "GridItemColumnSpan");
UI8Mapping.Add(30068, "GridItemContainingGrid");
UI8Mapping.Add(30069, "DockDockPosition");
UI8Mapping.Add(30070, "ExpandCollapseExpandCollapseState");
UI8Mapping.Add(30071, "MultipleViewCurrentView");
UI8Mapping.Add(30072, "MultipleViewSupportedViews");
UI8Mapping.Add(30073, "WindowCanMaximize");
UI8Mapping.Add(30074, "WindowCanMinimize");
UI8Mapping.Add(30075, "WindowWindowVisualState");
UI8Mapping.Add(30076, "WindowWindowInteractionState");
UI8Mapping.Add(30077, "WindowIsModal");
UI8Mapping.Add(30078, "WindowIsTopmost");
UI8Mapping.Add(30079, "SelectionItemIsSelected");
UI8Mapping.Add(30080, "SelectionItemSelectionContainer");
UI8Mapping.Add(30081, "TableRowHeaders");
UI8Mapping.Add(30082, "TableColumnHeaders");
UI8Mapping.Add(30083, "TableRowOrColumnMajor");
UI8Mapping.Add(30084, "TableItemRowHeaderItems");
UI8Mapping.Add(30085, "TableItemColumnHeaderItems");
UI8Mapping.Add(30086, "ToggleToggleState");
UI8Mapping.Add(30087, "TransformCanMove");
UI8Mapping.Add(30088, "TransformCanResize");
UI8Mapping.Add(30089, "TransformCanRotate");
UI8Mapping.Add(30090, "IsLegacyIAccessiblePatternAvailable");
UI8Mapping.Add(30091, "LegacyIAccessibleChildId");
UI8Mapping.Add(30092, "LegacyIAccessibleName");
UI8Mapping.Add(30093, "LegacyIAccessibleValue");
UI8Mapping.Add(30094, "LegacyIAccessibleDescription");
UI8Mapping.Add(30095, "LegacyIAccessibleRole");
UI8Mapping.Add(30096, "LegacyIAccessibleState");
UI8Mapping.Add(30097, "LegacyIAccessibleHelp");
UI8Mapping.Add(30098, "LegacyIAccessibleKeyboardShortcut");
UI8Mapping.Add(30099, "LegacyIAccessibleSelection");
UI8Mapping.Add(30100, "LegacyIAccessibleDefaultAction");
UI8Mapping.Add(30101, "AriaRole");
UI8Mapping.Add(30102, "AriaProperties");
UI8Mapping.Add(30103, "IsDataValidForForm");
UI8Mapping.Add(30104, "ControllerFor");
UI8Mapping.Add(30105, "DescribedBy");
UI8Mapping.Add(30106, "FlowsTo");
UI8Mapping.Add(30107, "ProviderDescription");
UI8Mapping.Add(30108, "IsItemContainerPatternAvailable");
UI8Mapping.Add(30109, "IsVirtualizedItemPatternAvailable");
UI8Mapping.Add(30110, "IsSynchronizedInputPatternAvailable");
Unknown,
Custom,
Form,
Main,
Navigation,
Search
}
//TODO use UIA_ControlTypeIds
//AttributeIds
UI8Mapping.Add(40000, "AnimationStyle");
UI8Mapping.Add(40001, "BackgroundColor");
UI8Mapping.Add(40002, "BulletStyle");
UI8Mapping.Add(40003, "CapStyle");
UI8Mapping.Add(40004, "Culture");
UI8Mapping.Add(40005, "FontName");
UI8Mapping.Add(40006, "FontSize");
UI8Mapping.Add(40007, "FontWeight");
UI8Mapping.Add(40008, "ForegroundColor");
UI8Mapping.Add(40009, "HorizontalTextAlignment");
UI8Mapping.Add(40010, "IndentationFirstLine");
UI8Mapping.Add(40011, "IndentationLeading");
UI8Mapping.Add(40012, "IndentationTrailing");
UI8Mapping.Add(40013, "IsHidden");
UI8Mapping.Add(40014, "IsItalic");
UI8Mapping.Add(40015, "IsReadOnly");
UI8Mapping.Add(40016, "IsSubscript");
UI8Mapping.Add(40017, "IsSuperscript");
UI8Mapping.Add(40018, "MarginBottom");
UI8Mapping.Add(40019, "MarginLeading");
UI8Mapping.Add(40020, "MarginTop");
UI8Mapping.Add(40021, "MarginTrailing");
UI8Mapping.Add(40022, "OutlineStyles");
UI8Mapping.Add(40023, "OverlineColor");
UI8Mapping.Add(40024, "OverlineStyle");
UI8Mapping.Add(40025, "StrikethroughColor");
UI8Mapping.Add(40026, "StrikethroughStyle");
UI8Mapping.Add(40027, "Tabs");
UI8Mapping.Add(40028, "TextFlowDirections");
UI8Mapping.Add(40029, "UnderlineColor");
UI8Mapping.Add(40030, "UnderlineStyle");
UI8Mapping.Add(40031, "AnnotationTypes");
UI8Mapping.Add(40032, "AnnotationObjects");
UI8Mapping.Add(40033, "StyleName");
UI8Mapping.Add(40034, "StyleId");
UI8Mapping.Add(40035, "Link");
UI8Mapping.Add(40036, "IsActive");
UI8Mapping.Add(40037, "SelectionActiveEnd");
UI8Mapping.Add(40038, "CaretPosition");
UI8Mapping.Add(40039, "CaretBidiMode");
//Control types
UI8Mapping.Add(50000, "Button");
UI8Mapping.Add(50001, "Calendar");
UI8Mapping.Add(50002, "Checkbox");
UI8Mapping.Add(50003, "Combobox");
UI8Mapping.Add(50004, "Edit");
UI8Mapping.Add(50005, "Hyperlink");
UI8Mapping.Add(50006, "Image");
UI8Mapping.Add(50007, "Listitem");
UI8Mapping.Add(50008, "List");
UI8Mapping.Add(50009, "Menu");
UI8Mapping.Add(50010, "Menubar");
UI8Mapping.Add(50011, "Menuitem");
UI8Mapping.Add(50012, "Progressbar");
UI8Mapping.Add(50013, "Radiobutton");
UI8Mapping.Add(50014, "Scrollbar");
UI8Mapping.Add(50015, "Slider");
UI8Mapping.Add(50016, "Spinner");
UI8Mapping.Add(50017, "Statusbar");
UI8Mapping.Add(50018, "Tab");
UI8Mapping.Add(50019, "Tabitem");
UI8Mapping.Add(50020, "Text");
UI8Mapping.Add(50021, "Toolbar");
UI8Mapping.Add(50022, "Tooltip");
UI8Mapping.Add(50023, "Tree");
UI8Mapping.Add(50024, "Treeitem");
UI8Mapping.Add(50025, "Custom");
UI8Mapping.Add(50026, "Group");
UI8Mapping.Add(50027, "Thumb");
UI8Mapping.Add(50028, "Datagrid");
UI8Mapping.Add(50029, "Dataitem");
UI8Mapping.Add(50030, "Document");
UI8Mapping.Add(50031, "Splitbutton");
UI8Mapping.Add(50032, "Window");
UI8Mapping.Add(50033, "Pane");
UI8Mapping.Add(50034, "Header");
UI8Mapping.Add(50035, "Headeritem");
UI8Mapping.Add(50036, "Table");
UI8Mapping.Add(50037, "Titlebar");
UI8Mapping.Add(50038, "Separator");
UI8Mapping.Add(50039, "Semanticzoom");
UI8Mapping.Add(50040, "Appbar");
UI8Mapping.Add(80000, "Custom");
UI8Mapping.Add(80001, "Form");
UI8Mapping.Add(80002, "Main");
UI8Mapping.Add(80003, "Navigation");
UI8Mapping.Add(80004, "Search");
public enum WebDriverKey
{
Null,
Cancel,
Help,
Back_space,
Tab,
Clear,
Return,
Enter,
Shift,
Control,
Alt,
Pause,
Escape,
Space,
Page_up,
Page_down,
End,
Home,
Arrow_left,
Arrow_up,
Arrow_right,
Arrow_down,
Insert,
Delete,
Semicolon,
Equals,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
Multiply,
Add,
Separator,
Subtract,
Decimal,
Divide,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
Meta,
Command,
Zenkaku_hankaku,
Wait
}
}
}

Просмотреть файл

@ -15,8 +15,7 @@ namespace Microsoft.Edge.A11y
TestStrategy a11yStrategy = new EdgeStrategy(fileSuffix: ".html");
var results = TestData.alltests.Value.Where(td =>
td._ControlType != null && //Control type == null means skip the test
(testName == null || td._TestName == testName)) //Either no test name was provided or the test names match
(testName == null || td.TestName == testName)) //Either no test name was provided or the test names match
.ToList().ConvertAll(td => a11yStrategy.Execute(td)) //Execute each of the tests
.Where(r => r.Any()) //Only keep the ones that were executed
.ToList().ConvertAll(r => //Convert results from internal form (Pass/Pass, Pass/Fail, Fail/Fail) to external (Pass, Half, Fail)

Просмотреть файл

@ -1,4 +1,6 @@
namespace Microsoft.Edge.A11y
using System.Text;
namespace Microsoft.Edge.A11y
{
public enum ResultType
{
@ -25,4 +27,20 @@
return Name + "," + Result + (MoreInfo != null ? "," + MoreInfo : "");
}
}
public class TestCaseResultExt : TestCaseResult
{
public TestCaseResultExt()
{
Result = ResultType.Pass;
}
public void AddInfo(string info)
{
var stringBuilder = new StringBuilder(MoreInfo);
stringBuilder.Append(info);
MoreInfo = stringBuilder.ToString();
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -28,8 +28,8 @@ namespace Microsoft.Edge.A11y
/// <returns></returns>
public IEnumerable<TestCaseResult> Execute(TestData testData)
{
_driverManager.NavigateToUrl(BuildTestUrl(testData._TestName + _FileSuffix));
return testData._ControlType == null ? Skip(testData._TestName) : TestElement(testData);
_driverManager.NavigateToUrl(BuildTestUrl(testData.TestName + _FileSuffix));
return TestElement(testData);
}
/// <summary>
@ -49,13 +49,12 @@ namespace Microsoft.Edge.A11y
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
protected List<TestCaseResult> Pass(string name, string note)
protected List<TestCaseResult> Pass(string name)
{
return new List<TestCaseResult> {
new TestCaseResult{
Result = ResultType.Pass,
Name = name + "-1",
MoreInfo = note
},
new TestCaseResult{
Result = ResultType.Pass,