Ask a Question

ComboBox item selected ok but get an error anyway

SOLVED
GordonD
Occasional Contributor

ComboBox item selected ok but get an error anyway

I have a test with a ComboBox "ClickItem" operation to select a ComboBox item, with this description: "Selects the 4 item of the 'ComboBox' combo box". The 4th item is always selected correctly, but the operation fails anyway. After selecting the correct ComboBox item, TC says "Waiting for the ComboBox object" and times out. It then says, "The control does not exist", and it logs an error. It can select the correct ComboBox item by integer index or by name, but with the same resulting error.

The Test Visualizer image for this operation shows a blank combo box item instead of the actual item to be selected. Is this why it fails?  If so, how can I tell TC not to care if the Visualizer image doesn't match?  Or basically, how can I stop TC from failing this operation, since it succeeds in selecting the correct ComboBox item?

19 REPLIES 19
Marsha_R
Champion Level 2

Just an fyi, you can use the debugger with a keyword test.  Works the same way.

 

Put the breakpoint a few lines above the problem line and then use Step Into to execute each line and see exactly what it does and when.  You may be able to observe a timing issue by doing it step by step this way.

https://support.smartbear.com/testcomplete/docs/testing-with/debugging/running/stepping-through.html

 

 

Hi,

 

In addition to everything that have been advised by @Marsha_R :

The problem looks like timing issue. I assume that you are using TestComplete 14. If my guess is correct, then this note from the documentation (https://support.smartbear.com/testcomplete/docs/general-info/whats-new.html#overall-improvements) might be relevant


As part of performance improvement, we have also updated algorithms in the Name Mapping subsystem. Earlier, in certain cases, the Name Mapping engine could wait for test objects longer than the timeout settings specified. This has been fixed. However, this change might cause issues in your tests: earlier, they could pass successfully because the waiting time was longer, but now, they might fail because the waiting time has become shorter. If you face such an issue, enlarge the Auto-wait timeout property of your project.

So, the reason of the problem may be the fact that the combo-box is (re)created and populated with data after the .OdfDataGrid.DatagridcellStream.Click(121, 9) command.

I would recommend to try to wait for the combo-box to be (re)created and continue after that. Try to change

.PopupRoot.ComboBox.ClickItem(4);

to

.PopupRoot.WaitAliasChild("ComboBox", 30000).ClickItem(4);

and see if it helps.

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
GordonD
Occasional Contributor

I added the breakpoint as described, stepping into the code with F11.  Somehow as a side-effect of the step-by-step process, when TC clicks on the ComboBox, it fails to select the menu item (leaving none selected), and then the usual wait for the ComboBox proceeds.  So without debugging, it selects the correct item, then waits indefinitely for the ComboBox, and with the debug breakpoint and step-by-step, it fails to select the item, then  indefinitely waits for the ComboBox.

Marsha_R
Champion Level 2

Okay, so our theory of a timing issue is doing pretty well.

 

Now try @AlexKaras 's WaitAliasChild suggestion.  I bet that will take care of it.

GordonD
Occasional Contributor

I tried using waitAliasChild as described, but the result was the same - it successfully selects the 4th of the ComboBox but then waits indefinitely for the Combobox. 

I gather there's no way to tell TestComplete that it doesn't need to wait for the ComboBox, since it has alread successfully selected the correct item?

Marsha_R
Champion Level 2

How clean is your Name Mapping?  I'm wondering now if there is more than one instance of this child in there and TC is not waiting on what we think it's waiting on.

 

The quickest way to test is to delete the combo box from the mapping and see if the test still runs.  You can remap it after that.  Also make a backup copy of your name mapping file first, just in case.  

GordonD
Occasional Contributor

I deleted the ComboBox mapping under NameMapping.Sys.AspenHysys.HwndSource_PopupRoot.PopupRoot, and as a result the 4th item was no longer selected at the end if the test.  Then after appending to the end of the test, selecting the 4th item (which restores the name mapping), the test once again selects the 4th item but waits indefinitely for the ComboBox.

 

There's only the one ComboBox object in that branch of the name mapping. There are other ComboBox objects, but not under HwndSource_PopupRoot - they are in different UI controls.

 

It might be relevant that this combo box is more complicated than usual.  You can make several selections, each with a drop-down, instead of 1 selection with 1 drop-down.  I attached a picture of what object spy shows for the (1st) drop-down, before the 4th item (Kerosene) is selected, and after it is selected (how it looks when TC is waiting for the ComboBox).  The ComboBox doesn't appear in the object spy's output - I guess the ComboBox is what appears and opens when you click on the item.

Marsha_R
Champion Level 2

You can use Point and Fix in ObjectSpy to get the combo box.  Let's see what that shows.

GordonD
Occasional Contributor

I solved this issue by using a script function (as suggested by Alex at Smartbear) to call the ComboBox's native method (SelectItemWithValue) instead of the TC method ClickItem that's added when recording the test.  I had trouble finding the ComboBox with ObjectSpy to use as the object path in the script, but I found it using Point and Fix as suggested by Martha (I marked it as the solution, since it was the closest).  That was necessary because the ComboBox only exists while the dropdown is open, and it closes when you click elsewhere, e.g. for the ObjectSpy drag.

 

Alex explained that the TC ClickItem method, which I had used for the ComboBox item selection, first executes the click, then verifies that it went ok.  But the ComboBox disappears in the object tree as soon as the selection is made, so it hangs while trying to verify.

 

 

 

@GordonD :

Aha!

Thank you a lot for the follow-up. I did not know the details provided by Alex from Support but now I will. 🙂

Much appreciated.

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
cancel
Showing results for 
Search instead for 
Did you mean: