Testing Copying/Pasting with RobotFramework - selenium

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?

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):
Paste command using Selenium
You will need to first import the selenium2 library for RobotFramework.

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

Related

using greek letters as variable names

How would I enter greek letters to be used e.g. as variable names in Python 3 under Spyder? Currently I'm using the following Python code on the console:
s = '\u03B1'
print(s)
α is printed on the console and I can copy it into my source. I was wondering if there is a way to directly enter it into my console, perhaps even some macro that automatically replaces \alpha with α.
In the Spyder IPython console, typing \alpha followed by a tab gives you α. You can then copy paste it into the Python editor. I am searching for a better solution.

How to paste multiple environment variables in IntelliJ

Is there a way to add multiple environment variables in IntelliJ? When one sends me a list of variables I can add them one by one by clicking + in this window
But it's quite annoying to do for 10 or 20 variables every time. I can copy all variables from Environment variables field but we cannot paste there. Is there any way to do it?
Yes, it's totally possible to paste all environment variables at once in this screen but they need to be in a specific format.
Click on the ... button to the right of environment variables to show the dialog you have in your first screenshot.
Now you can use the Paste button but the values in your clipboard have to be in a specific format for pasting to work. In your case that clipboard info would be something like this:
APP_PORT=8080
DB_URL=jdbc:mysql...
DB_USER=javausers
DB_PASSWORD=javausers
APP_LOGGING_LEVEL=DEBUG
Try copying the value above and use the paste button (not Ctrl+v). If you don't have your data in this format you can try formatting it using a text replace tool online.
Also if you select all of the values in that dialog and click the copy button you can get the values in the same format that will work with importing. Warning: clicking Ctrl+c will not copy the values in the same format as the copy button in the dialog.
You could use "Paste" button at the bottom of the variables list.
Yes, just:
Click on the three dots (...) button of the Environment variables option. On the Windows version, the button is a little folder icon.
Select all the variables on the showed popup (name and value) and click on the "Copy" button. Close the popup.
Choose the other configuration, open his Environment variables option and click on the "Paste" button.
I am not sure if the (...) option is available in the community edition also.
This is how i was able to add them to the configuration. Just select the environment variables you want to import into the desired configuration.
E.g: If you have variables like
min_instance_count: 1
max_instance_count: 2
min_memory: 2
max_memory: 2
Replace the colons/other delimiters with = :
min_instance_count= 1
max_instance_count= 2
min_memory= 2
max_memory= 2
Now import the variables by copy-pasting (the clipboard sign).
You can simply paste a ; concatenated list of environment variables (and their values) into the Environment Variables dialog box.
E.g. paste in:
AWS_DYNAMO_ENDPOINT=http://localhost:4569;AWS_REGION=us-east-1;sample_var=sample
and get:

How to select a text and put it directly on the search and replace bar of IntelliJ

I'm an IntelliJ user since years and I work on a Mac.
For a long I was able to execute like an automata the following procedure:
select a portion of a text in a file using the mouse
pressing a combination of keys
seeing the selected text in the find & replace bar of the IDE.
Now, I can't remember how to do it.
I have search through the docs of the search & replace in a file, but I cannot see that option.
Just to avoid confusion, the toolbar I'm talking about is the following
I am using IntelliJ on linux (Keymap : Default for xwin) and to select text I use Ctrl+W or Mouse double click. Then ctrl+R will put this text in replace text box
Probably it's a kind of bug. It should work by selecting the text and pressing cmd+r.
Cases when it works:
I select a piece of text in a line and I press cmd+R.
I select the whole line (including white spaces/tabs at the beginning)
Case when does not work:
I select a line from the first character to the last.
More context. I use IntelliJ 2017.2.5 on Mac Os Sierra.

Is there a shortcut for selecting word under cursor in Sublime Text, Atom

Is there a shortcut or a command to select word under cursor in Sublime Text or Atom? I want a replacement for double-click. So I could press shortcut instead and get selection on a current word and start typing to replace it or get in quotes etc...
command+d on OSX
control+d on Windows/Linux
You can find all the default keybindings by going to Preferences > Keybindings - Default and perusing the list.
You can add a key binding to select the word:
{ "keys": ["ctrl+shift+w"], "command": "expand_selection", "args": {"to": "word"} }
Unlike the find_under_expand command (control+d by default) repeated presses won't add cursors at matching words.
install ExpandRegion if you want to expand the selection:
Expand selection to word
Expand selection to quotes (content only)
Expand selection to quotes (with quotes)
Expand selection to complete self closing tag
Expand selection to parent node content
Expand selection to complete node
Expand selection to parent node content
I looked around for this and eventually came up with this, which I assigned to ctrl-F
you need to paste it into a new user plugin python file
import sublime, sublime_plugin
class find_under_cursor(sublime_plugin.WindowCommand):
def run(self):
view = self.window.active_view()
view.run_command("expand_selection", {"to": "word"})
view.run_command("slurp_find_string")
self.window.run_command("show_panel", {"panel": "find", "reverse": False} )
With Vim bindings (Vintage or vintageous)
* - to find next
# - to find last
For both, all matches are highlighted
Without Vim bindings
For current file: CMD+E, CMD+F, Enter
Explanation:
CMD+E - copies the word under cursor
CMD+F - bring up find in local file dialogue
Enter - er you know what this means
Substitute CMD+F for CMD+SHIFT+F to find in all files in project (or whatever search range you specify)

