UIAutomation is not working with latest Edge browser on Windows 10

Site Outreach Issue #12265150

Details

Author
Codework S.
Created
Jun 7, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
40.15063
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

Hi All,

UIAutomation is not working with latest Edge browser (version-
40.15063.0.0) on Windows 10 (Version - 1703, OS Build 15063.138). Kindly see the sample code and help us to solve this issue, the issue which we are facing is marked as Error the below code:

IUIAutomation* pUIAutomation = NULL;
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(__uuidof(CUIAutomation), NULL, CLSCTX_INPROC_SERVER, __uuidof(IUIAutomation), (void**)&pUIAutomation);
if (SUCCEEDED(hr))
{
EnumDesktopWindows(NULL, EnumWindowsProc, 0);
}

BOOL WINAPI EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
WCHAR wszClass[32];
GetClassName(hWnd, wszClass, ARRAYSIZE(wszClass));
WCHAR wszText[MAX_PATH];
GetWindowText(hWnd, wszText, ARRAYSIZE(wszText));

if (wcscmp(wszClass, L"ApplicationFrameWindow") == 0 &&
StrStrI(wszText, L"Microsoft Edge") != 0)
{
HRESULT hr = S_OK;
IUIAutomationElement *pEdgeRoot = NULL;
if (SUCCEEDED(hr))
{
hr = pUIAutomation->ElementFromHandle(hWnd, &pEdgeRoot);
if (SUCCEEDED(hr))
{
VARIANT varProp;
varProp.vt = VT_BSTR;
varProp.bstrVal = SysAllocString(L"Microsoft Edge");

IUIAutomationElement* pElement1 = NULL;
IUIAutomationCondition *condition1 = NULL;

hr = pUIAutomation->CreatePropertyCondition(UIA_NamePropertyId, varProp, &condition1);
if (SUCCEEDED(hr))
{
hr = pEdgeRoot->FindFirst(TreeScope_Subtree, condition1, &pElement1);
if (SUCCEEDED(hr))
{
VariantClear(&varProp);
varProp.vt = VT_BSTR;
varProp.bstrVal = SysAllocString(L"TabWindowClass");
IUIAutomationElement* pElement2 = NULL;
IUIAutomationCondition condition2 = NULL;
hr = pUIAutomation->CreatePropertyCondition(UIA_ClassNamePropertyId, varProp, &condition2);
if (SUCCEEDED(hr))
{
hr = pElement1->FindFirst(TreeScope_Descendants, condition2, &pElement2); // Error-> pElement2 is null
if (SUCCEEDED(hr))
{
VariantClear(&varProp);
varProp.vt = VT_BSTR;
varProp.bstrVal = SysAllocString(L"Internet Explorer_Server");
IUIAutomationElement
pElement3 = NULL;
IUIAutomationCondition *condition3 = NULL;
hr = pUIAutomation->CreatePropertyCondition(UIA_ClassNamePropertyId, varProp, &condition3);
if (SUCCEEDED(hr))
{
hr = pElement2->FindFirst(TreeScope_Descendants, condition3, &pElement3);
if (SUCCEEDED(hr))
{
VariantClear(&varProp);
BSTR bstrURL;
hr = pElement3->get_CurrentName(&bstrURL);
if (pElement3 != NULL)
pElement3->Release();
}
else
VariantClear(&varProp);
if (condition3 != NULL)
condition3->Release();
}
else
VariantClear(&varProp);
if (pElement2 != NULL)
pElement2->Release();
}
else
VariantClear(&varProp);
if (condition2 != NULL)
condition2->Release();
}
else
VariantClear(&varProp);
if (pElement1 != NULL)
pElement1->Release();
}
else
VariantClear(&varProp);
if (condition1 != NULL)
condition1->Release();
}
else
VariantClear(&varProp);
if (pEdgeRoot != NULL)
pEdgeRoot->Release();
}
}
}
return TRUE;
}

Thanks

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Steven K.”

      Changed Status to “Site Outreach”

    • Hey,
      I am sorry to hear you are having trouble with UIA and Edge, but this website is not the right place to look for help. I would recommend you file a support ticket.
      Best regards,
      Francois

    You need to sign in to your Microsoft account to add a comment.

    Sign in