Discussion:
[wtr-general] Browser instance not recognized by other modules
Jeff Fagot
2017-12-06 21:04:51 UTC
Permalink
Hello all,

Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?


I explain: (I am using Cucumber+Watir)
1) Before, when it was fine:
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
things in a more organized / re-usable / maintainable way, so:

2) After, where I am stuck:
I created myself both the "envr,rb" && a new Module "Login_module" files
(I also tried within hook.rb) to create my instance of @browser, then it
seems to only be recognized to my stepdef but not by the other module...??

I am trying to make things right from start, therefore as I read about it,
I am running away from using global variables at all.


*Files overview:*

*** ENVR.RB ***
browser = Watir::Browser.new :firefox

Before do
@b = browser
# @b = Watir::Browser.new :chrome
# @b = Watir::Browser.new :ie
end
***********************************************


*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
directly @b.goto "www.google.com" => it works ###*
end
******************************************************

*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.

Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Oscar Rieken
2017-12-06 22:04:28 UTC
Permalink
why not just create a class and pass the instance of the browser to that
class or something like that its been a while since i have written ruby

###Somewhere
Before do
@browser = Watir::Browser.new :firefox
end

###login.rb
class Login
def initialize(browser)
@browser = browser
end

def open_browser_at(destination="www.google.com")
@browser.goto destination
end
end

### Usage
login = Login.new(@browser)
login.open_browser_at
Post by Jeff Fagot
Hello all,
Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?
I explain: (I am using Cucumber+Watir)
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
I created myself both the "envr,rb" && a new Module "Login_module" files
seems to only be recognized to my stepdef but not by the other module...??
I am trying to make things right from start, therefore as I read about it,
I am running away from using global variables at all.
*Files overview:*
*** ENVR.RB ***
browser = Watir::Browser.new :firefox
Before do
@b = browser
end
***********************************************
*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
end
******************************************************
*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.
Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeff Fagot
2017-12-06 22:27:53 UTC
Permalink
Thanks Oscar for your input.
I was just trying to learn about CLASS today and see how I could implement
Class Objects...I guess you will get me started on it => I will try it out
tonight

But isn't Browser already a default Class Object of Watir?
By following blogs, posts...I do not recall seeing others creating a
specific class for the Browser creation?

Jeff F
Post by Oscar Rieken
why not just create a class and pass the instance of the browser to that
class or something like that its been a while since i have written ruby
###Somewhere
Before do
@browser = Watir::Browser.new :firefox
end
###login.rb
class Login
def initialize(browser)
@browser = browser
end
def open_browser_at(destination="www.google.com")
@browser.goto destination
end
end
### Usage
login.open_browser_at
Post by Jeff Fagot
Hello all,
Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?
I explain: (I am using Cucumber+Watir)
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
I created myself both the "envr,rb" && a new Module "Login_module" files
seems to only be recognized to my stepdef but not by the other module...??
I am trying to make things right from start, therefore as I read about
it, I am running away from using global variables at all.
*Files overview:*
*** ENVR.RB ***
browser = Watir::Browser.new :firefox
Before do
@b = browser
end
***********************************************
*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
end
******************************************************
*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.
Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Titus Fortner
2017-12-07 15:38:58 UTC
Permalink
He isn't referring to a class for browser creation, but creating a page
object class for using the browser, instead of using a module.

Classes and modules are very similar in Ruby, but classes can be
instantiated with instance variables, like a specific instance of a Browser
object.

