watir-webdriver + RWebSpec - ruby

I'm new in ruby and programming stuff in general. I have one, maybe silly question
is possible to use all the methods from rwebspec with watir-webdriver. And if it is possible, please show me.
Thanks

RWebSpec is a wrapper for all the Watir/Selenium-WebDriver methods. So by using it you are essentially using these underlying tools. There's no reason you need to explicitly need to use Watir-WebDriver.

Related

Upgrade old project to capybara

We are working right now with Ruby, Cucumber and Selenium to perform our integration tests.
Right now we want to improve the quality of our tests and therefore we want to use Capybara.
Now since all our methods need to be rewritten for that, we thought maybe someone has already done that and wrote a wrapper for the selenium webdriver, where Capybara does the job.
For example:
The wrapper should replace the following:
driver.navigate_to "/home"
to something like
visit "/home"
The point is, we donĀ“t want to rewrite all our code, since the functionality out of my view is quite of the same and it should not be that difficult to write a wrapper for driver, which does this automatically. Means: the navigate_to method just calls a visit method, and I am happy.
Do I have to write this on my own, or was this already done?
Thanks alot!
No, there is no existing wrapper for that.
You seem to be missing the fact that Capybara is itself a wrapper around selenium-webdriver, so you are asking for a selenium compatible wrapper around a wrapper around selenium. This coupled with the fact that if all you do is emulate your existing selenium commands with Capybara commands you won't be gaining anything from Capybara, so it's pointless. It sounds like your team would be better off leaving the existing tests as they are, writing all new tests using Capybara, and as existing tests need change/maintenance rewriting them to use Capybara with it's built-in waiting/retrying and friendlier API.

Create WordPress plugins using Ruby

I would like to create a WordPress plugin using Ruby (language). I understand that PHP is the primary server-side language used with WP. I don't know PHP, but know a great deal about Ruby, which is also a server-side language. Can anybody help?
based on previous experience and some reviews of similar questions on SO, there are ways you can call Ruby from within your Wordpress code. The simplest and elegant solution I've seen to this is here : http://code.tutsplus.com/tutorials/build-a-custom-api-to-connect-wordpress-with-ruby-on-rails--cms-21189
There are loads of arguments for going with both solutions at the same time, but probably the easiest read is this https://bernardic.ca/2012/07/08/rails-vs-wordpress/
Enjoy!

Ruby Selenium PageObjects Template

If possible does anyone have a template for setting up selenium tests using a pageObject design pattern.
What i would like to do is create a parent class which opens the browser. I can then pass that browser variable to another subclasses for pages such as LoginPage etc etc.
If anyone could be further information on this that would be great.
My main problem is getting the subclasses to inherit the browser variable.
I would really appreciate some help with this, any answer welcome to help point me in the right direction.
Cheers,
Jon
There is a page objects Gem. it works with both watir-webdriver and selenium-webdriver.
We had a 4 hour class on using that gem, watir-webdriver and cucumber at the recent test automation bazaar conference. you can find it here
Give it a shot, you can use it with either.. (and you may find you prefer the watir api to what selenium uses (I know I do) and if you like selenium, well that's an option too since the gem supports both

Documentation how to

How do I best navigate the core docs? What are others doing when curious about what methods are available on standard classes?
This other SO question is the same, but the accepted answer isn't cutting it for me.
I was trying
f = File.open("some-file.txt","w+")
and then wanted to check what methods I have available on f after this. I tried the following:
ri File.open -> Nothing known about File.open
The core docs tells that File at least doesn't define "open". But the page doesn't mention which modules File mixes in, or inherits from. So I wrote a script:
p File.open("foo.txt", "w+").methods
But this seems quite inefficient (not to mention a raw list of methods isn't the best documentation).
I used pickaxe. It wasn't the be all and end all, but it was pretty decent.
Now I guess it would have to be http://ruby-doc.org
You can just do ri File and it will give you full info on the File class (including the methods it implements and its superclass) or ri open (which will tell you all the places open is implemented if there are several).
You can access the documentation on your system from a browser. This details how to set it up.
Honestly, I usually just go to google and enter "Ruby [method name]" and what I want is almost always in the top three results. If it's not, I fall back to rubybrain.
I use http://apidock.com/ruby for Ruby documentation and the site also features Rails and RSpec documentation.
I found Fxri is useful when you want to browse what method is avaiable for certain object.
It is default in Ruby windows install package.
https://rubygems.org/gems/fxri/

A couple of questions on the architecture of Ruby

I am primarily a fluent .NET developer (as can be seen from the amount of posts and threads I make about .NET), but I thought it would be good to learn RoR.
In doing so, I have a few questions about the architecture of the language (Ruby) and the framework (RoR):
1) In .NET, every object is derived from System but inherits System.Object. So when I type System., I get a list of namespaces and then in those namespaces, classes and more namespaces.
Does Ruby not have this sort of hierarchy?
2) In some cases, I don't get the intellisense. For example, I wrote the class as outlined here (http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer) but in the line recipients user.email, nothing comes up when I type "user.".
Any idea why?
Thank
Dave Thomas (Pragmatic Programmers) has an excellent screencast series on the Ruby object model/metaprogramming. We watched this in a local Ruby user's group. The series isn't free, but it's not expensive either. You might want to check out the free preview to see if you think it is worth your time.
And to give you an answer. Yes, everything in Ruby derives from Object. You can find the docs on this at http://corelib.rubyonrails.org/. Look for the Object class.
I'm not sure why you aren't getting intellisense, partly because you haven't specified your IDE. It's possible that you can't because you've added the method dynamically and no intellisense is available.
If we compare .NET to Rails then yes, there is this kind of hierarchy there. And in general, you can achieve this kind of hierarchy in any Ruby application via using modules.
I guess it's because of Ruby's dynamic nature.
Ruby is a pure OO language meaning that everything from classes to objects derive from the Object class.
Download NetBeans. There is full intellisense support for Ruby and Ruby on Rails.
http://www.netbeans.org/features/ruby/index.html
Intellisense support probably won't get you what you think it will get you. Because Ruby is a dynamic language, Intellisense, or code completion, is difficult. What you will find is that either the drop down is so flooded with possible completions as to be useless. Or in your case nothing at all.
It's not 100% useless, but I have never found it terribly valuable.

Resources