Forum: Ruby Ruby & Watir

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
47abf01477d955de97ae0545f940332d?d=identicon&s=25 John Gouda (john-gouda)
on 2009-04-09 10:48
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!
146e52d49d361f85c0945487452fc6a0?d=identicon&s=25 Ben Lovell (benl)
on 2009-04-09 11:30
(Received via mailing list)
On Thu, Apr 9, 2009 at 9:48 AM, John John gouda <
dominator_legand@hotmail.com> 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
47abf01477d955de97ae0545f940332d?d=identicon&s=25 John Gouda (john-gouda)
on 2009-04-09 11:36
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!
146e52d49d361f85c0945487452fc6a0?d=identicon&s=25 Ben Lovell (benl)
on 2009-04-09 12:35
(Received via mailing list)
On Thu, Apr 9, 2009 at 10:36 AM, John Gouda
<dominator_legand@hotmail.com>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] http://www.ruby-lang.org/en/documentation/quickstart/
[2] http://wiki.openqa.org/display/WTR/Tutorial
285dba4c9db6b7745a4c774839cfac33?d=identicon&s=25 Nigel Hennan (nigelhennan)
on 2009-04-09 14:41
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
47abf01477d955de97ae0545f940332d?d=identicon&s=25 John Gouda (john-gouda)
on 2009-04-09 15:02
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
285dba4c9db6b7745a4c774839cfac33?d=identicon&s=25 Nigel Hennan (nigelhennan)
on 2009-04-10 02:00
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
47abf01477d955de97ae0545f940332d?d=identicon&s=25 John Gouda (john-gouda)
on 2009-04-10 15:15
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
285dba4c9db6b7745a4c774839cfac33?d=identicon&s=25 Nigel Hennan (nigelhennan)
on 2009-04-12 00:00
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
47abf01477d955de97ae0545f940332d?d=identicon&s=25 John Gouda (john-gouda)
on 2009-04-21 17:02
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!!
47abf01477d955de97ae0545f940332d?d=identicon&s=25 John Gouda (john-gouda)
on 2009-04-21 17:33
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!
0fcbdaf3d223c072a4e2141476b94234?d=identicon&s=25 Jared Quinert (xflibble)
on 2009-08-12 08:55
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...

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

Jared
http://www.software-testing.com.au/blog/
This topic is locked and can not be replied to.