Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculator Test Failed #34

Open
Saifulgani opened this issue Oct 5, 2023 · 3 comments
Open

Calculator Test Failed #34

Saifulgani opened this issue Oct 5, 2023 · 3 comments

Comments

@Saifulgani
Copy link

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
Copy link

daluu commented Dec 13, 2023

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

@Saifulgani
Copy link
Author

Yes! My code changes doe work.

@licanhua
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants