788bfc45bc4e57ee8671488bf359650a69872138
[lhc/web/wiklou.git] / tests / browser / features / step_definitions / login_steps.rb
1 #
2 # This file is subject to the license terms in the LICENSE file found in the
3 # qa-browsertests top-level directory and at
4 # https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
5 # qa-browsertests, including this file, may be copied, modified, propagated, or
6 # distributed except according to the terms contained in the LICENSE file.
7 #
8 # Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
9 # qa-browsertests top-level directory and at
10 # https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
11 #
12 Given(/^I am at Log in page$/) do
13 visit LoginPage
14 end
15
16 When(/^I log in$/) do
17 on(LoginPage).login_with(user, password, false)
18 end
19
20 When(/^I log in with incorrect password$/) do
21 on(LoginPage).login_with(user, 'incorrect password', false)
22 end
23
24 When(/^I log in with incorrect username$/) do
25 on(LoginPage).login_with('incorrect username', password, false)
26 end
27
28 When(/^I log in without entering credentials$/) do
29 on(LoginPage).login_with('', '', false)
30 end
31
32 When(/^I log in without entering password$/) do
33 on(LoginPage).login_with(user, '', false)
34 end
35
36 Then(/^error box should be visible$/) do
37 expect(on(LoginErrorPage).error_box_element).to be_visible
38 end
39
40 Then(/^error box should not be visible$/) do
41 expect(on(LoginErrorPage).error_box_element).not_to be_visible
42 end
43
44 Then(/^feedback should be (.+)$/) do |feedback|
45 on(LoginPage) do |page|
46 page.feedback_element.when_present.click
47 expect(page.feedback).to match Regexp.escape(feedback)
48 end
49 end
50
51 Then(/^Log in element should be there$/) do
52 expect(on(LoginPage).login_element).to exist
53 end
54
55 Then(/^main page should open$/) do
56 expect(@browser.url).to eq on(MainPage).class.url
57 end
58
59 Then(/^Password element should be there$/) do
60 expect(on(LoginPage).password_element).to exist
61 end
62
63 Then(/^there should be a link to (.+)$/) do |text|
64 expect(on(LoginPage).username_displayed_element.when_present.text).to eq text
65 end
66
67 Then(/^Username element should be there$/) do
68 expect(on(LoginPage).username_element).to exist
69 end