Ruby browser automation - ruby

I want to write ruby script which run browser (for example, firefox), open web-addresses, click links, check/uncheck boxes and other stuff. What gem can i use for that?

Selenium / Selenium Ruby is another option and there's Selenium IDE for scripting Firefox.
"It is implemented as a Firefox extension, and allows you to record,
edit, and debug tests."

Check watir and watir_webdriver which is used for automated web browser testing but it can be used for browser scripting from ruby http://watir.com/

you can use the rb-appscript framework to automate macosx
http://appscript.sourceforge.net/rb-appscript/index.html
Its a ruby framework that uses the applescript interfaces to interact with the macos applications.
I'm not sure if there is a gem you can use to install yet but there is are install instructions in the link above.
there is a nice article at http://www.apeth.com/rbappscript/00intro.html that shows how to replace applescript with ruby using rb-appscript

Check out watir, watir-webdriver or firewatir. It's very easy to use especially if you're just starting out. You can check out this quick tutorial on how to set it up, it's extremely easy.
http://webmites.org/watir-automated-tests-for-everyone/

Related

Is it possible to automate installion using Ruby or Watir?

Currently we are installing our setup(.exe file) on daily basis for testing purpose.I want to automate my installation using Ruby or Watir.Is it possible to automate? Please help me how to perform and give your suggestions.
There are many libraries available for Ruby. Watir itself is constrained to the web browser. Although it does have some technology it's built on top of that should allow Windows environment control. Some of the libraries you can try are Win32-autogui, RAutomation, and windows-pr to name a few.
If you are installing for testing purposes, you can use autoit. It will run your installer, and you can handle some unexpected (though anticipated) errors. I wouldn't use autoit for testing, just for setting up to test.

Headless execution of watir scripts on windows

I am in a need of running my watir scripts headless. I browsed a lot and found that there is a headless gem for running scripts, but it is specific to linux. I am on windows 7 64-bit so I cannot make use of the headless gem. Is there any way that I can run my watir scripts headless on windows.?
I am using watir 2.0.4 and ruby 1.9.3. And one more thing is that it would be great if their is solution that can work on watir 2.0.4 because I would like to stick to it..
Thanks in advance.
I have got exactly what you are looking for, check it here. I have tried and tested it, its working fine.
It is super is easy to configure and its execution is faster than other GUI browsers.

Coverage for desktop application in Ruby

I am writing a simple desktop application in Ruby. For testing my choice is minitest.
Now I want to measure test-coverage. In case of Ruby on Rails you can use Simplecov (https://github.com/colszowka/simplecov).
Can it be used with desktop app? If so, how?
(I am newbe in Ruby).
The docs do seem to be written with a bias towards Rails apps, but I don't see anything in there that should prevent you from being able to use Simplecov with any Ruby application, GUI or otherwise. I've used Simplecov for command line apps in the past.
And using minitest should not give you any problems either, based on the section titled "Use it with any framework".

Portable Ruby GUI Toolkit

I am in need of a GUI toolkit that goes a little further than tk does, but my school's computers do not allow programs to run if they try to create/alter files on the local disk. Because of that, I need a portable GUI toolkit for Windows. Does anybody know of one?
Green Shoes, just install the gem, copy it along with your Ruby map to a stick and you are off to go.
gem install green_shoes
http://ashbb.github.com/green_shoes/App.html
a simple sample
require 'green_shoes'
Shoes.app{
e = edit_line
button("Click me!"){alert("You entered #{e.text}")}
}
Qt4 and ruby-qt (the qtbindings gem works beautifully to get the ruby bindings)
For graphical applications in Ruby, I personally prefer JRuby + Swing. Presumably your school's computers have a JRE installed... perhaps you can run JRuby from your flash drive?
I see you haven't yet accepted an answer, so i try another suggestion.
Again, you only need a Gem, Watir in this case.
Your browser is the GUI.
Here a question i asked and the answer i accepted
http://stackoverflow.com/questions/11724201/use-browser-as-gui-in-ruby
That example uses IE but the other browsers are possible too, this solution is cross-browser and cross OS

Are there any good scriptable webpage rendering engines besides Selenium RC?

I like using Selenium RC for automating interaction with webpages that require JavaScript, except for the fact that it goes through launching an full instance of Firefox to run a script. Questions:
Is there a way to run Selenium RC so that it launches a headless version of Firefox that doesn't create a window? I'm using OS X. I know there is a way to do this using Xvfb on a Linux server, but I'm wondering how this would be done on OS X.
Is there any lighter weight alternative to Selenium RC? The tool would have to execute any JavaScript on a webpage and alter the DOM accordingly. I'm not too familiar with Spidermonkey; but can it be used for this purpose? Thanks.
There's a well supported Java one called HtmlUnit, which is completely headless - there is no GUI. It runs Javascript.
If you don't want to directly call Java, you can in theory run Selenium with HtmlUnit as its backend headlessly - I haven't got it to work yet though.
Also, you might find Selenium 2 better than Selenium RC. It has the WebDriver built in, and looks like it is going to be better and more complete.
Finally, you could run Selenium remotely on your own separate Linux server, and call it from the Mac remotely. Or you can use a service like Sauce Labs.

Resources