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

[Bug] Cross-platform tests are not consistent #148

Open
anpin opened this issue Jul 26, 2022 · 1 comment
Open

[Bug] Cross-platform tests are not consistent #148

anpin opened this issue Jul 26, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@anpin
Copy link

anpin commented Jul 26, 2022

Describe the bug

Hi, first thanks for your effort with this project it really seems like I can optimize my UI tests with it. Second, I'm trying to test sample MAUI app and unfortunately my basic test is failing on Windows, but running fine on Android and I'm yet to try iOS.

image

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

  Stack Trace: 
RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
AppiumDriver`1.Execute(String driverCommandToExecute, Dictionary`2 parameters)
RemoteWebDriver.FindElement(String mechanism, String value)
RemoteWebDriver.FindElementByXPath(String xpath)
<>c__DisplayClass19_0.<XPath>b__0(ISearchContext context)
By.FindElement(ISearchContext context)
RemoteWebDriver.FindElement(By by)
<>c__DisplayClass32_0.<AttemptWaitForDriverElement>b__0(IWebDriver driver)
DefaultWait`1.Until[TResult](Func`2 condition)
BasePage.AttemptWaitForDriverElement(By locator, TimeSpan timeout, IWebDriver appDriver)
BasePage.VerifyPageShown(Nullable`1 timeout)
BasePage.ctor(RemoteWebDriver app, Nullable`1 traitTimeout)
BasePage.ctor()
MainPageBase.ctor()
WinMainPage.ctor()
MainPageTest.ctor(UiTestFixture fixtureBase) line 9

I've looked at the samples and figured I have to use different methods for constructing the test page depending on a platform, so I did this

public class MainPage : MainPageBase
{
    protected override By GetBy(string id) => By.Id(id);

    protected override IWebElement GetElement(string id) => FindElement(By.Id(id));
}

public class WinMainPage : MainPageBase
{
    
    protected override By GetBy(string id) => WindowsByExtras.AutomationId(id);
    protected override IWebElement GetElement(string id) => this.WindowsApp.FindElement(GetBy(id));
}

public abstract class MainPageBase : BasePage
{

    protected override By Trait => GetBy("MainPage");
    public IWebElement Button => GetElement("button");
    protected abstract By GetBy(string id);
    protected abstract IWebElement GetElement(string id) ;
}

What is the expected behavior?

Test is able to discover an element using its AutomationId across multiple platforms using a single method e.g. By.Id(automationId)

Package

No response

Other information

You can find repro here https://github.com/anpin/maui_ui_tests

@anpin anpin added the bug Something isn't working label Jul 26, 2022
@jamesmcroft
Copy link
Member

Hey @anpin, thanks for taking a look at Legerity (and apologies for replying to this SO late! 🤦

I'll take a look into this. I've not tested Legerity with MAUI yet, I've only validated it with Xamarin applications. I have a feeling that MAUI is using WinUI3 for Windows apps and this may not be supported by the WinAppDriver yet.

I'll validate this assumption and get back to you!

@jamesmcroft jamesmcroft self-assigned this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants