Ruby & Watir

Hey guys,

It’s the first time to use ruby, I’m .Net developer I’m using ruby and
watir to create automated test for my web site,

I have many sections in my web site, for instance i have a sign-up
wizard, create people, contacts, groups, etc…

I making file for each section, the first file “Create Account.rb” open
the browser and create the account for me, I’m using random number
generator to generate email address and data to be entered.

When that file end, I open the 2nd file to test the 2nd section which is
create person.

My question now, I need to share some data between files, Like the email
address created, I need to share these data between many files.

how can I share these data, like making global variables that shared
between n files, if not possible can I write these data to file and read
it again when needed and how to do this?

Another question, each file need to create a new instance of IE, i need
to use the current window opened, how? how to share the IE object among
files?

Many thanks!

On Thu, Apr 9, 2009 at 9:48 AM, John John gouda <
[email protected]> wrote:

Hey guys,

It’s the first time to use ruby, I’m .Net developer I’m using ruby and
watir to create automated test for my web site,

While I’m not trying to dissuade you from using ruby (heresy!) you could
use
Watin – the .net equivalent of Watir. I believe there is total feature
parity between the two implementations and you may be more comfortable
in
the .net environment.

Ben

Many thanks for your comments,

That will be great! :), However the client I’m working with need to use
Watir for some reasons!

I’ll tell him about Whatin, but meanwhile how can i fix my problem?

Thanks!

On Thu, Apr 9, 2009 at 10:36 AM, John Gouda
[email protected]wrote:

Many thanks for your comments,

That will be great! :), However the client I’m working with need to use
Watir for some reasons!

I’ll tell him about Whatin, but meanwhile how can i fix my problem?

You can learn basic ruby here [1] and take a look at the Watir docs here
[2]

[1] Ruby in Twenty Minutes
[2] http://wiki.openqa.org/display/WTR/Tutorial

You can define a test_helper.rb to have methods to do what you
described, and make it available to all your test files,

You may want to try iTest2 (http://www.itest2.com), it runs Watir (with
extension) tests in RSpec syntax. It comes with a recorder and IDE.

Nigel

John,

I would suggest to follow tutorial (Watir - shown in ben’s post or
iTest2), get it working step by step, like opening a browser, can click
a link, can assert text present, …

If you are using iTest2, you can post your questions on its new forum (I
discovered today)
http://groups.google.com/group/itest2

The developers at iTest2 are very helpful.

Nigel

Nigel Hennan wrote:

You can define a test_helper.rb to have methods to do what you
described, and make it available to all your test files,

How can i do that? Sorry I know nothing about Ruby.

Many thanks

Hey guys,

Thanks for your comments and advice.

I have another question,
I need to share object between files

I have a file Globals.rb contain my global variables.
I need to include this

Open the Browser browser.

Browser = Watir::IE.new;

In another file I’ll write:
require ‘Globals.rb’

And use Browser without reintialize it, is that possible? if not how to
share objects between multiple files?

Thanks

John,

I would suggest to share the functions instead of global variables,
(from my experiences), this leads test scripts more readable and less
dependencies among test cases.

Here is an example test_helper.rb

test_helper.rb

def login_as(username=“testuser”, password=“iTest2”)

end

def try_logout_if_i_can
fail_safe { click_link(‘logout_link’) }
end

Nigel

John Gouda wrote:

Hey guys,

Thanks for your comments and advice.

I have another question,
I need to share object between files

I have a file Globals.rb contain my global variables.
I need to include this

Open the Browser browser.

Browser = Watir::IE.new;

In another file I’ll write:
require ‘Globals.rb’

And use Browser without reintialize it, is that possible? if not how to
share objects between multiple files?

Thanks

Hey,

Another important thing, I need to be able to send mails from ruby, and
login and check if the mail arrive to my inbox or not, is that possible?

So here is my question:
1- How to write text in tinymce editor?
2- Send mails using ruby?
3- Login to my email inbox, and check if mail sent in step 2 arrived?

Really thanks!

Hey guys,

Really thanks for your helpful post!!
I have something comeup, I’m using tinymce editor in composing mails,
and i need to automate the test.

I tried many solutions online but nothing works!
Please help in this :).

Thanks!!

John Gouda wrote:

Hey guys,

Really thanks for your helpful post!!
I have something comeup, I’m using tinymce editor in composing mails,
and i need to automate the test.

I tried many solutions online but nothing works!
Please help in this :).

Thanks!!

I’ve posted how to do this here -
http://www.software-testing.com.au/blog/2007/09/04/watir-difficulties-problems-and-trouble-with-tinymce/

Others have contributed further to the solution, but hopefully you’ve
found it already.

Jared
http://www.software-testing.com.au/blog/