Problem with ComboBox when trying to change selection
See original GitHub issueHello, I am experiencing the following issue with ComboBox:
Scenario:
- Open Microsoft Timesheets Application
- For each available week 2.1 Press Add Timesheet button 2.2 Select Week 2.3 Press Cancel button
Expected Behavior:
- The Driver will click on Add Sheet button
- The Driver will select the parsed week from ComboBox
- 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:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
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.
Closing issue. If anyone has anything to follow-up with, please create a new ticket.