locked
UITestControlNotAvailableException , even the control is present RRS feed

  • Question

  • Hello,

       i am trying to validate all cells in a table with column index 3 . But after creating function and while playback i am getting the following error:

    "Test method BX06DevelopmentAndDebugUI.x1149_Dev_Process_PS.Agilentx1149DevProcessPS threw exception:
    Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException: The control is not available or not valid. ---> System.Windows.Automation.ElementNotAvailableException: The target element corresponds to UI that is no longer available (for example, the parent window has closed).
       at MS.Internal.Automation.ElementProxy.GetPropertyValue(Int32 property)"

    The function i created is :

     

      public void mcell()
            {
                #region Variable Declarations           
                WpfTable table = this.UISetupPowerSupplyWindow.UIPowerSuppliesGroup.UIDataGridPsChannelTable;
               
                #endregion
    
                int count = 1;
    
                foreach (WpfRow r in table.Rows)
                {
                    foreach (WpfCell c in r.Cells)
                    {
                        if (c.ColumnIndex==3 )
                        {
                            if (c.Value != Convert.ToString(count))
                            {
                                Assert.Fail("Wrong sequence");
                            }
                        }
                        count++;
                    }
                }
            }

    I want to validate the sequence in all cells in sequence number column..

    Thanks in advance


    harinder singh

    Monday, December 10, 2012 8:53 AM

Answers

  • Hello Harkohil,

    Have you tried my suggestions in the previous reply? If possible, I suggest that you can try them so that we can further look at this issue.

    If possible, please provide us more exception information.

    In addition, I suggest that you can drag the crosshair on the cell’s parent window(UIDataGridPsChannelTable) and view its properties. Then you use greater properties to search the window through searchproperties. Meanwhile you need to check and make sure the UIDataGridPsChannelTable’s parent control(UISetupPowerSupplyWindow and UIPowerSuppliesGroup) can be found well and avalaible.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 12, 2012 8:00 AM
    Moderator

All replies

  • Hello Harinder,

    Thank you for your post.

    "Test method BX06DevelopmentAndDebugUI.x1149_Dev_Process_PS.Agilentx1149DevProcessPS threw exception:”

    I would like to know if the exception is thrown in the mcell method. Which type of the control is the cell? Are they customs controls or the 3rd controls? Please clarify.

    You can drag the crosshair on these control to check if Coded UI Test Builder can recognized them,

    “System.Windows.Automation.ElementNotAvailableException: The target element corresponds to UI that is no longer available (for example, the parent window has closed).”

    I suggest that you can check if the parent window has closed before this test method mcell() executes. If yes, please keep it open.

    Meanwhile I want to know if these controls are available. I suggest that you can put some checks in first to see if the cell controls have been initialized and are not null in the foreach loop.

    In addition, can you provide us more detailed error messages? Which cell do you get the exceprion? Or from the first cell of the column 3, will the exception occur?

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, December 11, 2012 2:45 AM
    Moderator
  • Hello Zhu,

    i put the validation on first cell of the column with coded ui test builder is running fine.. yes its a wpfcell and the parent window is not closed it is open .. and its throwing the exception in the mcell function...

    thanks for looking into this matter...l


    harinder singh

    Tuesday, December 11, 2012 5:42 AM
  • Hello Harkohil,

    i put the validation on first cell of the column with coded ui test builder is running fine..

    Do you mean that you do not get the issue at the first cell but at other cells?

    If yes, and Coded UI can recognize all cells well, I suggest that you can try the same scenario on another machine to check if the issue is related to your test environment.

    If possible, please provide us more detailed error messages.

    I would like to know if the CodedUI test performs on another window before executing the mcell method. If yes, you can refer to the following thread and try to re-initialize the UIMap to check if it can help:

    http://social.msdn.microsoft.com/Forums/en-US/vsautotest/thread/26a81771-65b5-4c5c-9ac0-481649d253d0

    I suggest that you can record actions on those failed cells using Coded UI Test Builder to check if they can be valid during running test. Maybe there is anything wrong with those cells themselves.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 11, 2012 8:36 AM
    Moderator
  • Hello Zhu,

    i mean to say if i  put validation one by one is running with coded ui test builder, there is no error , butwhen i try to run with the above function that i created i am getting this error

    Thanks


    harinder singh

    Wednesday, December 12, 2012 1:54 AM
  • Hello Harkohil,

    Have you tried my suggestions in the previous reply? If possible, I suggest that you can try them so that we can further look at this issue.

    If possible, please provide us more exception information.

    In addition, I suggest that you can drag the crosshair on the cell’s parent window(UIDataGridPsChannelTable) and view its properties. Then you use greater properties to search the window through searchproperties. Meanwhile you need to check and make sure the UIDataGridPsChannelTable’s parent control(UISetupPowerSupplyWindow and UIPowerSuppliesGroup) can be found well and avalaible.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 12, 2012 8:00 AM
    Moderator
  • Hello Harinder,

    Have you resolved this issue? Could you get useful information from our reply?

    If you have resolved it, please mark the helpful reply as answer.

    If not, please let us know the latest news about this issue and the result of our suggestion.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 13, 2012 9:11 AM
    Moderator