TestStack / White

DEPRECATED - no longer actively maintained
Other
1.02k stars 485 forks source link

window.Get<Buttons> ByText not working! Please help me! #656

Open gaslix opened 4 years ago

gaslix commented 4 years ago

Dear,

I'm beginner with C# and White, and I'm trying to automate a very stupid action => Click on the "New" button in Notepad++. Challenge, I'm building a DLL => I use that DLL in Automation Anywhere (Metabot).

Here is my DLL code :

using System; using System.Diagnostics; using System.Windows; using TestStack.White; using TestStack.White.WindowsAPI; using TestStack.White.UIItems; using TestStack.White.UIItems.Finders;

namespace MyAADLL { public class MyAAClass { public static void ClickButton2(string procName, string applicLaunch, string applicAttach, string getWin, string automationId) { Application application; Process[] processes = Process.GetProcessesByName(@procName); if (processes.Length == 0) { application = Application.Launch(@applicLaunch); } else { application = Application.Attach(@applicAttach); } TestStack.White.UIItems.WindowItems.Window window = application.GetWindow(getWin); TestStack.White.UIItems.Button button = window.Get(TestStack.White.UIItems.Finders.SearchCriteria.ByText(automationId)); button.Click(); } } }

I'm trying to make the ClickButton2 function working.

Actually, I provide "notepad++" as value for procName, applicLaunch, applicAttach, "new 5 - Notepad++" as value for getWin and "New" for automationId.

The script is failing when it comes to "TestStack.White.UIItems.Button button = window.Get(TestStack.White.UIItems.Finders.SearchCriteria.ByText(automationId));".

Could one of you help me with that ? I'm sure for you it's gonna be easy to solve ;-)

Thanks!

Augustin