How to copy to a text file in Robot Framework? - robotframework

I am writing Robot Framework automation tests for a web app and need to be able to copy text from the app into a notepad/notepad++ text file, by clicking the 'copy' button on the app and then pasting into the file, but I'm really struggling with the last bit. I can create the text file, but I don't understand how to then paste the text into it. Any help would be really gratefully appreciated.
Here's a snippet of my test:
`Click Element ${SELECT_FIRST_ACQ}
Sleep 1s
Page Should Contain Element ${DV_INFO_DATE}
Click Element ${DV_CALIBRATION}
Sleep 1s
Click Button ${DV_COPY_CAL}
Sleep 1s
Create File C:/Users/Deployment/Desktop/test.txt
Append To File C:/Users/Deployment/Desktop/test.txt`
(this is where I get stuck. If it were in the app itself, I could use the Press Keys keyword, but that obviously doesn't work here, because my file is external to the app and not a variable).

Related

Copy to clipboard on empty selection in the Jupyter notebook

I would like to disable the default copy on empty selection in the Jupyter notebook. A corresponding problem in the Sublime text editor can be solved easily as explained in an answer to the Sublime: how to disable empty copy question (similarly for VSCode as in How to stop copying the white space, on a blank line, in Visual Studio Code?).
Jupyter scenario: whilst the text selection is empty, press the copy keyboard shortcut (ctrl+c / command+c).
Current behavior: copies the current line to clipboard, overwriting its content.
Expected behavior: do nothing and keep the clipboard content intact.
Please avoid flame wars: I realize this is a feature for some people and I don't ask for changing the defaults. However, I find it useful not to lose the copied selection by mistake while hitting ctrl+c / command+c instead of ctrl+v / command+v and having to go through ctrl+z stack popping. Peace!

Jupyter notebook markdown without mouse click

For markdown there is a shortcut like typing a number(1,2,3,4..) in command mode (Esc) and then giving an Enter
The thing is that your cursor gets before the "###" (if you used 3) where you also need to click the End key to be able to write.
Is there a way to overcome the last action as it is very annoying.
What you already have is a one click solution, which is going to be hard to beat. The only improvement I can think of is to override the functionality that's inserting the markdown headings for you. You could extend it to also place the cell in edit mode and move the cursor to the end. This would be placed in your custom.js file, which you place here: ~/.jupyter/custom/custom.js.

Tosca: Can we scan Notepad.exe?

So, as I'm learning Tosca, I tried to scan the simple program Notepad.exe that comes with windows... and I can't seem to figure it out. Is it even possible with Tosca 9.2? Is it possible with Tosca 10?
The best I was able to do so far was to scan Notepad as an "other", and switch on the Options > Use UIAEngine... and then it was only really able to see the main editbox... menu headers could be scanned, but none of the menu options like file > Open... or Edit > Replace... which would make being able to automate Notepad.exe useful.
Is it just not possible yet?
It is possible with TOSCA 10. I just tried and scanned Notepad instance with Desktop option from Module Folder > [right click] Scan Application > Desktop. It shows all the open browsers, Notepad instance, folders and desktop.
I scanned a module of Notepad which had only two attributes (because I selected only those) - Text area of Notepad and its close button. I created a test case where I inputted 'This' in the text area and clicked the close button. The test case also works fine.
Hope this helps!
The performance is much faster if you use the below modules instead of opening it UI. You can read/write and play around in the text file.
TBox Read/Create File
File system operations
TEXTSTREAM

Brackets Code Complete Not working

I have installed Brackets with Tern Intelligence.
Inside my file Main.js, I type the following thing
Math.
And press ctrl-enter. I imagine I should see pow,max,etc, show up. What am I missing?
Code hints should appear automatically - no need to press anything. (If you do want to trigger them manually though, it's Ctrl-Space, not Ctrl-Enter).
What's in the rest of your Main.js file? If you make a new, blank JS file does it work? When I type Math. in an empty .js file, I see a list of code hints both while I'm typing Math and the appropriate list of options after typing the .
Also, try using Debug > Reload Without Extensions to make sure you don't have an extension installed that could be causing a problem.

How to handle File Upload in Robot Framework

I have excel importer in my application when I click on the "Upload" button I will get a pop up window with file upload screen where I can select the excel from the specified path. How to handle this in Robot Framework? Can any one help me how to handle the case?
Selenium2Library provides Choose File keyword for the same.
It takes two arguments, first is locator for the button and second is path to the file which needs to be uploaded.
e.g.
Choose File xpath=.//div/input ${TEMPDIR}${/}file_pa.csv
If you're using a dialog or input that WebDriver can interact with, then Sachin's answer about Choose File is the way to go.
If you're talking about the pre-HTML5 file-chooser dialogs provided by the browser, then Selenium2Library can't do this. However RobotFramework isn't just a wrapper around Selenium2Library so you can use something else that allows you to interact with the file upload screen.
I've done it in the past using AutoIt.
If you're not explicitly testing the upload dialog (and why should you, since it's provided as an atomic widget by your browser) then you should consider ways to simply avoid it. Perhaps a simple rest interface for uploading files.

Resources