Fix Selenium tests
authorŽeljko Filipin <zeljko.filipin@gmail.com>
Thu, 19 Jan 2017 16:17:01 +0000 (17:17 +0100)
committerZfilipin <zfilipin@wikimedia.org>
Fri, 20 Jan 2017 12:50:23 +0000 (12:50 +0000)
The tests were broken because the feedback meesage is no longer
displayed as part of the page, but using HTML5 `required` attribute.

Bug: T155640
Change-Id: I9c46db374ec7f50262f84d721a21110aa6e81699

tests/browser/features/login.feature
tests/browser/features/step_definitions/login_steps.rb
tests/browser/features/support/pages/create_account_page.rb
tests/browser/features/support/pages/login_page.rb

index c18f087..8922234 100644 (file)
@@ -11,11 +11,11 @@ Feature: Log in
 
   Scenario: Log in without entering credentials
     When I log in without entering credentials
-    Then error box should be visible
+    Then error message should be displayed for username
 
   Scenario: Log in without entering password
     When I log in without entering password
-    Then error box should be visible
+    Then error message should be displayed for password
 
   Scenario: Log in with incorrect username
     When I log in with incorrect username
index 9b35e99..14a2d76 100644 (file)
@@ -30,6 +30,14 @@ Then(/^error box should not be visible$/) do
   expect(on(LoginPage).error_message_element).not_to exist
 end
 
+Then(/^error message should be displayed for username$/) do
+  expect(on(LoginPage).username_error_element).to exist
+end
+
+Then(/^error message should be displayed for password$/) do
+  expect(on(LoginPage).password_error_element).to exist
+end
+
 Then(/^feedback should be (.+)$/) do |feedback|
   on(LoginPage) do |page|
     page.feedback_element.when_present.click
index 20e2744..de12aee 100644 (file)
@@ -4,5 +4,5 @@ class CreateAccountPage
   page_url '<%=params[:page_title]%>'
 
   button(:create_account, id: 'wpCreateaccount')
-  element(:error_message, css: 'div#userloginForm div.error')
+  element(:error_message, css: 'input#wpName2:required:invalid')
 end
index 4727318..c119b38 100644 (file)
@@ -10,10 +10,12 @@ class LoginPage
   button(:login, id: 'wpLoginAttempt')
   li(:logout, id: 'pt-logout')
   text_field(:password, id: 'wpPassword1')
+  element(:password_error, css: 'input#wpPassword1:required:invalid')
   a(:password_strength, text: 'password strength')
   a(:phishing, text: 'phishing')
   text_field(:username, id: 'wpName1')
   a(:username_displayed, title: /Your user page/)
+  element(:username_error, css: 'input#wpName1:required:invalid')
 
   def logged_in_as_element
     @browser.div(id: 'mw-content-text').p.b