licanhua / YWinAppDriver

A open source project provides WinAppDriver compatible functionality
MIT License
49 stars 10 forks source link

Calculator Test Failed #34

Open Saifulgani opened 11 months ago

Saifulgani commented 11 months ago

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.

daluu commented 9 months ago

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

Saifulgani commented 9 months ago

Yes! My code changes doe work.

licanhua commented 9 months ago

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