2

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?

chopper draw lion4
  • 12,401
  • 13
  • 53
  • 100
  • 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 Zaidenvorm Mar 29 '16 at 04:58
  • Unfortunately this functionality is not available and issue for that is open for more then 2 years already. https://github.com/robotframework/SeleniumLibrary/issues/498 – Pavol Travnik Jan 31 '18 at 12:11

5 Answers5

2
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
1

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
AutoTester213
  • 2,714
  • 2
  • 24
  • 48
0

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):

Paste command using Selenium

You will need to first import the selenium2 library for RobotFramework.

Ory Zaidenvorm
  • 896
  • 1
  • 6
  • 20
  • 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. – Pavol Travnik Jan 31 '18 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 - https://github.com/robotframework/SeleniumLibrary/issues/275#issuecomment-35382111 – Ory Zaidenvorm Mar 12 '18 at 14:29
0

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.

AhmedWas
  • 1,205
  • 3
  • 23
  • 38
-1

You can use the OS library of Robot Framework http://robotframework.org/robotframework/latest/libraries/OperatingSystem.html#Copy%20File