-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestable-watir-context.rb
executable file
·67 lines (53 loc) · 1.59 KB
/
testable-watir-context.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env ruby
$LOAD_PATH << "./lib"
require "rspec"
# rubocop:disable Style/MixinUsage
include RSpec::Matchers
# rubocop:enable Style/MixinUsage
require "testable"
# rubocop:disable Style/MixinUsage
include Testable::Context
# rubocop:enable Style/MixinUsage
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
on_visit(Home) do
@context.login_form.click
@context.username.set "admin"
@context.password(id: 'password').set "admin"
@context.login.click
expect(@context.message.text).to eq('You are now logged in as admin.')
end
on(Navigation) do |page|
page.page_list.click
# page.page_list.wait_until(&:dom_updated?).click
page.planets.click
expect(page.planet_logo.exists?).to be true
end
Testable.quit_browser