How to preserve formatting from rstudio when copy/pasting to Word?

I want to reproduce my code in Word 2010. The scripts were written in rstudio, and I would like to preserve rstudio's formatting when pasting into Word. Principally, I like the font colors and spacing that rstudio uses. I find that when I paste from SAS to Word, the formatting is preserved, but no dice here.
I would usually look for copy special / paste special options to do this, but I can't find any. When I try to paste special into word, only unformatted text options are presented. I would rather not reformat the text line-by-line, because I think it looks pretty nice in rstudio.
I thought of trying to save the script in rstudio to some format that would preserve its formatting, but I couldn't find any way to do this. How can it be done?
It's not totally clear whether you are pasting from RStudio's script editor (which has some 4 or 5 colors) or from the R console (script + output) within RStudio (which only has 2 colors).
If you are pasting from the console--please check "Paste special" again. There should be an option for "HTML Format" that will do what you need (though you may need to resize the font to make everything fit properly depending on your page margins).
If you are pasting from the script editor, then you're out of luck with a direct copy-and-paste solution. But there is a copy-and-paste-and-copy-and-paste solution...
One solution could be to use Notepad++. From RStudio, save your script (with a ".R" extension) then open the script in Notepad++. (Or copy and paste from RStudio to Notepad++, but make sure you set the file's language--from the "Language" menu--to R). When your script is correctly highlighted in Notepad++ go to the "Plugins > NppExport > Copy HTML to clipboard" menu to copy the open file. This can then be pasted into MS Word with HTML format.
Just in case someone else looks for this question...
Another way to have all the source code in a word document with a good-looking format using RStudio is to use the File/Compile Notebook option, choosing MS Word as the output format.
Using this option, a .docx document will be generated with the output of your script as well as the original source code. The script will be executed, though.
If you don't want your code to be evaluated (you just want a simple copy-paste), you can add #+eval=FALSE at the beginning of your script and then the source code will be reproduced in the word document without being evaluated.
This approach relies on knitr. Here is an example if anyone wants to start playing with this.
#' ---
#' title: "My homework"
#' author: John Doe
#' date: June 15, 2015
#' output: word_document
#' ---
# The header above sets some metadata used in the knitr output
# Conventional comments are formatted as regular comments
# Comments starting with "#+" control different knitr options.
#+echo=FALSE,message=FALSE,warning=FALSE
library(ggplot2)
#+echo=TRUE
#' Comments with a "+" sign are used to tell knitr what should be
#' done with the chunk of code:
#'
#' - echo: Show the original code or not
#' - eval: Run the original code or not
#' - message: Print messages
#' - warning: Print warnings
#' - error: Print errors
#' ...
#' Comments with an apostrophe "'" will be printed as regular text.
#' This is very useful to explain what you are actually doing!
# Regular comments can be used to document the code as usual
# Figures are printed:
ggplot(mpg, aes(x=cty, y=hwy)) + geom_point(aes(color=class))
#' Formatting **options** are possible.
#' Even [links](http://stackoverflow.com/questions/10128702/how-to-preserve-formatting-from-rstudio-when-copy-pasting-to-word)
#'
#' This will show all the packages and versions used to generate this document.
#' It can be used to make sure that your teacher has all he needs to run your script
#' if he/she wants to.
sessionInfo()
Assuming you have internet access
Copy and paste to gist.gisthub.com
Select 'R' as the language - this should provide colours
Hit create (secret or public) gist
Copy and paste from the gist to your word processor.
Compared with the notepad++ solution:
An online backup to your code, with a recording of the time when you clipped it.
You don't have to install any other software, useful if you're a student using a public computer.
If you just need the code as formatted:
Step1: Just add #+eval=FALSE at the beginning of your code.
Step2: Then go to File -> Knit Document. Compile the file in msword/PDF/Html.
OR
Just add #+eval=FALSE at the beginning of your code.
Press CTRL+SHIFT+K and then compile the file in msword/PDF/Html.
If you need the code with output do not enter add #+eval=FALSE at the beginning of your code and perform step 2 directly.
I agree with zeehio that using Knitr is probably the best option. But another way is to use the Pretty R tool and the "open document text" steps here. Basically just copy and paste your code into pretty R, and copy and paste the output (not the html) into the open document.
After you copy from the Rstudio Console window and paste into a Word document, you need to highlight all the the just copied text and change the font into Courier New. This will give you the same spacing and lineup as you had in the Rstudio Console window.
Copy paste the code from Rstudio editor to 'visual studio code' & then again copy from there into a word processor.
For this to happen you must first install R extension in visual studio code.
'Visual studio code' is itself an IDE which can potentially be used for R language as well, but right now I'm emphasizing on using it to answer the above question.
In R I use the Monaco editor font. To copy paste the output of the R consol in Microsoft Word, I select the output of the consol, right click and copy and paste in my Word document. Once I have pasted the output in word, I select it and put it in Word's Monaco font and reduce the size of the font if necessary.
This does the job very nicely and perfectly preserves the output style from the R consol, as well as written chunks of code.
If you want to retain the formatting when coping a selection from the R Console you will need to install an older version of R Studio. Version 1.2.5042. it will not work in the newer versions