Please help with the extension methods
HausBJB opened this issue · 1 comments
Hello @rickjet,
first of all great work. thanks for that
I have a problem with the extension methods.
I have the following code that I want to run.
here is the script:
string code = $@"
public async Task<bool> Run()
{{
var app = FlaUI.Core.Application.Launch(@""C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"");
using (var automation = new UIA3Automation())
{{
Task.Delay(2000).Wait();
var window = app.GetMainWindow(automation);
var button1 = window.FindFirstDescendant(cf => cf.ByAutomationId(""msotcidPlaceOfficeStart"")).AsListBoxItem();
button1?.Select();
}}
return true;
}}";
public async Task<bool> RunCode(string code)
{
if (!string.IsNullOrEmpty(code))
{
var script = CSharpScriptExecution.CreateDefault();
script.AddNetCoreDefaultReferences();
script.AddAssembly("FlaUI.Core.dll");
script.AddAssembly("FlaUI.UIA3.dll");
script.AddAssembly("System.Diagnostics.Process.dll");
script.AddAssembly("System.Threading.Tasks.dll");
script.AddNamespace("FlaUI.UIA3");
script.AddNamespace("FlaUI.Core");
script.AddNamespace("System.Threading.Tasks");
var result = await script.ExecuteMethodAsync<bool>(code, "Run");
}
return true;
}
But I keep getting the following exception
(30,110): error CS1061: \"AutomationElement\" enthält keine Definition für \"AsListBoxItem\", und es konnte keine zugängliche AsListBoxItem-Erweiterungsmethode gefunden werden, die ein erstes Argument vom Typ \"AutomationElement\" akzeptiert (möglicherweise fehlt eine using-Direktive oder ein Assemblyverweis).\r\n(23,25):
It does not find the extension method, namely this one
var button1 = window.FindFirstDescendant(cf => cf.ByAutomationId("msotcidPlaceOfficeStart")).AsListBoxItem();
AsListBoxItem()
Sorry forgot a namespace