question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with ComboBox when trying to change selection

See original GitHub issue

Hello, I am experiencing the following issue with ComboBox:

Scenario:

  1. Open Microsoft Timesheets Application
  2. For each available week 2.1 Press Add Timesheet button 2.2 Select Week 2.3 Press Cancel button

Expected Behavior:

  1. The Driver will click on Add Sheet button
  2. The Driver will select the parsed week from ComboBox
  3. The Driver will click Cancel button

Observed behavior: After the first iteration is completed successfully, the second iteration is opening the drop down menu, but its throwing an exception that the element could not be found.

I have the example code here:

foreach (var week in dateProvider)
            {
                application.GetInstance<HomePage>()
                    .PressAddButton()
                    .SelectTimesheetPeriod(week)
                    .PressCancelButton();
            }

dateProvider is a List<string> which has 20 elements.

public class HomePage : Invoker
    {
        protected WindowsElement DatesComboBox => this.Driver.FindElementByAccessibilityId("timesheetPeriodField");
        
        public HomePage SelectTimesheetPeriod(string value)
        {
                        DatesComboBox.Click();

            DatesComboBox.FindElementByName(value).Click();

            return this;
        }
    }

Where value is something like “Mon, ‎Jul‎ 16 - Sun, May 22”

And just in case the GetInstance implementation to remove the suspicion: Its just returning me same instance of the Driver if its already instantiated.

public T GetInstance<T>() where T : GlobalStepInvoker, new()
        {
            if (this._instances.All(i => i.Key != typeof(T)))
            {
                var instance = new T();
                instance.WindowsDriver = this.Driver;
                this._instances.Add(typeof(T), instance);
            }
            return (T)this._instances[typeof(T)];
        }

I have tried with xpaths such as

this.Driver.FindElementByXPath($"//ListItem[contains(@Name, '{value}')]");
this.Driver.FindElementByXPath($"//ListItem[starts-with(@Name, \"{value}\")]");

this.DatesComboBox.FindElementByXPath($"//ListItem[contains(@Name, '{value}')]");
this.DatesComboBox.FindElementByXPath($"//ListItem[starts-with(@Name, \"{value}\")]");

Also tried to select the same value again:

foreach (var week in dateProvider)
            {
                application.GetInstance<HomePage>()
                    .PressAddButton()
                    .SelectTimesheetPeriod(dateProvider[0])
                    .PressCancelButton();
            }

EDIT:: The UI Recorder provided by Microsoft recorded following this structure

"/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]
/Window[@Name=\"Timesheets\"][@ClassName=\"ApplicationFrameWindow\"]
/Window[@Name=\"Timesheets\"][@ClassName=\"Windows.UI.Core.CoreWindow\"]
/Pane[@ClassName=\"Web Platform Embedding\"]
/Pane[@Name=\"Timesheets\"][@ClassName=\"Internet Explorer_Server\"]
/Pane[@Name=\"Time\"]
/Group[@AutomationId=\"newTimesheetPanel\"][@Name=\"New Timesheet Panel\"]
/ComboBox[@AutomationId=\"timesheetPeriodField\"]
/List[position()=2]
/ListItem[@Name=\"‎Mon‎, ‎Jul‎ ‎16 - ‎Sun‎, ‎Jul‎ ‎22\"]"

but none changed the result, exact same behavior.

I have checked all the strings, they check-out so I am confident in my List of strings…

Any suggestions ? Am I missing something else ? Making a mistake or ? Or is a defect ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
hassanuzcommented, Jul 17, 2018

Hi @martinikolaev,

For WinAppDriver to interact with the combo box, you would have to initiate a desktop session and interact with the combo box elements that way.

0reactions
hassanuzcommented, Oct 14, 2019

Closing issue. If anyone has anything to follow-up with, please create a new ticket.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with ComboBox when trying to change selection
Hello, I am experiencing the following issue with ComboBox: Scenario: Open Microsoft Timesheets Application; For each available week
Read more >
Can't change ComboBox selected item
Once that the combobox is properly populated with all the voices, I can't select any value from the combobox. Where is the problem?...
Read more >
How to fix this combobox index change problem?
So an alternative approach is to hook up the combo box's SelectedIndexChanged event and if it is less than 0 (and not empty)...
Read more >
ComboBox Selection Change
Dear Community, Good Morning to All, The basic function of this Combobox selection change is show the revision number. If we select the...
Read more >
[Solved] combobox select change error
I want to create a selection list item when I am select the gold item then show only gold item in the list...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found