Cannot interact with GUI element with WinAppDriver in Azure pipeline

84 views Asked by At

I'm new with Appium and WinAppDriver. I'm using .NET MAUI blazor webview to create app in different platforms (IOS, Andriod and Windows) thus not in XAML. And I try to write UI test in NUnit with WinAppDriver and Appium and run ui tests for windows app in Azure DevOps pipeline automatically, leaned from this Microsoft documentation.

The ui tests run perfect in visual studio locally. (it works fine with FindElementByXPath, FindElementByClassName or FindElementByAccessibilityId) However, it does not work in pipeline and gives the error: "An element could not be located on the page using the given search parameters." I've tried several things such as maximize window, change resolution, fullreset in setup method, wait until element displayed or clickable, still not working :(

Small business logic in the app: When a user opens the app for the first time(clean app), it goes to registration page, once registrated, then user data will be saved and next time user open the app, it will go to login page, once loggedin, the next time it opens the main page directly and so on. The app will cache user data and decide which page the user can reach directly.

To address the reason causing this problem, only 1 ui test (test registration page) runs in pipeline, but still failed. Thus, I have the idea: in pipeline, the page when run the test is somehow not the registration page (correct me If I'm wrong) Or it is in the registration page well, but it still could not find the element.

Any idea? Of course, I can provide some codeframent in details if needed.

1

There are 1 answers

0
congying pan On

After logging en took screenshot in progress during the test in pipeline, I came the answer back. In pipeline, it needs just more time than local to render the page en to locate the element. The solution is to use a time out function to wait until the element is found. See related solution here

So I will close the question.