SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Sep 2009
    Posts
    262
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    QTP and WinComboBox items issue

    Folks,

    I have a WinComboBox object; based on the environment that we run the script in, some of the items in the wincombobox are grayed out. Is there a way to check if the item in the WinComboBox is enabled for selection?

  2. #2
    Advanced Member gencke's Avatar
    Join Date
    Feb 2008
    Location
    Seattle, Washington, United States
    Posts
    532
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Check the properties, there may be one called Enabled.
    Patience is like bread I say.... I ran out of that yesterday.

  3. #3
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Florida, United States
    Posts
    2,765
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Blog Entries
    1
    mzammari,
    I'm thinking of the idea of setting
    On ERROR RESUME Next
    Try selecting it.
    check err.number and err.description
    Maybe you would get an error for the ones that are grayed out.

    It does not sound that sophisticated or a good idea. I cannot think of another way to do it.

    Thanks,

    Kevin

  4. #4
    Member
    Join Date
    Aug 2008
    Posts
    172
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    Hi mzammari,

    For each object you can return the Runtime Object Properties.

    In the example below I describe a Win Checkbox and how to return whether it is enabled or not.

    Code:
    'The value returned is either True, if enabled, or False, if not. 
    bIsEnabled = Window("FlightReservation").WinComboBox("FlyFrom").GetRoProperty("enabled")
    You can then use the result to drive your testing or verification. GetRoProperty is one of my main test drivers for verification. Read the QTP Help file on GetRoProperty for more information.

  5. #5
    Member
    Join Date
    Sep 2009
    Posts
    262
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    Thanks Mike,

    I did try GetROProperty("enabled") option, but you need to select the item first in the list and then test to see if it is enabled or not. if the item in the combobox is disabled, the script fails due to not being able to select the item. so your code should be like the following:
    Window("FlightReservation").WinComboBox("FlyFrom") .Select 1 'or item
    Wait 1
    bIsEnabled = Window("FlightReservation").WinComboBox("FlyFrom") .GetRoProperty("enabled")

  6. #6
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Florida, United States
    Posts
    2,765
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Blog Entries
    1
    mzammari,
    On this line:
    Window("FlightReservation").WinComboBox("FlyFrom") .Select 1 'or item
    What happens if the item in the list is not available? Maybe it is in a list of items, but it is grayed out so it is not currently selectible.
    I would think that QTP would display an error dialog box saying something about the item being missing or not selectable.
    i am guessing that On Error Resume Next is needed first. Then a check to see if an error occurred. Then set On Error GO TO 0.

    Thanks,

    Kevin

  7. #7
    Member
    Join Date
    Jan 2010
    Posts
    53
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    1. Check if the Combo Box is enabled/disabled
    2. Get the count of items in the combo box.
    3. if the count is zero, go to next step
    4. If there are items available then select the item
    5. check if the combo box is enabled/disabled

  8. #8
    SQA Knight bklabel1's Avatar
    Join Date
    Sep 2012
    Location
    Florida, United States
    Posts
    2,765
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    2 Thread(s)
    Total Downloaded
    0
    Blog Entries
    1
    I think that we are missing the point of the question.
    It is to determine which items in the list can be selected. Not if the object is enabled.

  9. #9
    Member
    Join Date
    Aug 2008
    Posts
    172
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    mzammari: by using select you may affect the condition of the checkbox itself, depending on build Select can be used to check the checkbox. Whatever the state, selected or not, enabled can be checked regardless.

    Kevin: If you collect the child objects of Window("FlightReservation") that are WinComboBox class, then for each child found, you can check if enabled and whatever other properties you want to check.

    Here is some (untested) code I have cobbled together:
    Code:
    Set oProperties = Description.Create
    oProperties("micclass").value="WinComboBox"
    Set oCheckboxList = Window("FlightReservation").ChildObjects(oProperties)
    If oCheckboxList.Count > 0 Then
       For each oCheckbox in oCheckboxList
          Msgbox oCheckbox.GetRoProperties("enabled")
       Next
    End If
    While I have been working for Businesses that are Vendor partners with HP, IBM and Microsoft, my opinions and advice is my own.
    The solutions provided are either sourced from my own scripting libraries or from a quick Google Search.

 

 

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.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:26 PM.

Copyright BetaSoft Inc.