Fix Selenium tests
[mediawiki.git] / tests / browser / features / support / pages / login_page.rb
blobc119b38af1a132aa8f6ef7b17fa6334ffcd0d76f
1 require 'page-object'
3 class LoginPage
4   include PageObject
6   page_url 'Special:UserLogin'
8   element(:error_message, css: 'div#userloginForm div.error')
9   div(:feedback, class: 'errorbox')
10   button(:login, id: 'wpLoginAttempt')
11   li(:logout, id: 'pt-logout')
12   text_field(:password, id: 'wpPassword1')
13   element(:password_error, css: 'input#wpPassword1:required:invalid')
14   a(:password_strength, text: 'password strength')
15   a(:phishing, text: 'phishing')
16   text_field(:username, id: 'wpName1')
17   a(:username_displayed, title: /Your user page/)
18   element(:username_error, css: 'input#wpName1:required:invalid')
20   def logged_in_as_element
21     @browser.div(id: 'mw-content-text').p.b
22   end
24   def login_with(username, password, wait_for_logout_element = true)
25     username_element.when_present.send_keys(username)
26     password_element.when_present.send_keys(password)
27     login_element.when_present.click
28     logout_element.when_present(10) if wait_for_logout_element
29   end
30 end