YWinAppDriver icon indicating copy to clipboard operation
YWinAppDriver copied to clipboard

Calculator Test Failed

Open Saifulgani opened this issue 2 years ago • 5 comments

Hi, The calculator test was failing on my Windows 11 Pro laptop.

Though the Calculator App was launched successfully, I got the below error after launch:

System.InvalidOperationException HResult=0x80131509 Message=Unable to find Windows.UI.Core.CoreWindow|WinUIDesktopWin32WindowClass in {Calculator, ApplicationFrameWindow, } Source=WebDriver StackTrace: at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at OpenQA.Selenium.Appium.AppiumDriver1..ctor(Uri remoteAddress, ICapabilities desiredCapabilities) at CalculatorTest.CalculatorSession.Setup(TestContext context) in C:\YWinAppDriver\YWinAppDriver-0.3.1.0\examples\CalculatorTest\CalculatorSession.cs:line 42 at CalculatorTest.ScenarioStandard.ClassInitialize(TestContext context) in C:\YWinAppDriver\YWinAppDriver-0.3.1.0\examples\CalculatorTest\ScenarioStandard.cs:line 94

I had to add else loop after line 54 in UIObjectHelper.cs to make it work The below is how my code looks now ... ... 50 if (currentTimeout < 0 && element == null) 51 { 52 throw new UIObjectNotFoundException( 53 $"Timeout after ${timeoutInMilliseconds}: Unable to find {string.Join("|", classNames)} in {topWindow}"); 54 } 55 else // by Saif 56 { 57 break; 58 } ... ...

Just want a confirmation, is this correct? Or am I missing something?

Thanks, Saif.

Saifulgani avatar Oct 05 '23 05:10 Saifulgani

Well, did things work with your code change? You could test it out as one way to confirm as well.

daluu avatar Dec 13 '23 22:12 daluu

Yes! My code changes doe work.

Saifulgani avatar Dec 18 '23 04:12 Saifulgani

First, we need to know why the matching failed.

  1. It maybe the calculator app is changed, and the existing matching is not enough to match the app. The app will always fail in this case, and need code fix it.
  2. timeout. The matching depends on a timer. You may workaround the issue either increasing the 300ms timeout image or using title matching image

licanhua avatar Dec 18 '23 17:12 licanhua