SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Member
    Join Date
    Jun 2007
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    When does .Object methods return objects / strings

    Hi,

    I can't see a pattern in the return values of .Object methods. Have I missed something?

    Sometimes I get a object when calling a method or property, sometimes I get a string describing the object I would expected as the return value.

    It could be a controls Bound property, which is returned as a string descripting, e.g. "x=10, y= 10, width=200, height=200", I would have expected a Rectangle object instead.

    I'm testing a .Net application written in C# with qtp9.5 and .Net addin

    Thanks

  2. #2
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    her is the difference

    'x would get SwfWindow().object.toString
    x = SwfWindow().object

    'x would get the object SwfWindow().object
    Set x = SwfWindow().object

  3. #3
    Member
    Join Date
    Jun 2007
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    Ok, if it was like that allways, I could understand it, but I'm pretty sure I've seen runtime errors when doing something similar as your example.

    If I did something like:
    x = SwfWindow().object.Bounds

    I would get a runtime error saying something about Object expected, so no ToString() is called.

    Is this behaviour documented or is it something you learned? I'd better try to replicate the error, so you don't think I'm just stubborn ;-)

  4. #4
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    it is because of RHS not getting evaluated to a object as such. So ToString can never be called if the object is not there at all. And .NET is managed while what you get is a object in unmanaged code. So there are in between RCW wrappers involved which would definitely have some impact on few things. One thing that can be observed is .NET arrays don't work like VBScript arrays.

  5. #5
    Member
    Join Date
    Jun 2007
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    Sorry, but what is RHS? RCW?

    If what you are saying is true, what is failing in my scenario? I know I haven't supplied all information, but maybe this small example recalled from my volatile memory


    set oBounds = SwfWindow().object.Bounds

    results in a runtime error.

    If we expect the syntax to be correct and the property to exist and not throwing an exception and returning a rectangle object I should have a object in oBounnds, right?

    If not, is it the wrapper layer you are talking about which is failing?

    Then
    sBounds = SwfWindow().object.Bounds

    would also fail of course.

  6. #6
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    RHS = Right hand side
    RCW = Runtimne callable wrapper used by .NET to expose objects into the COM world

    I am not sure what i wrong in what you are doing. I would only be able to comment better if i have that app in the front

  7. #7
    Member
    Join Date
    Jun 2007
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    Haven't given up on this issue yet. Trying to create a sample app that demonstrates the problem.

    Meanwhile I found another isssue, which might be related to the wrapper. Ill throw that in as well.

    If I have a method which is overloaded, it looks like I'm only able to use one of the methods.

    On a Flexigrid the two following overloaded method exists (among others):
    [C#]
    public Boolean SetData ( int row , String colName , Object data )
    public Boolean SetData ( int row , int col , Object data )

    But I can only use the last one. Giving a string for colname fails.

    And as another curiosity calling SetData with a variable containing a int modifies that variable, this threw me off completly?!? Is this to be expected?

    E.g.
    iRow = 17
    iCol = 17
    .Object.SetData iRow, iCol, "SomeData"

    When SetData returns, iRow = 1 !?!

  8. #8
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    Try this

    .Object.SetData CInt(iRow), Cstr(iCol), "Some Data"

  9. #9
    Member
    Join Date
    Jun 2007
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    To keep it really simple, I tried to make this small test sample. It contains two tabs. I know that in this case, QTP will recognize the tabcontrol and allow me to use '.Select' but in our AUT the tab control is a 3. party product, so I'm using this test sample to illustrate.

    QTP:

    Set var_Object = SwfWindow("Form1").SwfTab("tabControl1").Object.Ta bPages.Item(0).Bounds

    This results in an error, as '.Bounds' returns a string and not a 'Rectangle' object. I don't understand why I don't get the 'Rectangle' object. Could someone explain why? Thank you in advance

    Attached is the test sample app I use.
    Attached Files Attached Files

  10. #10
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: When does .Object methods return objects / str

    Try this

    Set var_Object = SwfWindow("Form1").SwfTab("tabControl1").Object.Ta bPages.Item(0).Bounds()

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:46 PM.

Copyright BetaSoft Inc.