Page Objects should not be subclasses of TestCase
Page Objects should not contain assertions, those belong in _step files
require 'rspec' in env.rb to use RSpec matchers:
Given(/^I am on the login page$/) do
@login_page = Login.new
expect(@login_page.gmail?).to eq true
end
def gmail?
$browser.text.include?("Gmail")
end
On Fri, Jan 12, 2018 at 8:33 AM, 江南 <[email protected]> wrote:
>
> I have the code below to verify a text on the website I want to know how to
> call the method 'test_verifyGmail' in my Cucumber Step Definition file?
>
> #!/usr/bin/ruby
>
>
> require 'watir'
> require 'selenium-webdriver'
> require 'test/unit'
> require 'rubygems'
>
> class Login < Test::Unit::TestCase
>
> def setup
> $browser = Watir::Browser.new :chrome
> $browser.goto "www.google.com"
> end
>
> def test_verifyGmail
> assert($browser.text.include?("Gmail"))
> end
>
> end
>
> Step Definition:
>
> Given(/^I am on the login page$/) do
> @login_page = Login.new
> @login_page.test_verifyGmail
> end
>
>
> Currently when I run it will produce an error and is point at the
> @login_page = Login.new
> ArgumentError: wrong number of arguments (given 0, expected 1..2)
>
>
> Thanks
>
> --
> --
> Before posting, please read
> https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
> In short: search before you ask, be nice.
>
> [email protected]
> http://groups.google.com/group/watir-general
> [email protected]
> ---
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
In short: search before you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.