-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rb
86 lines (75 loc) · 2.19 KB
/
test.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Bundler.require(:default)
require_relative 'lib/capybara'
require_relative 'lib/selenium'
require_relative 'lib/watir'
LOGIN_PAGE = 'http://demoapp.strongqa.com/users/sign_in'.freeze
HOME_PAGE = 'http://demoapp.strongqa.com/'.freeze
allowed_drivers = %w[capybara selenium watir]
puts 'Enter drivers names you want to use for the test, separate'\
'their names via coma :'
drivers = gets.chomp.split(',').map(&:strip).uniq & allowed_drivers
tests = lambda do
test_case 'tc_01', 'User can open login page via menu' do
visit_home_page
click_login
assert_login_page_open
end
test_case 'tc_02', 'User can login with correct credentials' do
visit_login_page
fill_form(email: 'lopandya96@gmail.com', password: 'lopandya96')
click_enter
assert_user_logged
assert_home_page_open
end
test_case 'tc_04.1', 'User can not login with blank password' do
visit_login_page
fill_form(email: 'lopandya96@gmail.com', password: '')
click_enter
assert_login_error
end
test_case 'tc_04.2', 'User can not login with blank email' do
visit_login_page
fill_form(email: '', password: 'lopandya96')
click_enter
assert_login_error
end
test_case 'tc_04.3', 'User can not login with blank data' do
visit_login_page
fill_form(email: '', password: '')
click_enter
assert_login_error
end
test_case 'tc_05.1', 'User can not login with incorrect email' do
visit_login_page
fill_form(email: 'FASLE@i.ua', password: 'lopandya96')
click_enter
assert_login_error
end
test_case 'tc_05.2', 'User can not login with incorrect password' do
visit_login_page
fill_form(email: 'lopandya96@i.ua', password: 'FALSE')
click_enter
assert_login_error
end
test_case 'tc_05.3', 'User can not login with incorrect data' do
visit_login_page
fill_form(email: 'FALSE@i.ua', password: 'FALSE')
click_enter
assert_login_error
end
end
if drivers.empty?
puts "Drivers haven't been chosen"
else
puts "Tests will run for: #{drivers.join(', ')}"
end
drivers.each do |driver|
case driver
when 'capybara'
capybara_test_run &tests
when 'selenium'
selenium_test_run &tests
when 'watir'
watir_test_run &tests
end
end