WinAppDriver
WinAppDriver copied to clipboard
How to debug test project when testing using WinAppDriver
Hi Team,
We have our custom control that acts like MS DataGrid. We used the Windows driver to retrieve the framework elements and perform some actions on the control (like click). But the elements are not retrieved properly and we need to debug through the methods of our custom control from Windows driver methods. Can you suggest a way to debug the testing project? Below are the method that we use from Windows driver to get elements.
var options = new AppiumOptions();
options.AddAdditionalCapability("app", @"\....\bin\Debug\GridControlDemo.exe");
options.AddAdditionalCapability("deviceName", "LAPN-23996");
_driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723/"), options);
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
Actions actions = new Actions(_driver);
var grid1 = _driver.FindElementByAccessibilityId("Grid1");
var firstCellValue = grid1.FindElementByName("GridCell_R1_C1");
actions.MoveToElement(firstCellValue).ContextClick().Build().Perform();
Thanks in Advance, Arulpriya R
Arulpriya What do you mean to Debug? Why you cannot use standart methods of your IDE?
Hi @Shakevg,
Our use case is, When we have two custom controls in the same form and trying to retrieve the element by passing the FindElementByAccessibilityId, we get same instance for both grids. So, we could not perform click actions in the 2nd grid. Can you please suggest a solution to get each elements to perform actions?
Thanks in Advance, Arulpriya R
Arulpriya Did you try to access to each grid by index:
var grids = _driver.FindElementsByAccessibilityId("Grid1");
var grid1 = grids[0];
var firstCellValue = grid1.FindElementByName("GridCell_R1_C1");
actions.MoveToElement(firstCellValue).ContextClick().Build().Perform();
var grid2 = grids[1];
firstCellValue = grid2.FindElementByName("GridCell_R1_C1");
actions.MoveToElement(firstCellValue).ContextClick().Build().Perform();
Hi @Shakevg, Yes, we tried but we only get the single grid using FindElementByAccessibilityId method and we could get another grid by indexing. Thanks, Arulpriya R
Arulpriya Could you post Session.PageSource here or screen with 2 grids
Hi @Shakevg,
Please find the screen with 2 grids,
@vijayarasan I mean need to see how it looks like in inspector.exe (screen from inspector)
Hi @Shakevg,
Please find the screen from inspector,

@vijayarasan Grids looks different. Can you try to save PageSource: session.PageSource And check grids are available there with expected properties because real available XML can be different with Inspector
@Shakevg Find the saved session.PageSource is in the attachment. Both grids are available in the attached document.
PageSource Saved File: PageSource.txt
@vijayarasan Your grids have different AutomationId The next code should work:
var grid1 = _driver.FindElementByAccessibilityId("gridControl2");
var firstCellValue = grid1.FindElementByName("GridCell_R1_C1");
actions.MoveToElement(firstCellValue).ContextClick().Build().Perform();
var grid2 = _driver.FindElementByAccessibilityId("gridControl1");
firstCellValue = grid2.FindElementByName("GridCell_R1_C1");
actions.MoveToElement(firstCellValue).ContextClick().Build().Perform();
@Shakevg We tried as you suggested, but it didn't work. We are getting the same Grid when accessing the grids by using FindElementByAccessibilityId. Look at the screenshot taken when debugging the test,
(Note: We used the cell value text to indicate that both grids have the same value)
The element ID in both grids is the same. So, we could not perform click actions in the second grid. Please suggest a solution to get each element to perform actions.