New to Telerik Test Studio? Start a free 30-day trial
Log Clipboard Text
My test copies text into the Clipboard and I would like to log its content.
Solution
This is possible with a coded solution:
- Add an Assembly Reference to System.Windows.Forms.
- Add a coded step to the test after the step that populates the Clipboard.
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);
}
}
}