Zfilipin has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/100376


Change subject: WIP move shared login code to the gem
......................................................................

WIP move shared login code to the gem

Change-Id: Ia53e24dea583d8a44f72a1322be434a9026cb9d2
---
M lib/mediawiki/selenium.rb
A lib/mediawiki/selenium/features/step_definitions/login_steps.rb
A lib/mediawiki/selenium/features/support/modules/url_module.rb
A lib/mediawiki/selenium/features/support/pages/login_page.rb
4 files changed, 69 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/selenium 
refs/changes/76/100376/1

diff --git a/lib/mediawiki/selenium.rb b/lib/mediawiki/selenium.rb
index dbdbc20..f3d479f 100644
--- a/lib/mediawiki/selenium.rb
+++ b/lib/mediawiki/selenium.rb
@@ -13,4 +13,6 @@
 require "mediawiki/selenium/hooks"
 require "mediawiki/selenium/sauce"
 require "mediawiki/selenium/version"
-
+require_relative "selenium/features/step_definitions/login_steps"
+require_relative "selenium/features/support/modules/url_module"
+require_relative "selenium/features/support/pages/login_page"
diff --git a/lib/mediawiki/selenium/features/step_definitions/login_steps.rb 
b/lib/mediawiki/selenium/features/step_definitions/login_steps.rb
new file mode 100644
index 0000000..2eaa841
--- /dev/null
+++ b/lib/mediawiki/selenium/features/step_definitions/login_steps.rb
@@ -0,0 +1,13 @@
+=begin
+This file is subject to the license terms in the LICENSE file found in the
+mediawiki-selenium top-level directory and at
+https://github.com/zeljkofilipin/mediawiki-selenium/blob/master/LICENSE. No 
part of
+mediawiki-selenium, including this file, may be copied, modified, propagated, 
or
+distributed except according to the terms contained in the LICENSE file.
+Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
+mediawiki-selenium top-level directory and at
+https://github.com/zeljkofilipin/mediawiki-selenium/blob/master/CREDITS.
+=end
+When(/^Log in as (.+)$/) do |username|
+  on(LoginPage).login_with(username, ENV["MEDIAWIKI_PASSWORD"])
+end
diff --git a/lib/mediawiki/selenium/features/support/modules/url_module.rb 
b/lib/mediawiki/selenium/features/support/modules/url_module.rb
new file mode 100644
index 0000000..fdba4c6
--- /dev/null
+++ b/lib/mediawiki/selenium/features/support/modules/url_module.rb
@@ -0,0 +1,20 @@
+=begin
+This file is subject to the license terms in the LICENSE file found in the
+mediawiki-selenium top-level directory and at
+https://github.com/zeljkofilipin/mediawiki-selenium/blob/master/LICENSE. No 
part of
+mediawiki-selenium, including this file, may be copied, modified, propagated, 
or
+distributed except according to the terms contained in the LICENSE file.
+Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
+mediawiki-selenium top-level directory and at
+https://github.com/zeljkofilipin/mediawiki-selenium/blob/master/CREDITS.
+=end
+module URL
+  def self.url(name)
+    if ENV['MEDIAWIKI_URL']
+      mediawiki_url = ENV['MEDIAWIKI_URL']
+    else
+      mediawiki_url = 'http://en.wikipedia.beta.wmflabs.org/wiki/'
+    end
+    "#{mediawiki_url}#{name}"
+  end
+end
diff --git a/lib/mediawiki/selenium/features/support/pages/login_page.rb 
b/lib/mediawiki/selenium/features/support/pages/login_page.rb
new file mode 100644
index 0000000..cc82dbc
--- /dev/null
+++ b/lib/mediawiki/selenium/features/support/pages/login_page.rb
@@ -0,0 +1,33 @@
+=begin
+This file is subject to the license terms in the LICENSE file found in the
+mediawiki-selenium top-level directory and at
+https://github.com/zeljkofilipin/mediawiki-selenium/blob/master/LICENSE. No 
part of
+mediawiki-selenium, including this file, may be copied, modified, propagated, 
or
+distributed except according to the terms contained in the LICENSE file.
+Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
+mediawiki-selenium top-level directory and at
+https://github.com/zeljkofilipin/mediawiki-selenium/blob/master/CREDITS.
+=end
+class LoginPage
+  include PageObject
+
+  include URL
+  page_url URL.url("Special:UserLogin")
+
+  div(:feedback, class: "errorbox")
+  button(:login, id: "wpLoginAttempt")
+  text_field(:password, id: "wpPassword1")
+  a(:password_strength, text: "password strength")
+  a(:phishing, text: "phishing")
+  text_field(:username, id: "wpName1")
+  a(:username_displayed, title: /Your user page/)
+
+  def logged_in_as_element
+    @browser.div(id: "mw-content-text").p.b
+  end
+  def login_with(username, password)
+    self.username = username
+    self.password = password
+    login
+  end
+end

-- 
To view, visit https://gerrit.wikimedia.org/r/100376
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia53e24dea583d8a44f72a1322be434a9026cb9d2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/selenium
Gerrit-Branch: master
Gerrit-Owner: Zfilipin <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to