Skip to content

Commit 2e4e43e

Browse files
[Testing] Fix flaky Bugzilla32801 test by using unique AutomationId (#26651)
* Enabled 42nd set of UITests migrated from XamarinUITest into Appium (#40) * Migrated Issues : Issue32801, Issue774 and Bugzilla40704 * Modified the enabled tests --------- Co-authored-by: HarishKumarSF4517 <harish.kumar@syncfusion.com> * Improved the test to resolve flakiness * Addressed the review changes --------- Co-authored-by: HarishKumarSF4517 <harish.kumar@syncfusion.com>
1 parent 7e7cd24 commit 2e4e43e

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

src/Controls/tests/TestCases.HostApp/Issues/Bugzilla/Bugzilla32801.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ public class Bugzilla32801 : TestTabbedPage
66
{
77
protected override void Init()
88
{
9-
Children.Add(new NavigationPage(new TestDemoPage(1)) { Title = "Tab", IconImageSource = "bank.png" });
10-
Children.Add(new NavigationPage(new TestDemoPage(1)) { Title = "Tab 1", IconImageSource = "bank.png" });
11-
9+
Children.Add(new NavigationPage(new TestDemoPage(1, "FirstTabAddButton", "FirstTabStackButton")) { Title = "Tab", IconImageSource = "bank.png" });
10+
Children.Add(new NavigationPage(new TestDemoPage(1, "SecondTabAddButton", "SecondTabStackButton")) { Title = "Tab 1", IconImageSource = "bank.png" });
1211
}
1312

1413
public class TestDemoPage : ContentPage
1514
{
1615
int _level = 0;
1716

18-
public TestDemoPage(int level)
17+
public TestDemoPage(int level, string AddButtonAutomationId, string StackButtonAutomationId)
1918
{
2019
_level = level;
2120

@@ -28,16 +27,16 @@ public TestDemoPage(int level)
2827
var buttonAdd = new Button
2928
{
3029
Text = "Add Level",
31-
AutomationId = "btnAdd",
30+
AutomationId = AddButtonAutomationId,
3231
BackgroundColor = Colors.Aqua
3332
};
3433

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

3736
var buttonStack = new Button
3837
{
3938
Text = "Show Navigation Stack",
40-
AutomationId = "btnStack",
39+
AutomationId = StackButtonAutomationId,
4140
BackgroundColor = Colors.Aqua
4241
};
4342

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Bugzilla/Bugzilla32801.cs

+16-12
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ namespace Microsoft.Maui.TestCases.Tests.Issues;
66

77
public class Bugzilla32801 : _IssuesUITest
88
{
9-
#if ANDROID
9+
#if ANDROID
1010
const string Tab1 = "TAB 1";
11-
#else
11+
#else
1212
const string Tab1 = "Tab 1";
13-
#endif
14-
const string AddButton = "btnAdd";
15-
const string StackButton = "btnStack";
13+
#endif
14+
const string FirstTabAddButton = "FirstTabAddButton";
15+
const string Level2AddButton = "Level2AddButton";
16+
const string Level3StackButton = "Level3StackButton";
17+
const string SecondTabStackButton = "SecondTabStackButton";
18+
1619

1720
public Bugzilla32801(TestDevice testDevice) : base(testDevice)
1821
{
@@ -24,15 +27,16 @@ public Bugzilla32801(TestDevice testDevice) : base(testDevice)
2427
[Category(UITestCategories.TabbedPage)]
2528
public void Bugzilla32801Test()
2629
{
27-
App.WaitForElement(AddButton);
28-
App.Tap(AddButton);
29-
App.WaitForElementTillPageNavigationSettled(AddButton);
30-
App.Tap(AddButton);
31-
App.WaitForElementTillPageNavigationSettled(StackButton);
32-
App.Tap(StackButton);
30+
App.WaitForElement(FirstTabAddButton);
31+
App.Tap(FirstTabAddButton);
32+
App.WaitForElementTillPageNavigationSettled(Level2AddButton);
33+
App.Tap(Level2AddButton);
34+
App.WaitForElementTillPageNavigationSettled(Level3StackButton);
35+
App.Tap(Level3StackButton);
3336
App.WaitForElement("Stack 3");
3437
App.Tap(Tab1);
35-
App.Tap(StackButton);
38+
App.WaitForElementTillPageNavigationSettled(SecondTabStackButton);
39+
App.Tap(SecondTabStackButton);
3640
App.WaitForElement("Stack 1");
3741
}
3842
}

0 commit comments

Comments
 (0)