New to Telerik Test Studio Dev EditionStart a free 30-day trial

Log Clipboard Text

My test copies text into the Clipboard and I would like to log its content.

Solution

Here is the full code-behind file, excluding the standard using/Imports statements and the Dynamic Pages Reference region:

C#
    using System.Windows.Forms;
    using System.Threading;
    
    namespace TestProject8
    {     
        public class ClipboardTest : BaseWebAiiTest
        {  
            public string ClipboardMethod()
            {
                string content = Clipboard.GetText();
                return content;
            }
        
            [CodedStep(@"New Coded Step")]
            public void ClipboardTest_CodedStep()
            {
                string content = string.Empty;
                
                var thread = new Thread(obj =>
                {
                    content = this.ClipboardMethod();
                });
                
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();
                
                Log.WriteLine(content);
            }
        }
    }
In this article
Solution
Not finding the help you need?
Contact Support