Sha256: 6600fb100363afe5ac11fc2ad88763077e8acc70f51dffe5d9668032e2630d47

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

#!/usr/bin/env ruby
$LOAD_PATH << "./lib"

require "rspec"
include RSpec::Matchers

require "testable"

class Home
  include Testable

  url_is "https://veilus.herokuapp.com/"
  url_matches(/heroku/)
  title_is "Veilus"

  # Elements can be defined with HTML-style names as found in Watir.
  p          :login_form, id:    "open", visible: true
  text_field :username,   id:    "username"
  text_field :password
  button     :login,      id:    "login-button"
  div        :message,    class: "notice"

  # Elements can be defined with a generic name.
  # element :login_form, id:    "open", visible: true
  # element :username,   id:    "username"
  # element :password
  # element :login,      id:    "login-button"
  # element :message,    class: "notice"

  def begin_with
    move_to(0, 0)
    resize_to(screen_width, screen_height)
  end
end

class Navigation
  include Testable

  p     :page_list,     id: "navlist"
  link  :planets,       id: "planets"

  image :planet_logo,   id: "planet-logo"
end

Testable.start_browser :firefox

# Will default to UNKNOWN.
puts Testable.log_level

# Will not actually log.
Testable.logger.info("Testing an info log message.")

# Change the log.
Testable.log_level = :debug

# Will actually log.
Testable.logger.debug("Testing a debug log message.")

# Sets the Watir wire protocol level logging.
Testable.wire_level_logging = :info

page = Home.new

page.visit

page.login_form.click
page.username.set "admin"
page.password(id: 'password').set "admin"
page.login.click
expect(page.message.text).to eq('You are now logged in as admin.')

page = Navigation.new

page.page_list.click
# page.page_list.wait_until(&:dom_updated?).click

page.planets.click
expect(page.planet_logo.exists?).to be true

Testable.quit_browser

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
testable-1.0.0 examples/testable-watir-test.rb
testable-0.10.0 examples/testable-watir-test.rb
testable-0.9.0 examples/testable-watir-test.rb
testable-0.8.0 examples/testable-watir-test.rb
testable-0.7.0 examples/testable-watir-test.rb
testable-0.6.0 examples/testable-watir-test.rb