Skip to content

Commit 210ba1f

Browse files
committed
fix errors
1 parent 8e210fb commit 210ba1f

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

src/Bellatrix.Desktop/infrastructure/App.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class App : IDisposable
3838
{
3939
// TODO: Change to be ThreadLocal.
4040
private static bool _shouldStartLocalService;
41-
private static Process _winAppDriverProcess;
41+
// private static Process _appiumProcess;
4242

4343
public App()
4444
{

src/Bellatrix.Desktop/llm/FindByPrompt.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using System.Linq;
2727
using System.Text.RegularExpressions;
2828
using System.Threading;
29+
using OpenQA.Selenium;
2930

3031
namespace Bellatrix.Desktop.LLM;
3132

@@ -49,43 +50,43 @@ public FindByPrompt(string value, bool tryResolveFromPages = true) : base(value)
4950
}
5051

5152
/// <summary>
52-
/// Locates a single WindowsElement using the resolved XPath.
53+
/// Locates a single AppiumElement using the resolved XPath.
5354
/// </summary>
54-
public override WindowsElement FindElement(WindowsDriver<WindowsElement> driver)
55+
public override AppiumElement FindElement(WindowsDriver driver)
5556
{
5657
var location = driver.CurrentWindowHandle;
5758
var xpath = ResolveLocator(location, driver);
58-
return driver.FindElementByXPath(xpath);
59+
return driver.FindElement(By.XPath(xpath));
5960
}
6061

6162
/// <summary>
62-
/// Locates all matching WindowsElements using the resolved XPath.
63+
/// Locates all matching AppiumElements using the resolved XPath.
6364
/// </summary>
64-
public override IEnumerable<WindowsElement> FindAllElements(WindowsDriver<WindowsElement> driver)
65+
public override IEnumerable<AppiumElement> FindAllElements(WindowsDriver driver)
6566
{
6667
var location = driver.CurrentWindowHandle;
6768
var xpath = ResolveLocator(location, driver);
68-
return driver.FindElementsByXPath(xpath);
69+
return driver.FindElements(By.XPath(xpath));
6970
}
7071

7172
/// <summary>
72-
/// Locates a single AppiumWebElement in the context of a parent element using the resolved XPath.
73+
/// Locates a single AppiumElement in the context of a parent element using the resolved XPath.
7374
/// </summary>
74-
public override AppiumWebElement FindElement(WindowsElement element)
75+
public override AppiumElement FindElement(AppiumElement element)
7576
{
7677
var location = element.WrappedDriver.CurrentWindowHandle;
77-
var xpath = ResolveLocator(location, element.WrappedDriver as WindowsDriver<WindowsElement>);
78-
return element.FindElementByXPath(xpath);
78+
var xpath = ResolveLocator(location, element.WrappedDriver as WindowsDriver);
79+
return element.FindElement(By.XPath(xpath));
7980
}
8081

8182
/// <summary>
82-
/// Locates all matching AppiumWebElements in the context of a parent element using the resolved XPath.
83+
/// Locates all matching AppiumElements in the context of a parent element using the resolved XPath.
8384
/// </summary>
84-
public override IEnumerable<AppiumWebElement> FindAllElements(WindowsElement element)
85+
public override IEnumerable<AppiumElement> FindAllElements(AppiumElement element)
8586
{
8687
var location = element.WrappedDriver.CurrentWindowHandle;
87-
var xpath = ResolveLocator(location, element.WrappedDriver as WindowsDriver<WindowsElement>);
88-
return element.FindElementsByXPath(xpath);
88+
var xpath = ResolveLocator(location, element.WrappedDriver as WindowsDriver);
89+
return element.FindElements(By.XPath(xpath));
8990
}
9091

9192
/// <summary>
@@ -94,7 +95,7 @@ public override IEnumerable<AppiumWebElement> FindAllElements(WindowsElement ele
9495
/// <param name="location">Desktop app window handle or location identifier.</param>
9596
/// <param name="driver">WindowsDriver for presence checking.</param>
9697
/// <returns>A valid XPath string.</returns>
97-
private string ResolveLocator(string location, WindowsDriver<WindowsElement> driver)
98+
private string ResolveLocator(string location, WindowsDriver driver)
9899
{
99100
// Step 1: Try RAG memory (PageObjects index)
100101
if (_tryResolveFromPages)
@@ -129,7 +130,7 @@ private string ResolveLocator(string location, WindowsDriver<WindowsElement> dri
129130
/// <param name="instruction">The natural language instruction for the element.</param>
130131
/// <param name="driver">WindowsDriver for presence checking.</param>
131132
/// <returns>XPath string if found; otherwise null.</returns>
132-
private string TryResolveFromPageObjectMemory(string instruction, WindowsDriver<WindowsElement> driver)
133+
private string TryResolveFromPageObjectMemory(string instruction, WindowsDriver driver)
133134
{
134135
var match = SemanticKernelService.Memory
135136
.SearchAsync(instruction, index: "PageObjects", limit: 1)
@@ -160,7 +161,7 @@ private string TryResolveFromPageObjectMemory(string instruction, WindowsDriver<
160161
/// <param name="driver">WindowsDriver for presence checking.</param>
161162
/// <param name="maxAttempts">Maximum number of attempts to generate a working selector.</param>
162163
/// <returns>XPath string if found; otherwise throws InvalidOperationException.</returns>
163-
private string ResolveViaPromptFallback(string location, WindowsDriver<WindowsElement> driver, int maxAttempts = 3)
164+
private string ResolveViaPromptFallback(string location, WindowsDriver driver, int maxAttempts = 3)
164165
{
165166
var viewSnapshotProvider = ServicesCollection.Current.Resolve<IViewSnapshotProvider>();
166167
var failedSelectors = new List<string>();
@@ -222,9 +223,9 @@ private static string ParsePromptLocatorToXPath(string promptResult)
222223
/// <param name="driver">The WindowsDriver instance.</param>
223224
/// <param name="xpath">The XPath locator to check.</param>
224225
/// <returns>true if at least one element is found; otherwise false.</returns>
225-
private static bool IsElementPresent(WindowsDriver<WindowsElement> driver, string xpath)
226+
private static bool IsElementPresent(WindowsDriver driver, string xpath)
226227
{
227-
try { return driver.FindElementsByXPath(xpath).Any(); }
228+
try { return driver.FindElements(By.XPath(xpath)).Any(); }
228229
catch { return false; }
229230
}
230231

templates/Bellatrix.Desktop.Tests/WindowsCalculatorTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void Addition()
2020
App.Components.CreateByName<Button>("Equals").Click();
2121

2222
var calculatorResult = GetCalculatorResultText();
23-
Assert.AreEqual("12", calculatorResult);
23+
Assert.That(calculatorResult, Is.EqualTo("12"));
2424
}
2525

2626
////[TestMethod]
@@ -34,7 +34,7 @@ public void Division()
3434
App.Components.CreateByAccessibilityId<Button>("num1Button").Click();
3535
App.Components.CreateByAccessibilityId<Button>("equalButton").Click();
3636

37-
Assert.AreEqual("8", GetCalculatorResultText());
37+
Assert.That(GetCalculatorResultText(), Is.EqualTo("8"));
3838
}
3939

4040
////[TestMethod]
@@ -46,7 +46,7 @@ public void Multiplication()
4646
App.Components.CreateByXPath<Button>("//Button[@Name='Nine']").Click();
4747
App.Components.CreateByXPath<Button>("//Button[@Name='Equals']").Click();
4848

49-
Assert.AreEqual("81", GetCalculatorResultText());
49+
Assert.That(GetCalculatorResultText(), Is.EqualTo("81"));
5050
}
5151

5252
////[TestMethod]
@@ -58,7 +58,7 @@ public void Subtraction()
5858
App.Components.CreateByXPath<Button>("//Button[@AutomationId='num1Button']").Click();
5959
App.Components.CreateByXPath<Button>("//Button[@AutomationId='equalButton']").Click();
6060

61-
Assert.AreEqual("8", GetCalculatorResultText());
61+
Assert.That(GetCalculatorResultText(), Is.EqualTo("8"));
6262
}
6363

6464
private string GetCalculatorResultText()

0 commit comments

Comments
 (0)