I don’t can choose and click on the next item in dropdown list of combobox though I see that output report is correct an

Ask general questions here.
uriisak
Posts: 10
Joined: Sun Apr 10, 2022 1:42 pm

I don’t can choose and click on the next item in dropdown list of combobox though I see that output report is correct an

Post by uriisak » Tue Mar 07, 2023 2:49 pm

Hi,
I have problem with execution of my code and I need your help , please

I want to do :
1. Get to combobox and click on it (see attached application print screen*)
2. Click on combobox and opened dropdown list with the 3 items (High , Medium , Low)- see attached application print screen*
3. In loop choose the next item of combobox list (step by step in loop)
- i.e. one step choose item "High" – second step choose item "Medium" and third step chose item "Low"

- But with my code I only click on the combobox and close it and I don’t can choose and click on the next item in dropdown list of combobox though I see that output report (attached below) is correct and I got the all Items from combobox in report print log (output) !


*Application print screen


After click on combobox opened dropdown list of 3 items (High , Medium , Low)



My code (attached code in txt file too)
1. Clicked on combobox and opened dropdown
2. Closed combobox immediately – I don’t understand why ?
3. No executed the : liItem.MoveTo()
4. No executed the : liItem.Click(Location.Center);
5. Again opened the dropdown list
6. Printed - Report.Info("The item name is = "+liItem.Text); - see the output
7. loop again

//repository ref
public static WebNmsEmsCoreSolanRepository repo = new WebNmsEmsCoreSolanRepository();

//3. Select items from combobox step by step in loop
IList<Ranorex.ListItem> ilist = repo.ApplicationUnderTest.EMS.GeneralTabV.MainPowerV.MainPowerDropDown.Items;
foreach (Ranorex.ListItem liItem in ilist)
{
if(liItem.Valid){
Report.Info("The Item Valid");
Report.Info("Click on combobox and open dropdown list of all items");
repo.ApplicationUnderTest.EMS.GeneralTabV.MainPowerV.MainPowerDropDown.Click(Location.CenterRight);
Delay.Seconds(1);
liItem.MoveTo();

Report.Info("Click on the next item in the combobox...");
liItem.Click(Location.Center);

Report.Info("The item name is = "+liItem.Text);
Report.Info("The item Element is = "+liItem.Element);
}
else
Report.Info("Item No valid");

}//end of foreach


OUTPUT attached



PLEASE HELP me - I don’t know what is wrong


Thank you for help
Best regards
Uri
You do not have the required permissions to view the files attached to this post.


csaszi89
Posts: 41
Joined: Mon Jan 17, 2022 12:10 pm

Re: I don’t can choose and click on the next item in dropdown list of combobox though I see that output report is correc

Post by csaszi89 » Thu Mar 09, 2023 5:38 pm

Hi,

what kind of application are we talking about? Is this a desktop app? Winforms or Wpf?
Here is my best guess:
Your combo box loads its items in a "lazy" way.
Meaning that the list items are only available when the drop down list is visible.
So, try to open the drop down list first and then collect the list items. Perhaps you should get the list items again and again in each iteration, I am not sure.

Lets give it a try!

uriisak
Posts: 10
Joined: Sun Apr 10, 2022 1:42 pm

Re: I don’t can choose and click on the next item in dropdown list of combobox though I see that output report is correc

Post by uriisak » Fri Mar 10, 2023 11:06 am

Hi
Thank you for your answer

1. I working with Web app on Chrome

2. The combo box I opened earlier in the test (I see that the combo box opened in my test before I tryed to get to the item )

Mouse.Click(repo.ApplicationUnderTest.EMS.GeneralTabV.MainPowerV.MainPowerDropDown.Element);
Delay.Seconds(1);


P.S. - In the Output, I see that I got the all items names (but I don't can click on the next item)

-------------------My Output ----------------------------
Success The Ranorex output:
Found the element 'Main Power' drop-down (selectTag) on the General window

open the 'MainPower' drop-down. Click on it

The liItem.Element =High
The liItem.Text =High


The liItem.Element =Medium
The liItem.Text =Medium

The liItem.Element =Low
The liItem.Text =Low

-----------------------------------------------------

I don't understand still why I don't can click on the next item (when opening combobox and displaying the dropdown list)