To select item from combobox content through text file

I'm a new user of Eggplant and seeking help regarding the following issue:

How can i select an item from the combo box, other than capturing and clicking images. I'm taking input from a text file in my script and want to select the item in combo box depending on the text file input. Capturing images for a combobox with large content is becoming a constraint in my work.

Provide me with the sample Script for the same.

Comments

  • Hi sudhacar,

    What platform is the SUT? You'll have to turn on Full keyboard access on mac (if it's a Mac, I think). Then you could define a property list that contains a list of the items in the combo box and each of them has a position property. Then you'd be able to get that property and then access the combo box and typetext the down arrow key enough times to find what you want. I'm sure that Matt or Jo or Jonathan will have a more elegant solution.
  • JonathanOSXJonathanOSX ForumAdmin admin
    edited March 2006
    The answers depends on the operating system that you are scripting against.

    On a Mac running OS X we usually refer to a Combo-Box as a pull-down menu that also allows typing in values in a text field at the top. In this case of course once you have focus on the UI element you can just use the TypeText command to type in your string.
    MacComboBoxExample.png

    If you are talking about a drop-down (that doesn't have an editble text entry field) you can actually still use TypeText to type the full choice once you have popped the list up (which can best be done by clicking on the little arrow on the right). If what you type is present it will be selected (otherwise it will select the next closest alphabetic choice which is sometimes peculiar).
    MacDropDownExample.png

    Some Windows applications behave as decribed in the above example. Unfortunately most Windows applications don't offer quite as nice of a user interface mechanic.

    If it's got a text entry field you can type your choice just like on OS X but if it only gives you a fixed set of choices you really need to know the full contents of the list to be able to select from it without using an image. Typing a letter will highlight the next item in the list with that letter, repeatedly typing that letter will continue to select items in the list. For example on a pull-down with a list of US states I can type "cc" to select Colorado. So by using a series of letters or down arrows you can select items in the list.
  • Thanks Jonathan.

    I have to run the script in windows and Mac OS.

    I have another query in the same:

    In my script i'm taking input from the text file. The Text file contains the items which user wants to select from the combo box. So, how can i Select the item from a "DROP DOWN COMBO BOX", depending upon the input from the text file???

    Let me elaborate my point with a small example:

    Suppose the drop down combo enlists-
    Default
    Short
    Large
    Small
    Medium

    I want to select "small" item from the combo. So i will enter "Small" in my text file. While running the script, this input from the text file should be taken, compared with the combo list and then selected.

    According to your suggestion, while taking the input from the file, its selecting character by character, but not the word as a whole. So its selecting wrong item from the combo box.

    So in this case, when i use "typetext small" in the script, it first selects "Short" (since first letter is 's'), then selects "Medium" (since second letter is 'm') and so on. Finally ending up with selecting "Large" as the last char in "small" is 'l'. :!:

    Help me in this issue.

    The answers depends on the operating system that you are scripting against.

    On a Mac running OS X or a Windows XP machine we usually refer to a Combo-Box as a pull-down menu that also allows typing in values in a text field at the top. In this case of course once you have focus on the UI element you can just use the TypeText command to type in your string.
    MacComboBoxExample.png

    If you are talking about a drop-down or pop-up (that doesn't have an editble text entry field) you can actually still use TypeText to type the full choice once you have popped the list up (which can best be done by clicking on the little arrow on the right). If what you type is present it will be selected (otherwise it will select the next closest alphabetic choice which is sometimes peculiar).
    MacDropDownExample.png

    Windows 2000 and earlier unfortunately doesn't offer quite as nice of a user interface mechanic.

    If it's got a text entry field you can type your choice just like on OS X but if it only gives you a fixed set of choices you really need to know the full contents of the list to be able to select from it without using an image. Typing a letter will highlight the next item in the list with that letter, repeatedly typing that letter will continue to select items in the list. For example on a pull-down with a list of US states I can type "cc" to select Colorado. So by using a series of letters or down arrows you can select items in the list.
  • JonathanOSXJonathanOSX ForumAdmin admin
    Small correction to my earlier post....

    On Windows unfortunately it's not consistent, on some controls in some applications typing "SMALL" should work and select "Small". We've found Firefox and the Display Properties Panel to behave this way.

    In others, like IE and Office you need to just type "S", if you had "Small", "Smaller", "Smallest" in you drop-down you would need to type "SSS" to select "Smallest".

    So, the answer unfortunatley on Windows is...it depends, you'll have to try your application and determine.
Sign In or Register to comment.