Wednesday, April 10, 2013

Including the Rake task on your script



This line of code is very helpful when you want to include running the rake task  itself  in your script (a task that is being done manually through some third party ide like Putty #for windows to execute a specific  line of code to a bulk of data )

Just include this one-liner code on your rb or spec file:

`ssh ubuntu@your_staging_server.com -t ubuntu@your_staging-server.com "sudo -i -u server_build; cd /your/folder/here; bundle exec rake your_name_of_rake_task_here" `

How to inject text on Tinymice

Having a lot of troubles trying to type a text with tinymice - automation? Found some solutions that i have used for some inconsistent behavior of tinymice box in different browsers:
First, tried using this;


     browser.select_frame 'frame_id_here_ifr'
     browser.focus '//body[@id="tinymce"]'
     browser.type_keys '//body[@id="tinymce"]',"your text here" 
     browser.select_window "name_of_the_window_here"


But still, this solution is not applicable for all browsers (because of radical changes of versions cof firefox). Well, you can also try the command, the "run_script"

To explain:
 "Creates a new "script" tag in the body of the current test window, and adds the specified text into the body of the command. Scripts run in this way can often be debugged more easily than scripts executed using Selenium‘s "getEval" command. Beware that JS exceptions thrown in these script tags aren‘t managed by Selenium, so you should probably wrap your script in try/catch blocks if there is any chance that the script will throw an exception.
‘script’ is the JavaScript snippet to run"

command: run_script

target: tinyMCE.activeEditor.setContent('Replace with your text')
ex. 
browser.run_script "tinyMCE.activeEditor.setContent('your desired text here')"