locked
An event was unable to invoke any of the subscribers Ui Automation

    Question

  • I doing UI automation Using IUIAutomation Interface.I am using VS 2011 On windows 8.

    I have a metro App which has a Toggle Switch and Slider control.I have created a UIAutomationTest App to Automate Metro UI.

    I am facing problem in following code

      1.  IToggleProvider* pToggle = NULL;
           hr = m_pFocusTSBtn->GetCurrentPattern(UIA_TogglePatternId,(IUnknown**)&pToggle);

          I am getting error as 0x80040201 : An event was unable to invoke any of the subscribers 

     2.  IRangeValueProvider* ipClickButton1 = NULL;

         hr = m_pBrightness_Slider->GetCachedPattern(UIA_RangeValuePatternId,(IUnknown**)&ipClickButton1);

         double valMAx = 0;
         hr = ipClickButton1->get_Maximum(&valMAx);

        I am getting error as 0x80040201 : An event was unable to invoke any of the subscribers 

        I have created Cached property and Added 

    hr = pCacheRequest->AddPattern(UIA_TogglePatternId);
    hr = pCacheRequest->AddPattern(UIA_RangeValuePatternId);

    I dont Understand why I am getting this error.Please help me on this




    • Edited by chris_vr Monday, September 3, 2012 6:58 PM
    Monday, September 3, 2012 6:45 PM

Answers

  • Hi Chris,

    What happens if you put a delay in before trying to get those interfaces (or after receiving UIA_E_ELEMENTNOTAVAILABLE and then trying again)? If it's a timing issue where you are calling too early this should get you past it.

    --Rob

    • Marked as answer by chris_vr Monday, September 24, 2012 6:41 AM
    Saturday, September 8, 2012 12:31 AM
    Owner

All replies

  • 0x80040201 is UIA_E_ELEMENTNOTAVAILABLE (0x8004 series HRESULTS are interface specific, the event message you found was the same value but for a different interface. See Structure of COM Error Codes).

    When are you calling these? This usually occurs when the element has been destroyed, but I've also seen this due to a a timing issue where the automating client was getting ahead of the server and requesting patterns before they were ready.

    --Rob

    Wednesday, September 5, 2012 3:12 AM
    Owner
  • 0x80040201 is UIA_E_ELEMENTNOTAVAILABLE (0x8004 series HRESULTS are interface specific, the event message you found was the same value but for a different interface. See Structure of COM Error Codes).

    When are you calling these? This usually occurs when the element has been destroyed, but I've also seen this due to a a timing issue where the automating client was getting ahead of the server and requesting patterns before they were ready.

    --Rob

    Thanks for reply

    In my Metro App there is More Option Button when clicked It will Pop custom More Option for Camera 

    I am using Windows::Media::Capture::CameraOptionsUI::Show(m_MediaCaptureMgr); to launch the more option in the metro App.

    I am Clicking the more option button through my Automation App and it will brings the more option charming window.Then I Walk through all the element in the more option Charming window and getting the Elements (IUIAutomationElement). 

    Coming to the Question, I get toggle switch and slider element and try to get the control pattern for it.I am not able to that as  I am getting error mentioned in the question.The more option also has button and for that I am  able to get Invoke Pattern and able to click that button.but for toggle button and slider it is failing.


    Wednesday, September 5, 2012 7:44 AM
  • Hi Chris,

    What happens if you put a delay in before trying to get those interfaces (or after receiving UIA_E_ELEMENTNOTAVAILABLE and then trying again)? If it's a timing issue where you are calling too early this should get you past it.

    --Rob

    • Marked as answer by chris_vr Monday, September 24, 2012 6:41 AM
    Saturday, September 8, 2012 12:31 AM
    Owner