0
votes

I am programming on a WinForms application with a gui built using Visual Basic back in pre 2005. I frequently will have elements that are visible on inspect.exe, but when I am running WinAppDriver and Appium it fails to detect those elements.

This is the error I get.

OpenQA.Selenium.WebDriverException: 'An element could not be located on the page using the given search parameters.'

The error will occur even when my application is the only maximized application. It occurs when I click a button and launch another form. To make sure that it isn't because the elements haven't appeared yet, I have run the command Thread.Sleep(5000) to ensure that the form which is launched has enough time to appear.

This is the line of code attempting to click on the element.

driver.FindElementByAccessibilityId("vlblYVar").Click(); 

Here is a picture showing inspect.exe clearly finding the element. Any guidance would be greatly appreciated!

enter image description here

1

1 Answers

0
votes

Turns out it just takes a significant amount of time for the elements in the window that pops up to be recognizable by winappdriver even if inspect.exe picks it up immediately.

I had to use

var element = desktopWait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.VisibilityOfAllElementsLocatedBy(ByWindowsAutomation.AccessibilityId("vlblYVar")));
desktop.FindElementByAccessibilityId("vlblYVar").Click(); 

Also I had to use a driver that loads the desktop UI because using my program's driver never found the element which would lead to a timeout.

I have a new issue though. When I have a combo box, the elements in that combo box are found by name with inspect.exe, but winAppDriver can never identify the elements in the combo box.