简体   繁体   中英

TestStack.White panel click

I want to create an autologin WinForms app with TestStack.White. Here is my code:

private void button1_Click(object sender, EventArgs e)
{
         Process[] process = Process.GetProcessesByName("XYapp");

         TestStack.White.Application app = TestStack.White.Application.Attach(process[0].Id);
         TestStack.White.UIItems.WindowItems.Window window = app.GetWindow("XYwindowName", TestStack.White.Factory.InitializeOption.NoCache); 
         TestStack.White.UIItems.Panel panel = window.Get<TestStack.White.UIItems.Panel>(TestStack.White.UIItems.Finders.SearchCriteria.ByText("Login"));
         panel.Click();
         ...
}

The XY app main window has 10+ panels and one of them is the "Login" panel. When I click the button1, the XY app "Login" panel will be visible, so it works.

But my WinForms app freezes and I get the control back when I close the XY program but I want to run further.

In debug mode, the following error message is displayed: "Managed Debugging Assistant 'DisconnectedContext' : 'Transition into COM context 0x15305d0 for this RuntimeCallableWrapper failed..."

I think I understand why I get this message, but I have no idea what the solution is.

Someone could help me? thanks

I'm sorry for the stupid question, the solution is simply just make a new thread.

https://docs.microsoft.com/en-us/windows/desktop/winauto/uiauto-threading

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM