/
symbiont-with-capybara.rb
executable file
·65 lines (48 loc) · 1.59 KB
/
symbiont-with-capybara.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
#!/usr/bin/env ruby
$: << './lib'
require 'symbiont'
include Symbiont::Factory
Capybara.configure do |config|
config.default_driver = :selenium
config.app_host = 'https://decohere.herokuapp.com/'
end
class Navigation < Symbiont::Region
element :open, '#navlist'
end
class Decohere < Symbiont::Page
url_is '/'
url_matches /:\d{4}/
element :open_form, :xpath, ".//*[@id='openLogin']" # "p[id='openLogin']"
element :username, "input[id='username']"
element :password, "input[id='password']"
element :login, "button[id='login']"
end
#class Home < Symbiont::Page
# region :navigation, Navigation, "#areas"
#end
class Stardate < Symbiont::Page
url_is '/stardate'
elements :facts, 'ul#fact-list li a'
end
puts Symbiont.version
on_view(Decohere)
puts "Page displayed? #{@page.displayed?}"
puts "Page title: #{@page.title}"
puts "Page URL: #{@page.current_url}"
puts "Page secure? #{@page.secure?}"
puts "Open Form Element: #{@page.open_form}"
puts "Open Form Exists? #{@page.has_open_form?}"
puts "Username not present? #{@page.has_no_username?}"
puts "Username exists in DOM? #{@page.has_username?(visible: false)}"
puts "Username Element (in DOM): #{@page.username(visible: false)}"
on(Decohere) do
@page.open_form.click
@page.username.set 'admin@decohere.com'
@page.password.set 'admin'
@page.login.click
end
#puts "Does page have region of navigation?: #{on(Home).has_navigation?}"
#on(Home).navigation.open.click
#puts "Region parent for navigation: #{on(Home).navigation.region_parent}"
on_view(Stardate).facts.each { |fact| puts fact.text }
puts "Facts count: #{@page.facts.size}"