I create some custom copying functionality for my web application that I want to test. I can't find any Keywords for copying or pasting in the documentation though. Does anything like this exist?
-
I am not sure I understand the question - RobotFramework will only manage your testing, it won't test your website? If you're asking how to copy and paste using selenium and python - I've provided an answer. Otherwise please edit your question to be more clear, thanks!– Ory ZaidenvormMar 29, 2016 at 4:58
-
Unfortunately this functionality is not available and issue for that is open for more then 2 years already. github.com/robotframework/SeleniumLibrary/issues/498– Pavol TravnikJan 31, 2018 at 12:11
5 Answers
You can use the following code for copy paste in Robot Framework
1.Install clipboard library using command in CMD : pip install clipboard
2.use code:
Copy To Clipboard ${TextToCopy}
Click Element ${TargetLocator}
Press Key ${TargetLocator} \\22
You can use Selenium2Library that has a keyword name Press Key
then we could get the values from ascii table such as ASCII Table
We can see that ctrl+A hex value is 01 - we need to hit that to highlight the text.
You could try something like this
Copy Text and Paste Text
[Documentation]
... CTRL-A -> 1
... Copy-> 03
... Paste -> 16
Press Key ${seleniumLocator} \1 #Highlight the text Ctrl+ A
Press Key ${seleniumLocator} \03 #Copy Text Ctrl + c
Press Key ${Some_Other_Locator} \16 # Paste Text Ctrl+ v
For copying and pasting using Selenium + python (using keyboard shortcuts):
Performing-a-copy-and-paste-with-selenium-2
You can also create a method to re-use (e.g. using RobotFramework):
You will need to first import the selenium2 library for RobotFramework.
-
You are mixing Robot Framework and Selenium library in Python itself. Can you explain the example more specifically please? I can not understand, how you can directly call Selenium functions from Robot Framework. Jan 31, 2018 at 14:32
-
I'm sorry, my answer was to point out that you can script copy/paste in Selenium+Python (as an example). I was not aware RobotFramework had a limitation in regarding to implementing that. From what I can see from the link you pasted there's a hack that still works - github.com/robotframework/SeleniumLibrary/issues/… Mar 12, 2018 at 14:29
I have been using RFW for a while now. I've never heard of copy/paste as you mentioned.
Thus, the only way would be custom your own keywords based on python libraries.
You can use the OS library of Robot Framework http://robotframework.org/robotframework/latest/libraries/OperatingSystem.html#Copy%20File