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

[Testing] Fix flaky Bugzilla32801 test by using unique AutomationId #26651

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ public class Bugzilla32801 : TestTabbedPage
{
protected override void Init()
{
Children.Add(new NavigationPage(new TestDemoPage(1)) { Title = "Tab", IconImageSource = "bank.png" });
Children.Add(new NavigationPage(new TestDemoPage(1)) { Title = "Tab 1", IconImageSource = "bank.png" });

Children.Add(new NavigationPage(new TestDemoPage(1, "FirstTabAddButton", "FirstTabStackButton")) { Title = "Tab", IconImageSource = "bank.png" });
Children.Add(new NavigationPage(new TestDemoPage(1, "SecondTabAddButton", "SecondTabStackButton")) { Title = "Tab 1", IconImageSource = "bank.png" });
}

public class TestDemoPage : ContentPage
{
int _level = 0;

public TestDemoPage(int level)
public TestDemoPage(int level, string AddButtonAutomationId, string StackButtonAutomationId)
{
_level = level;

Expand All @@ -28,16 +27,16 @@ public TestDemoPage(int level)
var buttonAdd = new Button
{
Text = "Add Level",
AutomationId = "btnAdd",
AutomationId = AddButtonAutomationId,
BackgroundColor = Colors.Aqua
};

buttonAdd.Clicked += (sender, e) => Navigation.PushAsync(new TestDemoPage(_level + 1));
buttonAdd.Clicked += (sender, e) => Navigation.PushAsync(new TestDemoPage(_level + 1, $"Level{_level + 1}AddButton", $"Level{_level + 1}StackButton" ));

var buttonStack = new Button
{
Text = "Show Navigation Stack",
AutomationId = "btnStack",
AutomationId = StackButtonAutomationId,
BackgroundColor = Colors.Aqua
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Bugzilla32801 : _IssuesUITest
{
#if ANDROID
#if ANDROID
const string Tab1 = "TAB 1";
#else
#else
const string Tab1 = "Tab 1";
#endif
const string AddButton = "btnAdd";
const string StackButton = "btnStack";
#endif
const string FirstTabAddButton = "FirstTabAddButton";
const string Level2AddButton = "Level2AddButton";
const string Level3StackButton = "Level3StackButton";
const string SecondTabStackButton = "SecondTabStackButton";


public Bugzilla32801(TestDevice testDevice) : base(testDevice)
{
Expand All @@ -24,15 +27,16 @@ public Bugzilla32801(TestDevice testDevice) : base(testDevice)
[Category(UITestCategories.TabbedPage)]
public void Bugzilla32801Test()
{
App.WaitForElement(AddButton);
App.Tap(AddButton);
App.WaitForElementTillPageNavigationSettled(AddButton);
App.Tap(AddButton);
App.WaitForElementTillPageNavigationSettled(StackButton);
App.Tap(StackButton);
App.WaitForElement(FirstTabAddButton);
App.Tap(FirstTabAddButton);
App.WaitForElementTillPageNavigationSettled(Level2AddButton);
App.Tap(Level2AddButton);
App.WaitForElementTillPageNavigationSettled(Level3StackButton);
App.Tap(Level3StackButton);
App.WaitForElement("Stack 3");
App.Tap(Tab1);
App.Tap(StackButton);
App.WaitForElementTillPageNavigationSettled(SecondTabStackButton);
App.Tap(SecondTabStackButton);
App.WaitForElement("Stack 1");
}
}
Loading