Also, I typically recommend people do not use Cucumber unless they are
actively doing Behavior Driven Development with a company. using RSpec and
spec_helper are overall much more straightforward.
Post by Jeff Fagot
Thanks Oscar for your input.
I was just trying to learn about CLASS today and see how I could implement
Class Objects...I guess you will get me started on it => I will try it out
tonight
But isn't Browser already a default Class Object of Watir?
By following blogs, posts...I do not recall seeing others creating a
specific class for the Browser creation?
Jeff F
Post by Oscar Rieken
why not just create a class and pass the instance of the browser to that
class or something like that its been a while since i have written ruby
###Somewhere
Before do
@browser = Watir::Browser.new :firefox
end
###login.rb
class Login
def initialize(browser)
@browser = browser
end
def open_browser_at(destination="www.google.com")
@browser.goto destination
end
end
### Usage
login.open_browser_at
Post by Jeff Fagot
Hello all,
Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?
I explain: (I am using Cucumber+Watir)
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
I created myself both the "envr,rb" && a new Module "Login_module"
it seems to only be recognized to my stepdef but not by the other
module...??
I am trying to make things right from start, therefore as I read about
it, I am running away from using global variables at all.
*Files overview:*
*** ENVR.RB ***
browser = Watir::Browser.new :firefox
Before do
@b = browser
end
***********************************************
*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
end
******************************************************
*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.
Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeff Fagot
2017-12-07 20:19:51 UTC
Permalink
Did not get a chance to dive into creating my first Class but I will do
asap.
I quite understand the concept of the Page Object (I will still need
practice to get to the understanding of where exactly should I use it and
how) and that is why I was looking into Classes yesterday.

I guess what I am still confused about is what makes the difference?
To me it looks like by doing so (create class Login) I would only do a
translation of my problem to a sub-level.
Why would I be able to use more easily (from anywhere) an instance of
"Login" than an instance of "Browser"?

I mean, I understand I can use the instance from where it's been
instantiated, but how do I use it from elsewhere ?
(I hope my question makes sense)

Things are starting to make sense as I am typing and trying to even myself
understand my problem.
So now, I would turn my question in a different angle: why is my Browser
instance @b declared in my *** ENVR.RB *** file known to my *** STEPDEF.RB
*** file?
Does it mean that Modules or Class are segregated from the "rest of the
world" (== ENVR, STEPDEFS...) and that the "rest of the world" can be seen
as a unique big Class?

Thanks for helping me thru the process of sorting things out!

