Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Issues getting started with Test::Right #6

Open
mwarkentin opened this issue Jun 27, 2011 · 8 comments
Open

Issues getting started with Test::Right #6

mwarkentin opened this issue Jun 27, 2011 · 8 comments

Comments

@mwarkentin
Copy link

Hello,

I'm trying to test out Test::Right, but I'm having some issues. I've installed the gem, and added a login widget, and a feature (which only attempts to login right now. When I run test_right from my app directory, a Firefox window opens up, and then closes quickly. It doesn't seem to be actually loading my base_url (which is pointing to a staging server).

Shell Output

mwarkentin@mwarkentins-iMac sketchconnect  $ test_right 
Running 1 features
Failed:
  BuildingFeature
    test_loading_portfolio => Test::Right::ElementNotFoundError - Element username not found on LoginWidget using [:id, "j_username"]
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/widget.rb:174:in `get_element'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/widget.rb:113:in `fill_in'
      ./widgets/LoginWidget.rb:7
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/widget.rb:44:in `instance_exec'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/widget.rb:44:in `login'
      ./features/BuildingFeature.rb:4:in `test_loading_portfolio'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/feature.rb:21:in `with'
      ./features/BuildingFeature.rb:3:in `test_loading_portfolio'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:76:in `send'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:76:in `run_test'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:51:in `run_feature'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/batch.rb:101:in `call'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/batch.rb:101:in `send_to_threadpool'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:72:in `call'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:72:in `spawn_thread'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:63:in `initialize'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:63:in `new'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:63:in `spawn_thread'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:34:in `initialize'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:34:in `times'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:34:in `initialize'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:14:in `new'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:14:in `initialize'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/cli.rb:34:in `new'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/cli.rb:34:in `load_and_run_tests'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/cli.rb:14:in `start'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/bin/test_right:10
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/bin/test_right:19:in `load'
      /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/bin/test_right:19

LoginWidget.rb

class LoginWidget < Test::Right::Widget
  field :username, :id => 'j_username'
  field :password, :id => 'j_password'
  button :login, :css => '#loginForm input.button'

  action :login do |username, password|
    fill_in :username, username
    fill_in :password, password
    click :login
  end
end

BuildingFeature.rb

class BuildingFeature < Test::Right::Feature
  def test_loading_portfolio
    with LoginWidget do |w|
      w.login
    end
  end
end
@jmathes
Copy link
Contributor

jmathes commented Jun 27, 2011

It's using sauce selenium from the cloud, which probably can't reach your
private staging server. You need to run Sauce Connect.
http://saucelabs.com/docs/sauce-connect-2

On Mon, Jun 27, 2011 at 2:29 PM, mwarkentin <
[email protected]>wrote:

Hello,

I'm trying to test out Test::Right, but I'm having some issues. I've
installed the gem, and added a login widget, and a feature (which only
attempts to login right now. When I run test_right from my app directory,
a Firefox window opens up, and then closes quickly. It doesn't seem to be
actually loading my base_url (which is pointing to a staging server).

Shell Output

mwarkentin@mwarkentins-iMac sketchconnect  $ test_right
Running 1 features
Failed:
 BuildingFeature
   test_loading_portfolio => Test::Right::ElementNotFoundError - Element
username not found on LoginWidget using [:id, "j_username"]

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/widget.rb:174:in
`get_element'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/widget.rb:113:in
`fill_in'
     ./widgets/LoginWidget.rb:7

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/widget.rb:44:in
`instance_exec'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/widget.rb:44:in
`login'
     ./features/BuildingFeature.rb:4:in `test_loading_portfolio'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/feature.rb:21:in
`with'
     ./features/BuildingFeature.rb:3:in `test_loading_portfolio'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:76:in
`send'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:76:in
`run_test'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:51:in
`run_feature'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/batch.rb:101:in
`call'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/batch.rb:101:in
`send_to_threadpool'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:72:in
`call'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:72:in
`spawn_thread'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:63:in
`initialize'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:63:in
`new'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:63:in
`spawn_thread'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:34:in
`initialize'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:34:in
`times'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/threadz-0.1.3/lib/threadz/thread_pool.rb:34:in
`initialize'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:14:in
`new'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/runner.rb:14:in
`initialize'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/cli.rb:34:in
`new'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/cli.rb:34:in
`load_and_run_tests'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/lib/test/right/cli.rb:14:in
`start'

 /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/gems/test_right-0.2.1/bin/test_right:10
     /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/bin/test_right:19:in
`load'
     /Users/mwarkentin/.rvm/gems/ruby-1.8.7-p330/bin/test_right:19

LoginWidget.rb

class LoginWidget < Test::Right::Widget
 field :username, :id => 'j_username'
 field :password, :id => 'j_password'
 button :login, :css => '#loginForm input.button'

 action :login do |username, password|
   fill_in :username, username
   fill_in :password, password
   click :login
 end
end

BuildingFeature.rb

class BuildingFeature < Test::Right::Feature
 def test_loading_portfolio
   with LoginWidget do |w|
     w.login
   end
 end
end

Reply to this email directly or view it on GitHub:
#6

@mwarkentin
Copy link
Author

It is a publicly accessible server.

@santiycr
Copy link

could you share the website against which this test is being run?

@mwarkentin
Copy link
Author

Sure - http://qa.arcestra.com/

@santiycr
Copy link

Have you set the right url to the test/right/config.yml file?

@mwarkentin
Copy link
Author

Here's my config.yml

# The base URL of your staging server
base_url: http://qa.arcestra.com

# Which browser you want to run your tests in
browser: firefox

@santiycr
Copy link

santiycr commented Jul 7, 2011

I'll have to play with this as soon as I get soem time. Thanks for sending!

@MattiSG
Copy link

MattiSG commented May 14, 2012

This is old, but in case someone has the same kind of problem: you need to ask the driver to load your base URL. It won't, by default, automatically load, and no selection will ever happen.
And, due to how Test::Right:BrowserDriver#get is implemented, you’ll need to specify the :relative option (this is absolutely irrelevant btw, a basic ^https?\:\/\/ regexp could make the heuristic; and even without it, the default should be to consider an URL as relative, since we’re asked to give a base URL…).

Hence, add this line at the beginning of your Feature method:

@driver.get "/", :relative => true

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants