public async Task WpfInteractionAsync() { VisualStudio.InteractiveWindow.SubmitText( @"#r ""WindowsBase"" #r ""PresentationCore"" #r ""PresentationFramework"" #r ""System.Xaml""" ); VisualStudio.InteractiveWindow.SubmitText( @"using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging;" ); VisualStudio.InteractiveWindow.SubmitText( @"var w = new Window(); w.Title = ""Hello World""; w.FontFamily = new FontFamily(""Calibri""); w.FontSize = 24; w.Height = 300; w.Width = 300; w.Topmost = true; w.Visibility = Visibility.Visible;" ); var testValue = Guid.NewGuid(); VisualStudio.InteractiveWindow.SubmitText( $@"var b = new Button(); b.Content = ""{testValue}""; b.Margin = new Thickness(40); b.Click += (sender, e) => Console.WriteLine(""Hello, World!""); var g = new Grid(); g.Children.Add(b); w.Content = g;" ); await AutomationElementHelper.ClickAutomationElementAsync( testValue.ToString(), recursive : true ); VisualStudio.InteractiveWindow.WaitForLastReplOutput("Hello, World!"); VisualStudio.InteractiveWindow.SubmitText("b = null; w.Close(); w = null;"); }