Titus thanks for the advice on BDD, when I started I did not know about
RSpec and spec_helper, but I will definitely take your advice !
Post by Titus Fortner
He isn't referring to a class for browser creation, but creating a page
object class for using the browser, instead of using a module.
Classes and modules are very similar in Ruby, but classes can be
instantiated with instance variables, like a specific instance of a Browser
object.
Also, I typically recommend people do not use Cucumber unless they are
actively doing Behavior Driven Development with a company. using RSpec and
spec_helper are overall much more straightforward.
Post by Jeff Fagot
Thanks Oscar for your input.
I was just trying to learn about CLASS today and see how I could
implement Class Objects...I guess you will get me started on it => I will
try it out tonight
But isn't Browser already a default Class Object of Watir?
By following blogs, posts...I do not recall seeing others creating a
specific class for the Browser creation?
Jeff F
Post by Oscar Rieken
why not just create a class and pass the instance of the browser to that
class or something like that its been a while since i have written ruby
###Somewhere
Before do
@browser = Watir::Browser.new :firefox
end
###login.rb
class Login
def initialize(browser)
@browser = browser
end
def open_browser_at(destination="www.google.com")
@browser.goto destination
end
end
### Usage
login.open_browser_at
Post by Jeff Fagot
Hello all,
Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?
I explain: (I am using Cucumber+Watir)
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
I created myself both the "envr,rb" && a new Module "Login_module"
it seems to only be recognized to my stepdef but not by the other
module...??
I am trying to make things right from start, therefore as I read about
it, I am running away from using global variables at all.
*Files overview:*
*** ENVR.RB ***
browser = Watir::Browser.new :firefox
Before do
@b = browser
end
***********************************************
*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
end
******************************************************
*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.
Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
He isn't referring to a class for browser creation, but creating a page
object class for using the browser, instead of using a module.
Classes and modules are very similar in Ruby, but classes can be
instantiated with instance variables, like a specific instance of a Browser
object.
Also, I typically recommend people do not use Cucumber unless they are
actively doing Behavior Driven Development with a company. using RSpec and
spec_helper are overall much more straightforward.
Post by Jeff Fagot
Thanks Oscar for your input.
I was just trying to learn about CLASS today and see how I could
implement Class Objects...I guess you will get me started on it => I will
try it out tonight
But isn't Browser already a default Class Object of Watir?
By following blogs, posts...I do not recall seeing others creating a
specific class for the Browser creation?
Jeff F
Post by Oscar Rieken
why not just create a class and pass the instance of the browser to that
class or something like that its been a while since i have written ruby
###Somewhere
Before do
@browser = Watir::Browser.new :firefox
end
###login.rb
class Login
def initialize(browser)
@browser = browser
end
def open_browser_at(destination="www.google.com")
@browser.goto destination
end
end
### Usage
login.open_browser_at
Post by Jeff Fagot
Hello all,
Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?
I explain: (I am using Cucumber+Watir)
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
I created myself both the "envr,rb" && a new Module "Login_module"
it seems to only be recognized to my stepdef but not by the other
module...??
I am trying to make things right from start, therefore as I read about
it, I am running away from using global variables at all.
*Files overview:*
*** ENVR.RB ***
browser = Watir::Browser.new :firefox
Before do
@b = browser
end
***********************************************
*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
end
******************************************************
*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.
Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
He isn't referring to a class for browser creation, but creating a page
object class for using the browser, instead of using a module.
Classes and modules are very similar in Ruby, but classes can be
instantiated with instance variables, like a specific instance of a Browser
object.
Also, I typically recommend people do not use Cucumber unless they are
actively doing Behavior Driven Development with a company. using RSpec and
spec_helper are overall much more straightforward.
Post by Jeff Fagot
Thanks Oscar for your input.
I was just trying to learn about CLASS today and see how I could
implement Class Objects...I guess you will get me started on it => I will
try it out tonight
But isn't Browser already a default Class Object of Watir?
By following blogs, posts...I do not recall seeing others creating a
specific class for the Browser creation?
Jeff F
Post by Oscar Rieken
why not just create a class and pass the instance of the browser to that
class or something like that its been a while since i have written ruby
###Somewhere
Before do
@browser = Watir::Browser.new :firefox
end
###login.rb
class Login
def initialize(browser)
@browser = browser
end
def open_browser_at(destination="www.google.com")
@browser.goto destination
end
end
### Usage
login.open_browser_at
Post by Jeff Fagot
Hello all,
Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?
I explain: (I am using Cucumber+Watir)
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
I created myself both the "envr,rb" && a new Module "Login_module"
it seems to only be recognized to my stepdef but not by the other
module...??
I am trying to make things right from start, therefore as I read about
it, I am running away from using global variables at all.
*Files overview:*
*** ENVR.RB ***
browser = Watir::Browser.new :firefox
Before do
@b = browser
end
***********************************************
*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
end
******************************************************
*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.
Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
He isn't referring to a class for browser creation, but creating a page
object class for using the browser, instead of using a module.
Classes and modules are very similar in Ruby, but classes can be
instantiated with instance variables, like a specific instance of a Browser
object.
Also, I typically recommend people do not use Cucumber unless they are
actively doing Behavior Driven Development with a company. using RSpec and
spec_helper are overall much more straightforward.
Post by Jeff Fagot
Thanks Oscar for your input.
I was just trying to learn about CLASS today and see how I could
implement Class Objects...I guess you will get me started on it => I will
try it out tonight
But isn't Browser already a default Class Object of Watir?
By following blogs, posts...I do not recall seeing others creating a
specific class for the Browser creation?
Jeff F
Post by Oscar Rieken
why not just create a class and pass the instance of the browser to that
class or something like that its been a while since i have written ruby
###Somewhere
Before do
@browser = Watir::Browser.new :firefox
end
###login.rb
class Login
def initialize(browser)
@browser = browser
end
def open_browser_at(destination="www.google.com")
@browser.goto destination
end
end
### Usage
login.open_browser_at
Post by Jeff Fagot
Hello all,
Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?
I explain: (I am using Cucumber+Watir)
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
I created myself both the "envr,rb" && a new Module "Login_module"
it seems to only be recognized to my stepdef but not by the other
module...??
I am trying to make things right from start, therefore as I read about
it, I am running away from using global variables at all.
*Files overview:*
*** ENVR.RB ***
browser = Watir::Browser.new :firefox
Before do
@b = browser
end
***********************************************
*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
end
******************************************************
*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.
Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
He isn't referring to a class for browser creation, but creating a page
object class for using the browser, instead of using a module.
Classes and modules are very similar in Ruby, but classes can be
instantiated with instance variables, like a specific instance of a Browser
object.
Also, I typically recommend people do not use Cucumber unless they are
actively doing Behavior Driven Development with a company. using RSpec and
spec_helper are overall much more straightforward.
Post by Jeff Fagot
Thanks Oscar for your input.
I was just trying to learn about CLASS today and see how I could
implement Class Objects...I guess you will get me started on it => I will
try it out tonight
But isn't Browser already a default Class Object of Watir?
By following blogs, posts...I do not recall seeing others creating a
specific class for the Browser creation?
Jeff F
Post by Oscar Rieken
why not just create a class and pass the instance of the browser to that
class or something like that its been a while since i have written ruby
###Somewhere
Before do
@browser = Watir::Browser.new :firefox
end
###login.rb
class Login
def initialize(browser)
@browser = browser
end
def open_browser_at(destination="www.google.com")
@browser.goto destination
end
end
### Usage
login.open_browser_at
Post by Jeff Fagot
Hello all,
Main question == How to share the same browser instance across all my
modules?
Sub question 1 == What do you recommend between using hook.rb vs ruby
module to instantiate a new Browser?
Sub question 2 == Where do you store your modules?
I explain: (I am using Cucumber+Watir)
I first had one stepdef file with one module containing all my methods
(including creation of new browser...).
Now with everything I am reading and learning, I am trying to separate
I created myself both the "envr,rb" && a new Module "Login_module"
it seems to only be recognized to my stepdef but not by the other
module...??
I am trying to make things right from start, therefore as I read about
it, I am running away from using global variables at all.
*Files overview:*
*** ENVR.RB ***
browser = Watir::Browser.new :firefox
Before do
@b = browser
end
***********************************************
*** STEPDEF.RB ***
Given (/^I am navigating to the testsite$/) do
Login_module.open_browser_at *#### Here if instead I pass
end
******************************************************
*** LOGIN.RB ***
module Login_module
def self.open_browser_at
@b.goto "www.google.com"
end
end
******************************************************
I would appreciate any help in sorting things out.
Thanks in advance.
Jeff Fagot
--
--
Before posting, please read http://watir.com/support. In short: search
before you ask, be nice.
http://groups.google.com/group/watir-general
---
You received this message because you are subscribed to the Google
Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chuck van der Linden
2017-12-08 17:08:25 UTC
Permalink
Post by Jeff Fagot
Did not get a chance to dive into creating my first Class but I will do
asap.
I quite understand the concept of the Page Object (I will still need
practice to get to the understanding of where exactly should I use it and
how) and that is why I was looking into Classes yesterday.
I guess what I am still confused about is what makes the difference?
To me it looks like by doing so (create class Login) I would only do a
translation of my problem to a sub-level.
Why would I be able to use more easily (from anywhere) an instance of
"Login" than an instance of "Browser"?
I mean, I understand I can use the instance from where it's been
instantiated, but how do I use it from elsewhere ?
(I hope my question makes sense)
Things are starting to make sense as I am typing and trying to even myself
understand my problem.
So now, I would turn my question in a different angle: why is my Browser
*** file?
Does it mean that Modules or Class are segregated from the "rest of the
world" (== ENVR, STEPDEFS...) and that the "rest of the world" can be seen
as a unique big Class?
Thanks for helping me thru the process of sorting things out!
Titus thanks for the advice on BDD, when I started I did not know about
RSpec and spec_helper, but I will definitely take your advice !
Rather than a login class, I would suggest you create what I call a 'Domain
Object' class, in this case a User class. You can then put methods like
Login, Logout, Register, Update_Profile, etc.

