mediawiki_selenium 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/docs/template.md ADDED
@@ -0,0 +1,301 @@
1
+ # Template
2
+
3
+ ## Setup
4
+
5
+ - Jenkins > Templates > New Template > (name) > Job Template > OK > Save
6
+ - Display Name: (name)
7
+ - Description: (description)
8
+ - Instantiable?: check
9
+ - Attribute
10
+
11
+ ## Name
12
+
13
+ - ID: name
14
+ - Display Name: Name
15
+ - Type: Text-field
16
+
17
+ ## Browser Label
18
+
19
+ - ID: BROWSER_LABEL
20
+ - Display Name: Browser Label
21
+ - Type: Select a string among many
22
+ - UI Mode: Dropdown list (no inline help, but more compact UI)
23
+ - Options
24
+ - Display Name: (name)
25
+ - Value: (name)
26
+ - chrome
27
+ - firefox
28
+ - internet_explorer_6
29
+ - internet_explorer_7
30
+ - internet_explorer_8
31
+ - internet_explorer_9
32
+ - internet_explorer_10
33
+ - phantomjs
34
+
35
+ ## bundle exec
36
+
37
+ - ID: BUNDLE_EXEC_CUCUMBER
38
+ - Display Name: bundle exec cucumber --backtrace --verbose --profile ci
39
+ - Type: Text-field
40
+
41
+ ## Recipients
42
+
43
+ - ID: RECIPIENTS
44
+ - Display Name: Recipients
45
+ - Type: Text-field
46
+
47
+ ## Repository URL
48
+
49
+ - ID: REPOSITORY_URL
50
+ - Display Name: Repository URL
51
+ - Type: Select a string among many
52
+ - UI Mode: Dropdown list (no inline help, but more compact UI)
53
+ - Options
54
+
55
+ - Display Name: CirrusSearch
56
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/CirrusSearch
57
+
58
+ - Display Name: ContentTranslation
59
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/ContentTranslation
60
+
61
+ - Display Name: Flow
62
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/Flow
63
+
64
+ - Display Name: MobileFrontend
65
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/MobileFrontend
66
+
67
+ - Display Name: MultimediaViewer
68
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
69
+
70
+ - Display Name: Translate
71
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/Translate
72
+
73
+ - Display Name: TwnMainPage
74
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/TwnMainPage
75
+
76
+ - Display Name: UniversalLanguageSelector
77
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/UniversalLanguageSelector
78
+
79
+ - Display Name: VisualEditor
80
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
81
+
82
+ - Display Name: Wikibase
83
+ - Value: https://gerrit.wikimedia.org/r/mediawiki/extensions/Wikibase
84
+
85
+ - Display Name: browsertests
86
+ - Value: https://gerrit.wikimedia.org/r/qa/browsertests
87
+
88
+ ## MediaWiki URL
89
+
90
+ - ID: MEDIAWIKI_URL
91
+ - Display Name: MediaWiki URL
92
+ - Type: Select a string among many
93
+ - UI Mode: Dropdown list (no inline help, but more compact UI)
94
+ - Options
95
+ - Display Name: (name)
96
+ - Value: (name)
97
+
98
+ - name:
99
+ - commons.wikimedia.beta.wmflabs.org
100
+ - dev.translatewiki.net
101
+ - en.m.wikipedia.beta.wmflabs.org
102
+ - en.m.wikipedia.org
103
+ - en.wikipedia.beta.wmflabs.org
104
+ - en.wikipedia.org
105
+ - meta.wikimedia.org
106
+ - sandbox.translatewiki.net
107
+ - test2.m.wikipedia.org
108
+ - test2.wikipedia.org
109
+
110
+ ## Folder
111
+
112
+ - ID: FOLDER
113
+ - Display Name: Folder
114
+ - Type: Select a string among many
115
+ - UI Mode: Dropdown list (no inline help, but more compact UI)
116
+ - Options
117
+ - Display Name: (name)
118
+ - Value: (name)
119
+
120
+ - name:
121
+ - (empty)
122
+ - modules/ve-mw/test/browser/
123
+ - tests/browser/
124
+
125
+ ## MediaWiki user
126
+
127
+ - ID: MEDIAWIKI_USER
128
+ - Display Name: MediaWiki user
129
+ - Type: Text-field
130
+
131
+ ## MediaWiki password variable
132
+
133
+ - ID: MEDIAWIKI_PASSWORD_VARIABLE
134
+ - Display Name: MediaWiki password variable
135
+ - Type: Text-field
136
+
137
+ ## Build schedule
138
+ - ID: BUILD_SCHEDULE
139
+ - Display Name: Build schedule
140
+ - Type: Text-field
141
+
142
+ ## Jelly-based transformation
143
+
144
+ - Property
145
+ - Transformer: Jelly-based transformation
146
+ - Script, from (site)/job/(job)/config.xml
147
+
148
+ --
149
+
150
+ <?xml version='1.0' encoding='UTF-8'?>
151
+ <project>
152
+ <actions/>
153
+ <description></description>
154
+ <logRotator>
155
+ <daysToKeep>60</daysToKeep>
156
+ <numToKeep>-1</numToKeep>
157
+ <artifactDaysToKeep>-1</artifactDaysToKeep>
158
+ <artifactNumToKeep>20</artifactNumToKeep>
159
+ </logRotator>
160
+ <keepDependencies>false</keepDependencies>
161
+ <properties>
162
+ <nectar.plugins.rbac.groups.JobProxyGroupContainer>
163
+ <groups/>
164
+ </nectar.plugins.rbac.groups.JobProxyGroupContainer>
165
+ <com.cloudbees.jenkins.plugins.PublicKey/>
166
+ <com.cloudbees.plugins.deployer.DeployNowJobProperty>
167
+ <oneClickDeploy>false</oneClickDeploy>
168
+ <configuration>
169
+ <user>(jenkins)</user>
170
+ <account>wmf</account>
171
+ <deployables/>
172
+ </configuration>
173
+ </com.cloudbees.plugins.deployer.DeployNowJobProperty>
174
+ </properties>
175
+ <scm class="hudson.plugins.git.GitSCM">
176
+ <configVersion>2</configVersion>
177
+ <userRemoteConfigs>
178
+ <hudson.plugins.git.UserRemoteConfig>
179
+ <name></name>
180
+ <refspec></refspec>
181
+ <url>${REPOSITORY_URL}</url>
182
+ </hudson.plugins.git.UserRemoteConfig>
183
+ </userRemoteConfigs>
184
+ <branches>
185
+ <hudson.plugins.git.BranchSpec>
186
+ <name>master</name>
187
+ </hudson.plugins.git.BranchSpec>
188
+ </branches>
189
+ <disableSubmodules>false</disableSubmodules>
190
+ <recursiveSubmodules>false</recursiveSubmodules>
191
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
192
+ <authorOrCommitter>false</authorOrCommitter>
193
+ <clean>false</clean>
194
+ <wipeOutWorkspace>false</wipeOutWorkspace>
195
+ <pruneBranches>false</pruneBranches>
196
+ <remotePoll>false</remotePoll>
197
+ <ignoreNotifyCommit>false</ignoreNotifyCommit>
198
+ <useShallowClone>false</useShallowClone>
199
+ <buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
200
+ <gitTool>Default</gitTool>
201
+ <submoduleCfg class="list"/>
202
+ <relativeTargetDir></relativeTargetDir>
203
+ <reference></reference>
204
+ <excludedRegions></excludedRegions>
205
+ <excludedUsers></excludedUsers>
206
+ <gitConfigName></gitConfigName>
207
+ <gitConfigEmail></gitConfigEmail>
208
+ <skipTag>false</skipTag>
209
+ <includedRegions></includedRegions>
210
+ <scmName></scmName>
211
+ </scm>
212
+ <canRoam>true</canRoam>
213
+ <disabled>false</disabled>
214
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
215
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
216
+ <triggers class="vector">
217
+ <hudson.triggers.TimerTrigger>
218
+ <spec>${BUILD_SCHEDULE}</spec>
219
+ </hudson.triggers.TimerTrigger>
220
+ </triggers>
221
+ <concurrentBuild>false</concurrentBuild>
222
+ <builders>
223
+ <hudson.tasks.Shell>
224
+ <command>
225
+ export MEDIAWIKI_USER=${MEDIAWIKI_USER}
226
+ export MEDIAWIKI_PASSWORD_VARIABLE=${MEDIAWIKI_PASSWORD_VARIABLE}
227
+
228
+ export BROWSER_LABEL=${BROWSER_LABEL}
229
+ export MEDIAWIKI_URL=http://${MEDIAWIKI_URL}/wiki/
230
+
231
+ curl -s -o use-ruby https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/ruby/use-ruby
232
+ RUBY_VERSION=2.1.0 \
233
+ source ./use-ruby
234
+
235
+ gem install bundler --no-ri --no-rdoc
236
+ if [ -d "${FOLDER}" ]; then cd ${FOLDER}; fi
237
+ bundle install
238
+ bundle exec cucumber --backtrace --verbose --format pretty --format Cucumber::Formatter::Sauce --out reports/junit ${BUNDLE_EXEC_CUCUMBER} || (echo -e "\nJob has failed (exit code: $$?)."; false)
239
+ </command>
240
+ </hudson.tasks.Shell>
241
+ </builders>
242
+ <publishers>
243
+ <hudson.tasks.junit.JUnitResultArchiver>
244
+ <testResults>${FOLDER}reports/junit/*.xml</testResults>
245
+ <keepLongStdio>false</keepLongStdio>
246
+ <testDataPublishers/>
247
+ </hudson.tasks.junit.JUnitResultArchiver>
248
+ <hudson.plugins.emailext.ExtendedEmailPublisher plugin="email-ext@2.36">
249
+ <recipientList>${RECIPIENTS}</recipientList>
250
+ <configuredTriggers>
251
+ <hudson.plugins.emailext.plugins.trigger.FailureTrigger>
252
+ <email>
253
+ <recipientList></recipientList>
254
+ <subject>$PROJECT_DEFAULT_SUBJECT</subject>
255
+ <body>$PROJECT_DEFAULT_CONTENT</body>
256
+ <sendToDevelopers>false</sendToDevelopers>
257
+ <sendToRequester>false</sendToRequester>
258
+ <includeCulprits>false</includeCulprits>
259
+ <sendToRecipientList>true</sendToRecipientList>
260
+ <attachmentsPattern></attachmentsPattern>
261
+ <attachBuildLog>false</attachBuildLog>
262
+ <compressBuildLog>false</compressBuildLog>
263
+ <replyTo>$PROJECT_DEFAULT_REPLYTO</replyTo>
264
+ <contentType>project</contentType>
265
+ </email>
266
+ </hudson.plugins.emailext.plugins.trigger.FailureTrigger>
267
+ </configuredTriggers>
268
+ <contentType>text/html</contentType>
269
+ <defaultSubject>$DEFAULT_SUBJECT</defaultSubject>
270
+ <defaultContent>$${SCRIPT, template=&quot;wikimedia.template&quot;}</defaultContent>
271
+ <attachmentsPattern></attachmentsPattern>
272
+ <presendScript></presendScript>
273
+ <attachBuildLog>false</attachBuildLog>
274
+ <compressBuildLog>false</compressBuildLog>
275
+ <replyTo>$DEFAULT_REPLYTO</replyTo>
276
+ <saveOutput>false</saveOutput>
277
+ </hudson.plugins.emailext.ExtendedEmailPublisher>
278
+ <hudson.plugins.ircbot.IrcPublisher plugin="ircbot@2.21">
279
+ <targets class="java.util.Collections$EmptyList"/>
280
+ <strategy>STATECHANGE_ONLY</strategy>
281
+ <notifyOnBuildStart>false</notifyOnBuildStart>
282
+ <notifySuspects>false</notifySuspects>
283
+ <notifyCulprits>false</notifyCulprits>
284
+ <notifyFixers>false</notifyFixers>
285
+ <notifyUpstreamCommitters>false</notifyUpstreamCommitters>
286
+ <buildToChatNotifier class="hudson.plugins.im.build_notify.SummaryOnlyBuildToChatNotifier" plugin="instant-messaging@1.25"/>
287
+ <matrixMultiplier>ONLY_CONFIGURATIONS</matrixMultiplier>
288
+ <channels/>
289
+ </hudson.plugins.ircbot.IrcPublisher>
290
+ </publishers>
291
+ <buildWrappers/>
292
+ <executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
293
+ <runSequentially>false</runSequentially>
294
+ </executionStrategy>
295
+ </project>
296
+
297
+ --
298
+
299
+ ## Save
300
+
301
+ - Save
data/docs/view.md ADDED
@@ -0,0 +1,11 @@
1
+ # Create new view
2
+
3
+ - https://wmf.ci.cloudbees.com/newView
4
+ - View name: (name)
5
+ - List View
6
+ - OK
7
+
8
+ - https://wmf.ci.cloudbees.com/view/r-uls/configure
9
+ - Use a regular expression to include jobs into the view: .*STRING.*
10
+ - replace STRING with a string
11
+ - OK
@@ -0,0 +1,16 @@
1
+ =begin
2
+ This file is subject to the license terms in the LICENSE file found in the
3
+ mediawiki-selenium top-level directory and at
4
+ https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/LICENSE. No part of
5
+ mediawiki-selenium, including this file, may be copied, modified, propagated, or
6
+ distributed except according to the terms contained in the LICENSE file.
7
+ Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
8
+ mediawiki-selenium top-level directory and at
9
+ https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
+ =end
11
+
12
+ require "mediawiki_selenium/env"
13
+ require "mediawiki_selenium/hooks"
14
+ require "mediawiki_selenium/sauce"
15
+ require "mediawiki_selenium/version"
16
+
@@ -0,0 +1,163 @@
1
+ =begin
2
+ This file is subject to the license terms in the LICENSE file found in the
3
+ mediawiki-selenium top-level directory and at
4
+ https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/LICENSE. No part of
5
+ mediawiki-selenium, including this file, may be copied, modified, propagated, or
6
+ distributed except according to the terms contained in the LICENSE file.
7
+ Copyright 2013 by the Mediawiki developers. See the CREDITS file in the
8
+ mediawiki-selenium top-level directory and at
9
+ https://git.wikimedia.org/blob/mediawiki%2Fselenium/HEAD/CREDITS.
10
+ =end
11
+
12
+ # before all
13
+ require "bundler/setup"
14
+ require "page-object"
15
+ require "page-object/page_factory"
16
+ require "rest_client"
17
+ require "watir-webdriver"
18
+ require "yaml"
19
+
20
+ World(PageObject::PageFactory)
21
+
22
+ def browser(environment, test_name, language)
23
+ if environment == :saucelabs
24
+ sauce_browser(test_name, language)
25
+ else
26
+ local_browser(language)
27
+ end
28
+ end
29
+ def environment
30
+ if ENV["BROWSER_LABEL"] and ENV["BROWSER_LABEL"] != "phantomjs" and
31
+ ENV["SAUCE_ONDEMAND_USERNAME"] and ENV["SAUCE_ONDEMAND_ACCESS_KEY"]
32
+ :saucelabs
33
+ else
34
+ :local
35
+ end
36
+ end
37
+ def local_browser(language)
38
+ if ENV["BROWSER_LABEL"]
39
+ browser_label = ENV["BROWSER_LABEL"].to_sym
40
+ else
41
+ browser_label = :firefox
42
+ end
43
+
44
+ if language == "default"
45
+ browser = Watir::Browser.new browser_label
46
+ else
47
+ if browser_label == :firefox
48
+ profile = Selenium::WebDriver::Firefox::Profile.new
49
+ profile["intl.accept_languages"] = language
50
+ browser = Watir::Browser.new browser_label, profile: profile
51
+ elsif browser_label == :chrome
52
+ profile = Selenium::WebDriver::Chrome::Profile.new
53
+ profile["intl.accept_languages"] = language
54
+ browser = Watir::Browser.new browser_label, profile: profile
55
+ elsif browser_label == :phantomjs
56
+ capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs
57
+ capabilities["phantomjs.page.customHeaders.Accept-Language"] = language
58
+ browser = Watir::Browser.new browser_label, desired_capabilities: capabilities
59
+ else
60
+ raise "Changing default language is currently supported only for Chrome, Firefox and PhantomJS!"
61
+ end
62
+ end
63
+
64
+ browser.window.resize_to 1280, 1024
65
+ browser
66
+ end
67
+ def sauce_api(json)
68
+ RestClient::Request.execute(
69
+ :method => :put,
70
+ :url => "https://saucelabs.com/rest/v1/#{ENV['SAUCE_ONDEMAND_USERNAME']}/jobs/#{$session_id}",
71
+ :user => ENV["SAUCE_ONDEMAND_USERNAME"],
72
+ :password => ENV["SAUCE_ONDEMAND_ACCESS_KEY"],
73
+ :headers => {:content_type => "application/json"},
74
+ :payload => json
75
+ )
76
+ end
77
+ def sauce_browser(test_name, language)
78
+ browsers = {
79
+
80
+ "chrome" =>
81
+ {"name" => "chrome",
82
+ "platform" => "Linux",
83
+ "version" => nil},
84
+
85
+ "firefox" =>
86
+ {"name" => "firefox",
87
+ "platform" => "Linux",
88
+ "version" => 26},
89
+
90
+ "internet_explorer_6" =>
91
+ {"name" => "internet_explorer",
92
+ "platform" => "Windows XP",
93
+ "version"=> 6},
94
+
95
+ "internet_explorer_7" =>
96
+ {"name" => "internet_explorer",
97
+ "platform" => "Windows XP",
98
+ "version"=> 7},
99
+
100
+ "internet_explorer_8" =>
101
+ {"name" => "internet_explorer",
102
+ "platform" => "Windows XP",
103
+ "version"=> 8},
104
+
105
+ "internet_explorer_9" =>
106
+ {"name" => "internet_explorer",
107
+ "platform" => "Windows 7",
108
+ "version"=> 9},
109
+
110
+ "internet_explorer_10" =>
111
+ {"name" => "internet_explorer",
112
+ "platform" => "Windows 8",
113
+ "version"=> 10}}
114
+
115
+ browser_label = browsers[ENV["BROWSER_LABEL"]]
116
+
117
+ if language == "default"
118
+ caps = Selenium::WebDriver::Remote::Capabilities.send(browser_label["name"])
119
+ elsif browser_label["name"] == "firefox"
120
+ profile = Selenium::WebDriver::Firefox::Profile.new
121
+ profile["intl.accept_languages"] = language
122
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
123
+ elsif browser_label["name"] == "chrome"
124
+ profile = Selenium::WebDriver::Chrome::Profile.new
125
+ profile["intl.accept_languages"] = language
126
+ caps = Selenium::WebDriver::Remote::Capabilities.chrome("chrome.profile" => profile.as_json["zip"])
127
+ end
128
+
129
+ caps.platform = browser_label["platform"]
130
+ caps.version = browser_label["version"]
131
+ caps[:name] = "#{test_name} #{ENV['JOB_NAME']}##{ENV['BUILD_NUMBER']}"
132
+
133
+ require "selenium/webdriver/remote/http/persistent" # http_client
134
+ browser = Watir::Browser.new(
135
+ :remote,
136
+ http_client: Selenium::WebDriver::Remote::Http::Persistent.new,
137
+ url: "http://#{ENV['SAUCE_ONDEMAND_USERNAME']}:#{ENV['SAUCE_ONDEMAND_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub",
138
+ desired_capabilities: caps)
139
+ browser.wd.file_detector = lambda do |args|
140
+ # args => ["/path/to/file"]
141
+ str = args.first.to_s
142
+ str if File.exist?(str)
143
+ end
144
+
145
+ browser
146
+ end
147
+ def test_name(scenario)
148
+ if scenario.respond_to? :feature
149
+ "#{scenario.feature.name}: #{scenario.name}"
150
+ elsif scenario.respond_to? :scenario_outline
151
+ "#{scenario.scenario_outline.feature.name}: #{scenario.scenario_outline.name}: #{scenario.name}"
152
+ end
153
+ end
154
+
155
+ if ENV["HEADLESS"] == "true"
156
+ require "headless"
157
+ headless = Headless.new
158
+ headless.start
159
+ end
160
+
161
+ at_exit do
162
+ headless.destroy if headless
163
+ end