2gis / Winium.Elements

Winium.Elements is a set of extensions for WebDriver Clients Bindings providing easy-to-use way of interacting with desktop-specific UI elements in Windows Desktop apps tested with Winium.Desktop.
Mozilla Public License 2.0
12 stars 9 forks source link

Failed to use ToDataGrid and ToMenu to get grid text and menu items #24

Open rashagarhy opened 7 years ago

rashagarhy commented 7 years ago

I tried using ToDataGrid on a grid in a desktop application to read text from cells on the grid, but I got a null reference exception. The same happened with ToMenu. I'm using Winium.Desktop, not Winium.Cruciatus. Is there a way to make them work? I had already submitted an issue ealier on https://github.com/2gis/Winium.Desktop/issues/142 with more details. Thanks,

qamadhu commented 7 years ago

Hi Please help me how to read text using DataGrid in Java. It's throwing me an error when we execute the below code

  1. DataGrid dataGrid = WebElementExtensions.toDataGrid(driver.findElement(By.xpath(".//*[contains(@ControlType, 'ControlType.Custom')]")));
  2. System.out.println("Data Grid"+dataGrid.getRowCount());
  3. RemoteWebElement cell = dataGrid.find(1, 2);
  4. System.out.println(cell.getText());

Error: org.openqa.selenium.NoSuchElementException: NOT GET ITEM (WARNING: The server did not provide any stacktrace information)

viswachaitanya4 commented 7 years ago

Hey, in my current project we are using winium, i ran into a situation where there are multiple datagrid's with same property values. The error or exception is similar to the one explained by qamadhu in the earlier comment. So, is there any solution for that??. Any help is appreciated. Thank you

qamadhu commented 7 years ago

Hi Viswa, I found other alternative PFB

String cellValue = driver.findElements(By.className("ListViewItem")).get(0).findElements(By.className("ContentPresenter")) .get(10).findElement(By.className("TextBlock")).getAttribute("Name")

For me this code is working fine. Please let me know if any clarifications required. I will share my code. Thanks

viswachaitanya4 commented 7 years ago

Hi qamadhu, thank you for sharing your findings,

Actually, the situation is quite different and we realized it in later point that the datagrid is categorized as a "pane" instead of "datagrid or table". i mean ControlType.pane instead of ControlType.Datagrid or Table. This is not allowing us to create a datagrid object since the actual type is pane not datagrid. Now, we are facing the issue as how to access the row and column inside the pane. Using UISpy or Inspect.exe not identifying the rows or columns inside the pane.

  1. So, we need a solution to identify the elements inside the ControlType.pane which are not visible to any tools (UISpy, Inspect). (pane (datagrid) is identified by the tool, but their children are not able to be identified)
  2. The other issue is there are 3 different datagrids (means pane in the application i am dealing with) which have same AutomationId, ClassName. There is no other distinctive property for all three to be identified uniquely. Even the combination of properties as xpath is not working.

It is a kind of showstopper to my work, any help or suggestions are much appreciated

Thanks, Viswa

qamadhu commented 7 years ago

Hi Viswa, Is it possible to show ur code once. Pls ping me on WhatsApp - 9886976022 so that will discuss.

Thanks, Madhu

nits-PT commented 7 years ago

Hi viswachaitanya4, have you got any solution to this? I have ran into the same problem and need an urgent solution.

autoasi commented 6 years ago

Hi @viswachaitanya4 / @nits-PT, I'm facing similar issue with our Pane element - Have you managed to find a solution for it?

viswachaitanya4 commented 6 years ago

Hi @autoasi, I could not resovlve this using winium. Since winium uses element id's, name etc to work, and the application that i worked on is a legacy thick client. There are lot of other places within the application where i found it impossible to identify an element using just the element tags. So, i used Sikuli for that kind of issues. Sikuli works on image recognition. It provided solution to all the impossibles with Winium in my application.

Please go through the following link if you need more information on sikuli http://www.sikuli.org/