What objects to create depends on the nature of the business domain.. In
a retail setting you might have a shopping cart class, (an instance of
which could be included in your user class). When working at one company
that made a site for farmers I had domain objects (defined as classes) for
the user, and their fields, etc.

Have a look at the Test Factory gem it is a simple approach to both page
objects and domain objects and is designed to work with watir.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chuck van der Linden
2017-12-08 17:21:07 UTC
Permalink
Post by Jeff Fagot
So now, I would turn my question in a different angle: why is my Browser
*** file?
Does it mean that Modules or Class are segregated from the "rest of the
world" (== ENVR, STEPDEFS...) and that the "rest of the world" can be seen
as a unique big Class?
Thanks for helping me thru the process of sorting things out!
Titus thanks for the advice on BDD, when I started I did not know about
RSpec and spec_helper, but I will definitely take your advice !
I second what Titus said about BDD.. while you can build a test framework
from cucumber, if you are not also using it for BDD then you are really not
getting the full benefit from cucumber, and in a lot of cases you would be
better off with using rspec as a test framework. You can create re-usable
test helper methods that work much the same way as the reusable steps in
cucumber. Writing proper tests in gherkin is a bit of an art, and if you
are not using the feature files to drive shared understanding of what the
product is supposed to do, then that is mostly just additional overhead,
and the same test steps could be expressed directly in the code for your
tests. .

