Ask a Question

selecting the Drop Down values

nisgupta
Valued Contributor

selecting the Drop Down values

Here are some issues going on with drop down values. As you know drop down objects has the method ClickItem . but in one application if we use ClickItem with the values it do not work ,it can only work with the index. While in other application we can use the ClickItem method with the values. Even though in both the the application Object browser show the same properties and methods .

I have attached the screenshots

Thanks

NG

 

 

5 REPLIES 5
tristaanogre
Esteemed Contributor

Do you get any particular error in your log when it attempts to ClickItem with the text string and fails?  That may help give a clue as to what the difference is.

My suspicion (and I don't know this for sure) is that it might have something to do with the parenthetical portion of the drop down... that somehow it's being interpreted wrong or something.  That's just a guess.

 

Another guess is if there is, for some reason, non-printing characters in those drop down options that just setting it to straight text is not working.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Also... how does it "resolve" if you record the drop down selection on the control that doesn't work?  Does it record with the index or does it record with the text?  That might also give a clue because, if it records with the text, it might show us what text we may be missing.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
KP13
Occasional Contributor

Is it the application developed in Angular. Could you please try this.

 

1. Identify the drop arrow element of list box and click that

2. Then click on the item you want to select

 

A sample code in Python

 

#Browser 

page=Sys.Browser().Page("*")

 

#Drop down panel property definition

setInstCodePropArray = ["ObjectType", "firstElementChild.id"]
setInstCodeValuesArray = ["Panel", "SelectVpdiCmp"]

 

#Click on the drop down
panel=page.FindChild(setInstCodePropArray , setInstCodeValuesArray , 20)
panel.focus
panel.Click()


# Select the item
PropArray = ["ObjectType", "contentText"]
ValuesArray = ["TextNode", "Health Sciences Center (HSC)"]
panel.FindChild(PropArray, ValuesArray,2).Click() 

@tristaanogre

 

I have used the following functions for the drop down   where DropDownValue is the expected value we are passing.  We found that in case for application where it is not working (as attached in the previous screenshot) it contain some characters after the last parenthesis whose char code is 8206. That is why it do not click the item in drop down. from the UI perspective it look like it is space and I was passing the value with space. 

 

function SelectDropdownValue(DropdownObj, DropdownValue)
{
       var SelectDropdownValueSuccess = false;
       try
          { 
              if(DropdownObj.WaitProperty("Exists", true, 5000))
             {
// DropdownObj.ClickItem(DropdownValue);
                 var DropdownCount = DropdownObj.wItemCount;
                 for(i=0; i<DropdownCount; i++)
               {
                   Log.Message(DropdownObj.wItem(i));
// Log.Message(DropdownValue);
                   if(aqString.Compare(DropdownObj.wItem(i),DropdownValue,false) == 0)
                      { 
                             DropdownObj.ClickItem(DropdownValue);
                            SelectDropdownValueSuccess = true;
                           break;
                       }
                  }
                 if(SelectDropdownValueSuccess == false){
                          Log.Error("No Values are found");
                 }
       }
   }catch(e) {
        Log.Error("Exception Occurred: " +e);
    } 
// return SelectDropdownValueSuccess; 
}

 

tristaanogre
Esteemed Contributor

Figured it was something like that... something about those items was not matching the string you were using.

Glad you found a solution.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: