I'm building a Ruby program that uses several other programs, and while most of them are programs I can download and run on this computer, one has to be accessed and run through a web browser.
I actually have two questions: I've found Watir which looks like a good web automation tool, but it's meant for testing. Is it still okay to use Watir for automation in the main program, not for testing? Or is there something better out there to use?
The other question I have is that I can't get Watir to work. I downloaded the firewatir-1.6.5 gem and installed jssh for Firefox 3.6, but when I run
b = Watir::Browser.start("the_web_page_address")
it just opens a new Firefox window to Google, and I'm given the error:
Unable to connect to machine : foo.bar.baz.blah on port 9997. Make sure that JSSh is properly installed and Firefox is running with '-jssh' option (Watir::Exception::UnableToStartJSShException)
I've run Firefox with -jssh but that doesn't seem to help.
Watir is perfectly suitable for automating browsing tasks. I've personally used it a couple of times for that purpose. However, you might also want to look at other solutions, such as Selenium.
Now, to be honest, I don't have much to say about your second question;
I'm assuming you've set Watir to open firefox by setting
Watir::Browser.default = 'firefox'
If so, things should be running as normal. Did you restart firefox since installing jssh? Did you install Watir and jssh as instructed on the tutorial?
I can suggest running Watir with Internet Explorer, instead of Firefox, but that might be unsuitable for your application. If all else fails, try the other framework I recommended earlier.
You also might want to check out a headless option. Sometimes it's not necessary to install an automation framework like Watir or Selenium when something simple like mechanize would suffice. Really depends on the complexity of what you're trying to automate!
http://mechanize.rubyforge.org/mechanize/EXAMPLES_rdoc.html
Related
I'm looking for a ruby solution to automate web accions on a headless server (no xwindows).
What I need is to daily export a file from a webapp and import it to other web app in other server.
I've seen Selenium, Capybara, Nokogiri, but I'm confused with their differences/similarities. Selenium seems to require a browser running, which I can't have as there is no X to run it. Nokogiri can use Webkit on a headless server, but can't figure out if it can actually download/upload files.
Any pointer would be appreciated.
I would suggest mechanize. I'm not sure that you need something like selenium for a task like this.
This gem should be able to accomplish what your looking for.
It's not Ruby, but...I'd strongly consider using something like PhantomJS (+ CasperJS, perhaps) or Zombie.js. They're all JavaScript, but...I'd still see if you can make them work.
Thats basically my question. I have searched the internet and I have no idea!
I read in a tutorial (http://www.layeredthoughts.com/automation/how-to-write-your-first-ruby-web-bot-in-watir-scraping-weather-com) that I need to install JSSH for the tutorial to work, but there are no instructions on how to do this and I cannot find anything on the watir homepage.
You do not need to install the JSSH plugin to drive Firefox.
If I recall correctly, the JSSH plugin was needed several years ago - probably back in 2010 when the article you referenced was written. Driving Firefox, as well as Watir, have come a long way since then.
As a result, you should try following a more recent tutorial. Then go back to the article you were reading if there are additional tips you need, but would like need to adjust.
Ċ½eljko Filipin's Watirbook has been frequently updated with steps for installing Selenium-Webdriver on various operating systems for various browsers. Note that Watir is simply an API wrapper around Selenium.
The installation steps are simply (for more explicit details/steps see the book):
Install Ruby
Install selenium-webdriver
Install the watir and watir-webdriver gems (this is not listed in the book, but they are required if you want to use the Watir API instead)
Install Firefox (if it is not already)
That is it. The other plugins (Test-Wise Recorder, Firebug, FireXPath) are not needed. The latter two can be replaced by Firefox's built-in developer tools. The usefulness of recorder is often debated.
Once everything is installed you can start off with a script like:
require 'watir'
browser = Watir::Browser.new :firefox
browser.goto 'http://www.weather.com/
Then you can start working on automating the page.
A company I applied to had sent me a "test", which I had to decline, due to it not making a lot of sense: They asked me to use Selenium to test a Win desktop app GUI and produce bug reports in the table form. They claimed that they're using Selenium to test Win desktop applications in their company, but they wouldn't tell how.
I did some research, and my understanding is that Selenium works with web browsers only, as it's been specifically designed for this. How can it connect to Windows desktop app? I just don't see any way possible for this. I found a claim that some integrate it with another open source tool to do this, but this "test" was supposed to take 1 hour of my time and installing some other framework, configuring, integrating with Selenium, etc, etc definitely wouldn't fall into one hour time frame. I had heard from another company too, that they wanted me to use Selenium to automate non-browser stuff if they hired me... Still have no clue about this--is this even possible? -- or is it something simply wrong?
You can't. Selenium can only automate web browsers, and even then, only certain browsers (Chrome, Firefox, Internet Explorer, Opera, and occasionally Safari). It interacts with them at a very deep level, very specific to the browser in question, in ways that don't apply to other Windows applications.
Selenium is meant for GUI tests of web applications and nothing else. But you can include Sikuli in webdriver code and can test the any of the applications either desktop or web applications, since it uses Image recognition.
else if you want to test the desktop application using Selenium thne u need to import Autoit and can test those as well
I've recently started using watir-webdriver and so far am a big fan. However I need to be able to test Safari too, and I don't have access to a mac to be able to use Safari-Watir.
Does anyone know a good alternative to use for testing Safari on a windows machine? (In Ruby of course)
Thanks
(important, see UPDATE below)
the Selenium Webdriver folks are apparently waiting for something from Apple in order to support safari. I would not hold your breath.
Apple does have a version of Safari for the PC, I'm not sure how good the current version is, the initial releases were.. um, well, lets just say they had issues (lots of issues)
Personally (mostly for security reasons) I would not run it nor recommend anyone use it for any purpose other than downloading Chrome or Firefox. But unfortunately a lot of apple users use it because it's what came with their systems, which means to the extent apple users are part of your target market, you have to test on it.
For the moment that means you'll need to use Safariwatir, which has not as far as I can tell had an update for a year or more.
the current state of support on both the Selenium/Webdriver side and the Safariwatir side was discussed recently in this thread in the watir general group on google
UPDATE
Webdriver now has Safari support, which makes direct support of safari (I think on a mac only at this point) possible. See http://watirmelon.com/2012/04/17/using-watir-webdriver-with-safari-at-last/ for more info.. still a bit DYI but I'm sure it will get more accessable soon.
Mike, seems this is available now. Alister Scott wrote up some instructions on his blog Using Watir-Webdriver with Safari At Last
Unfortunately this still a bit DYI because you have to build your own safari extension, which requires getting certificates and such from apple, and I'm not sure if you can create the right environment to build that stuff on anything other than a mac.
I am looking for a way to automate couple of browsers... Firefox and Chrome (for now on just Windows) from an external application/process.
Is there a way to do things along these lines:
Start the browser with a URL
Have the browser load up the page, run script etc.
Inspect the DOM
For reference, IE can be automated using the InternetExplorer.Application object which can be created in a shell script using the following javascript, and then I can walk the DOM API:
var ie = new ActiveXObject('InternetExplorer.Application');
The motivating scenario here is automated testing. I'd like to load up the page containing the test code, and gather results after the test has run.
http://watin.sourceforge.net/
WatiN does exactly that, and I believe they recently added Chrome support
Update 6/22/2011:
Currrently WatiN only works on Firefox 2 and 3, not in Firefiox 4 (and almost certainly not in Firefox 5, which was released today). Also, the time of this answer, Chrome support was supposedly being added, but it looks like that never got fully baked and now is not listed as a suported platform on their home page.
Also worth noting, in my experience WatiN got a lot slower when I upgraded to IE9. I saw this on two different machines, and downgrading to IE8 sped the tests back up on both machines.
I still use WatiN heavily, but now mostly for behavior driven design and functional regression testing, which generally are not browser-specific. Then, manually test in FF and Chrome for all progression testing.
Update 9/22/2015:
Elmue is right, it looks like WatiN is no longer being worked on. We've looking into Selenium for our automated acceptance tests now: http://www.seleniumhq.org
TestR will let you automated IE, FF, and Chrome. I've started working on Edge support but just haven't had the time.
https://github.com/BobbyCannon/TestR
You can use the nuget package.
https://www.nuget.org/packages/TestR/
Here is some examples.
https://docs.epiccoders.com/Page/35/TestR