Forum Discussion

Moulya_p's avatar
Moulya_p
Occasional Contributor
7 years ago

How to resize an object of type Panel in the Web Page?

Hello Everyone,

 

I am working on a script where it requires me to change the size of a panel by dragging it in the web application. I have used the Drag method in order to resize my panel.

I have written the following where width and heigth are the properties for the particular object retreived by Object Spy- 

draggableObj.Drag(width, height, 20, 0)

It is not throwing any error, but also not changing the width of my object.

 

So could someone please suggest me how to go about this?

 

Thanks in advance.

  • ScreenLeft and ScreenTop are relative to the screen, not the object.

    So... let's take a different example to describe how drag works.

    Let's say I have an object that is 200 pixels by 400 pixels.  I want to click on the center of it and drag it 100 pixels up and 100 pixels right.

    SO, that looks like this.

    myObject.Drag(100,200,100,-100)

     

    If I want to do the same, but do so by clicking on the upper left corner of my object, taht would be

     

    myObject.Drag(0,0,100,-100)

     

    The first two co-ordinates are pixels RELATIVE to the dimensions of your actual object.

    So... you know height and width.  If you used those as the first two co-ordinates as you suggested in your original post, that would be having the automation click in the bottom right corner of your object and attempting to drag it.   What you need to do is figure out, based upon height and width and the location of your control point on your object to resize, what are the pixel co-ordinates on your object that you need in order to do the resize.

     

    Suggestion:

     

    Create a brand new keyword test... and simply record your drag action that does the resize.  That's all... just the drag action.  This will give you an insight as to what co-ordinates to use and you can then adjust from there.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    The first two parameters of the Drag action are the X/Y co-ordinates of where to click (mouse down)... the starting co-ordinates if you will.  The next two co-ordinates are the change in X and change in Y for the drag.

     

    So, the height and width of your object aren't the best values for the two properties.  You will need to determine where you "mouse down" to be able to drag to change the panel size.  

    • Moulya_p's avatar
      Moulya_p
      Occasional Contributor

      Thanks for the reply tristaanogre. In order to determine the co-ordinates for my "mouse down" action, should I consider the pixel values with respect to the page or is there any other particular properties which I can make use of?  

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Since Drag is a method on the object, the x/y is the co-ordinates on the object that you want to click on in order to drag.