I am working on a test for a Web Application. I want to simulate the Copy command and verify the value of the Clipboard.
I have two ways to simulate this:
- I simulate "Ctrl+C" by using this code:
System.Windows.Forms.SendKeys.SendWait("^{c}");
- I use a button on my App which executes Copy on some text and puts it on the Clipboard
These two work and after using one of them, I can do "Ctrl+V" and it pastes the text correctly.
On my test, I am supposed to verify that the Clipboard contains the correct value.
I am using this code to check if the Clipboard is not empty and that it contains the correct string:
Clipboard.ContainsText(); // verify that Clipboard is not empty
Clipboard.GetText(); // verify that string on the Clipboard contains the good string
But after I simulate a Copy (with one of options above), the code just above returns respectively:
false
""
Does anyone have a solution to fill the Clipboard and to see its contents?