locked
UITestControl.BoundingRectangle property call takes a long time RRS feed

  • Question

  • I'm developing a test automation for a financial application and I'm using the property BoundingRectangle to check when a control is visible:

     private bool IsVisible(UITestControl testControl)
     {
        var xCordinate = testControl.BoundingRectangle.X;
        var yCordinate = testControl.BoundingRectangle.Y;
    
        return (xCordinate > -1 && yCordinate > -1);
     }

    But when there are enough controls in my body HTML, the call to the property takes a long time, about 2 minutes. The latter is proved by recordings of logs. Thanks in advance


    Thursday, December 17, 2015 12:51 PM

Answers

  • Hi Javi5,

    >>I think, when the control is no longer visible, the Code UI Test tries again search the control and when BoundingRectangle property is called, the system has to resolve the search.

    I agree with you. The control is exist when run TryFind() method, but when BoundingRectangle property is called, the control has not visible. So the Coded UI Test will try to find it again which will take some times.

    >>But I do not understand why the tryfind()  method returns true and DrawHighlight() method draws nothing.

    Please check whether there any controls on screen visible at start but will not visible when application run for a while. It results the TryFind() returns True, but when run DrawHighlight() the controls is not visible. For this problem, please try modify your code as below to check whether the controls visible become not visible in your application.

    for (int count = 0; controlCargando.TryFind() && count < 33; count++)
    {
      controlCargando.DrawHighlight();

      if(IsVisible(controlCargando))
      {

         controlCargando.DrawHighlight();

              System.Media.SystemSounds.Exclamation.Play();
              Playback.Wait(2000);

      }
    }


    In addition, We often ask one question in one thread. According to your origin post, your problem is related to the performance issue in your Coded UI Test. And there has some suggestion and explanation for that problem, if the replies are helpful, please close this thread for your origin problem.

    If have any other question about your Coded UI Test, please create a new thread and describe the problem detailed, which is appropriate.

    Best Regards,
    Weiwei

    • Marked as answer by Javi5 Tuesday, December 22, 2015 7:59 AM
    Tuesday, December 22, 2015 3:15 AM

