Ask a Question

Can't interact with dropdown list

aleksmatlashev
New Contributor

Can't interact with dropdown list

Hello! I have a dropdown list and I just want to choose one item. I read documentation and I tried everything, but I can't interact with this element. 

https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/standard/combobox/drop-do... 

https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/standard/combobox/selecti... 

This screenshot demonstrate dropdown list which I want to interact http://prntscr.com/nptg35 . 

I use 7 version of TestComplete. It is desktop app. 
I hope you will help me. Thank you.

6 REPLIES 6
tristaanogre
Esteemed Contributor

A screenshot of the object does not help in the diagnosis.  Somethings needed:

 

1) Copy/Paste of the code that you are executing or screenshot of the Keyword test that you are attempting to execute

2) Any NameMapping configurations for indentifying the object

3) Object Browser and/or Object Spy screenshots showing how the object appears within TestComplete.


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

var brokerDropDown = Sys.Process("ForexTester3").VCLObject("DataCenterFrm").VCLObject("Panel1").VCLObject("HistoryBox").VCLObject("BrokerBox");
  brokerDropDown.DropDown();
  brokerDropDown.ClickItem(3);

This is my code. I tried to use a lot of variants. I also attach screen of object properties
http://prntscr.com/nry8el

OK, technically, I don't think you need to call DropDown() first.  ClickItem will do the drop down call and click on the item... in your case, it will click on the 4th item down the list (index 3). 

So, your code looks, generally, OK.  So, when you run it, what do you get?  Do you get errors?  If so, what errors?


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

In all cases I get this error

The drop-down box cannot be opened

Is there an action you're attempting before you attempt the drop down?  This could be a timing issue where the automation is running faster than the application can keep up.  Try dropping an aqUtils.Delay(5000) before your var statement and see if that helps... if so, we have some options to fix it.


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

I had also problems with dropdown. I noticed that best way to use them was by keyboard.

Just figure what keystorkes it requires and then make a procedure to do them.  

This code is not tested, but I imagine that it would be something like this. 

procedure selectfromDropDown( dropdown , index)
var

  i;

begin

   for i:= 0 to index do

    dropdown.keys('[Down]');

  dropdown.keys('[Enter]');
end;

 

Jeemly - Dream Big
https://jeemly.com/
cancel
Showing results for 
Search instead for 
Did you mean: