Skip to content

Commit 2023cb4

Browse files
committed
Fix location prompt in system test
1 parent 605983b commit 2023cb4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
path: test\bin
8787

8888
- name: System Tests
89-
run: dotnet test --filter type=system --verbosity detailed
89+
run: dotnet test --filter type=system --verbosity normal
9090
working-directory: test
9191

9292
- uses: actions/upload-artifact@v4

test/SystemTests.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using OpenQA.Selenium.Appium;
44
using OpenQA.Selenium.Appium.Windows;
55
using System.Drawing;
6-
using System.Windows.Automation;
76

87
namespace WinDynamicDesktop.Tests
98
{
@@ -30,7 +29,7 @@ public void ShouldUpdateWallpaper()
3029
{
3130
driver.FindElementByXPath("//Window[@Name='Select Language']").Click();
3231
driver.FindElementByXPath("//Button[@Name='OK']").Click();
33-
Thread.Sleep(TimeSpan.FromSeconds(5));
32+
Thread.Sleep(TimeSpan.FromSeconds(2));
3433

3534
if (HandleLocationPrompt()) Thread.Sleep(TimeSpan.FromSeconds(2));
3635
driver.SwitchTo().Window(driver.WindowHandles[0]);
@@ -64,13 +63,12 @@ public void Dispose()
6463

6564
private bool HandleLocationPrompt()
6665
{
67-
var dialogMatcher = new PropertyCondition(AutomationElement.NameProperty, "Let Windows and apps access your location?");
68-
var buttonMatcher = new PropertyCondition(AutomationElement.NameProperty, "Yes");
69-
AutomationElement dialog = AutomationElement.RootElement.FindFirst(TreeScope.Children, dialogMatcher);
70-
if (dialog?.FindFirst(TreeScope.Descendants, buttonMatcher) is AutomationElement yesButton &&
71-
yesButton.GetCurrentPattern(InvokePattern.Pattern) is InvokePattern invokePattern)
66+
if (driver.WindowHandles.Count == 0)
7267
{
73-
invokePattern.Invoke();
68+
// Default focus is on No button, so Shift+Tab to focus Yes, then Enter to confirm
69+
System.Windows.Forms.SendKeys.SendWait("+{TAB}");
70+
Thread.Sleep(500);
71+
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
7472
return true;
7573
}
7674
return false;

0 commit comments

Comments
 (0)