As to why things defined in env.rb are available in steps, (as well as
things defined in steps usable in other steps), well that's part of the
magic of the cucumber 'world'. It's part of the design in order to make
it easy to pass data between steps, create common objects that are used by
steps etc. You can for example make a 'my_account' variable in a given
step that establishes the account balance, and then later use the same
variable in another step that modifies the balance with a deposit or
withdrawal. For more details I would strongly recommend reading 'The
Cucumber Book", it's the best way I know of to get off to a good start with
Cucumber and avoid a lot of the more common pitfalls I see testers fall
into when they first encounter Cucumber.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeff Fagot
2017-12-08 22:03:55 UTC
Permalink
I appreciate all your comments Chuck. AS you suggested I looked at Test
Factory gem and you were right, it gives good nice view of how objects can
be like.
=> I feel like I get the Object usage knowing I'll need practice to master
it.

I am still undecided on whether or not I will continue with Cucumber or
switch to RSpec.
=> I think I will trust you guys on that one). Even if as a none technical
guy, Cucumber was of a great help to get started (Even though I had to
rewrite several times certain steps to finally get to an acceptable level
of abstraction, that is the learning curve)

Thanks for all your good advice and enlightening me on new tools, it helps!



On Friday, December 8, 2017 at 12:21:08 PM UTC-5, Chuck van der Linden
Post by Chuck van der Linden
Post by Jeff Fagot
So now, I would turn my question in a different angle: why is my Browser
*** file?
Does it mean that Modules or Class are segregated from the "rest of the
world" (== ENVR, STEPDEFS...) and that the "rest of the world" can be seen
as a unique big Class?
Thanks for helping me thru the process of sorting things out!
Titus thanks for the advice on BDD, when I started I did not know about
RSpec and spec_helper, but I will definitely take your advice !
I second what Titus said about BDD.. while you can build a test framework
from cucumber, if you are not also using it for BDD then you are really not
getting the full benefit from cucumber, and in a lot of cases you would be
better off with using rspec as a test framework. You can create re-usable
test helper methods that work much the same way as the reusable steps in
cucumber. Writing proper tests in gherkin is a bit of an art, and if you
are not using the feature files to drive shared understanding of what the
product is supposed to do, then that is mostly just additional overhead,
and the same test steps could be expressed directly in the code for your
tests. .
As to why things defined in env.rb are available in steps, (as well as
things defined in steps usable in other steps), well that's part of the
magic of the cucumber 'world'. It's part of the design in order to make
it easy to pass data between steps, create common objects that are used by
steps etc. You can for example make a 'my_account' variable in a given
step that establishes the account balance, and then later use the same
variable in another step that modifies the balance with a deposit or
withdrawal. For more details I would strongly recommend reading 'The
Cucumber Book", it's the best way I know of to get off to a good start with
Cucumber and avoid a lot of the more common pitfalls I see testers fall
into when they first encounter Cucumber.
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...