All replies

  • Hi Javi5,

    Please test this code with one or two controls in your HTML page to check how long it will take.

    According to your description, it should be a performance problem in your test. The test code need to find out the control which need to be operated. More controls more time.

    I suggest you don't check every controls on your page. Please only check the controls you want.

    In addition, please make sure your computer is not busy when running your test. Please close all third part programs to release enough Memory and CPU.

    Best Regards,
    Weiwei

    Friday, December 18, 2015 8:28 AM
  • Hi Weiwei

    Thanks for the reply.

    I was making more changes. Here I show a piece of code:

    		.
    		.
    		.
            private static string controlCargandoTexto = "Cargando...";
            private static string controlCargandoTag = "DIV";
    		
    	HtmlControl controlCargando = new HtmlControl(browser);
            controlCargando.SearchProperties.Add(HtmlControl.PropertyNames.TagName, controlCargandoTag);
            controlCargando.SearchProperties.Add(HtmlControl.PropertyNames.InnerText, controlCargandoTexto, PropertyExpressionOperator.Contains);
    		
    	for (int count = 0; controlCargando.TryFind() && IsVisible(controlCargando) && count < 33; count++)
            {
                System.Media.SystemSounds.Exclamation.Play();
                Playback.Wait(2000);
            }
    		.
    		.
    		.
    	----------------------------------------------------------------------
    		
    	private bool IsVisible(UITestControl testControl)
            {
                if (testControl.Exists)
                {
                    traces.trace("Before call BoundingRectangle");
    
                    var xCordinate = testControl.BoundingRectangle.X;
                    var yCordinate = testControl.BoundingRectangle.Y;
    
                    traces.trace("After call BoundingRectangle");
    
                    return (xCordinate > -1 && yCordinate > -1);
                }
                else 
                    return false;
            }

    These are the traces when the control is visible:

    12:39:03 -> Before call BoundingRectangle
    12:39:04 -> After call BoundingRectangle

    And these are the traces when the control is NOT visible:

    12:40:10 -> Before call BoundingRectangle
    12:41:17 -> After call BoundingRectangle

    I do not understand why there is this difference in time.

    Best regards

    Javier




    • Edited by Javi5 Friday, December 18, 2015 1:46 PM
    Friday, December 18, 2015 12:01 PM
  • Hi Javi5,

    The controls is not visible is means it is a hidden control, is it right? As far as I know, Coded UI Test is not support hidden controls.

    According to the "for" loop in your code, the result of controlCargando.TryFind() should be always True if the controls is Visible (not hidden). So there should be 33 times traces message and there will be 32 times was wasted when the control has been found in first time. These will wast a long time.

    In addition, I'm a little confused about the IsVisible() method in your code. What is the purpose for this method? If you want to determine whether controls visible, the TryFind() method has implement this requirement. So I don't understand the traces message for controls is Not visible.

    Besides, please try using DrawHighlight() to watch the control which you are operating in IsVisible method on interface. It will draw a blue rectangle around the UI Test Control. To make sure the control is visible or not when you operate it.

    Best Regards,
    Weiwei

    Monday, December 21, 2015 6:31 AM
  • Hi Weiwei

    The code is in a class that is reused in different circumstances.

    Thereby, it may cause any of the following cases:

    1. Control does not exist: tryfind returns false, then it does not enter in "for" loop.
    2. Control exists, but for a time of a several seconds: tryfind returns true and BoundingRectangle.X returns a value greater than -1. In this case, I need  to wait until it disappears, although a maximum limit of 66 seconds. For this I need the "for "loop.
    3. Control stopped being visible: tryfind returns true, but BoundingRectangle.X returns a value -1, then it exits the loop.

    The DrawHighlight() method I already utilize, but it draws nothing when the control is not visible.

    In the case of the first message (there are enough controls in my body HTML), the control appears about 2 seconds and the "for" loop runs 2 times:

    • First time: tryfind returns true and BoundingRectangle.X returns a value greater than -1

             12:39:03 -> Before call BoundingRectangle
             12:39:04 -> After call BoundingRectangle

    • Second time:  tryfind returns true and BoundingRectangle.X returns a a value -1, but takes a long time

            12:40:10 -> Before call BoundingRectangle
            12:41:17 -> After call BoundingRectangle

    I think, when the control is no longer visible, the Code UI Test tries again search the control and when BoundingRectangle property is called, the system has to resolve the search. But I do not understand why the tryfind()  method returns true and DrawHighlight() method draws nothing.

    Best Regards

    Javier




    • Edited by Javi5 Monday, December 21, 2015 1:22 PM
    Monday, December 21, 2015 12:11 PM
  • Hi Javi5,

    >>I think, when the control is no longer visible, the Code UI Test tries again search the control and when BoundingRectangle property is called, the system has to resolve the search.

    I agree with you. The control is exist when run TryFind() method, but when BoundingRectangle property is called, the control has not visible. So the Coded UI Test will try to find it again which will take some times.

    >>But I do not understand why the tryfind()  method returns true and DrawHighlight() method draws nothing.

    Please check whether there any controls on screen visible at start but will not visible when application run for a while. It results the TryFind() returns True, but when run DrawHighlight() the controls is not visible. For this problem, please try modify your code as below to check whether the controls visible become not visible in your application.

    for (int count = 0; controlCargando.TryFind() && count < 33; count++)
    {
      controlCargando.DrawHighlight();

      if(IsVisible(controlCargando))
      {

         controlCargando.DrawHighlight();

              System.Media.SystemSounds.Exclamation.Play();
              Playback.Wait(2000);

      }
    }


    In addition, We often ask one question in one thread. According to your origin post, your problem is related to the performance issue in your Coded UI Test. And there has some suggestion and explanation for that problem, if the replies are helpful, please close this thread for your origin problem.

    If have any other question about your Coded UI Test, please create a new thread and describe the problem detailed, which is appropriate.

    Best Regards,
    Weiwei

    • Marked as answer by Javi5 Tuesday, December 22, 2015 7:59 AM
    Tuesday, December 22, 2015 3:15 AM