2626using System . Linq ;
2727using System . Text . RegularExpressions ;
2828using System . Threading ;
29+ using OpenQA . Selenium ;
2930
3031namespace 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
0 commit comments