Winium driver only identifies the inner elements only if inspect.exe is opened otherwise it throws "Element not found" exception
Hi Team,
My custom control has inner elements. In my case, my custom control is grid and inner elements are cells. You can find the AutomationPeer implementation in below,
public class GridAutomationPeer : FrameworkElementAutomationPeer, IGridProvider
{
public virtual GridModel Model
{
get
{
var grid = this.Owner as GridBase;
return grid.Model;
}
}
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.DataGrid;
}
protected override string GetClassNameCore()
{
return this.Owner.GetType().Name;
}
protected override List<AutomationPeer> GetChildrenCore()
{
var peers = new List<AutomationPeer>();
foreach (var kvp in this.cellPeers)
{
peers.Add(kvp.Value);
}
return peers;
}
public override object GetPattern(PatternInterface patternInterface)
{
switch (patternInterface)
{
case PatternInterface.Grid:
case PatternInterface.Selection:
case PatternInterface.Table:
return this;
return base.GetPattern(patternInterface);
}
}
int IGridProvider.ColumnCount
{
get
{
return this.Model.ColumnCount;
}
}
IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
{
if (row < this.Model.RowCount && column < this.Model.ColumnCount)
{
var cellPeer = this.GetOrCreateCellPeer(row, column);
if (cellPeer != null)
{
var item = this.ProviderFromPeer(cellPeer);
return item;
}
}
return null;
}
int IGridProvider.RowCount
{
get
{
return this.Model.RowCount;
}
}
}
My problem is that, it is properly recognized in Winium test script only if inspect.exe is opened. If the inspect.exe is not opened, Winium throws "Element not found" exception.
Below is my test script,
try
{
var grid = driver.FindElementById("grid");
var cell = grid.FindElement(By.Id("6,1"));
if (cell.Text != "Movie Poster")
Assert.Fail("Cell value is not Movie Poster");
driver.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
Please suggest me any solution for this.
Hi Team,
Is there any update?
Hi Team,
Can you please confirm whether i missed anything?
Hi Team,
Please update as this is critical for my project
You are talking about Winium... so the problem has nothing to do with WinAppDriver?
I'm also having this issue with WinAppdriver when trying to find an element on Powerpoint where it will only find a new slide element if the Inspect tool is open
public boolean isSlide2ThumbImageDisplayed(){
try {
driver.getKeyboard().sendKeys(Keys.ARROW_DOWN);
driver.findElementByName("Slide two").isDisplayed();
return true;
} catch (NoSuchElementException e) {
return false;
}
Really odd behaviour