-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
builder.coffee
65 lines (52 loc) · 2.01 KB
/
builder.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# this file will contains the different generic functions which
# will be called by the different tests
# inspired by this methodology
# http://www.lindstromhenrik.com/using-protractor-with-coffeescript/
class builderPage
constructor: (@builder, forcename) ->
@forceName=forcename
goDefault: ->
browser.get('#/builders')
go: () ->
browser.get('#/builders')
localBuilder = element.all(By.linkText(@builder))
localBuilder.click()
goForce: () ->
@go()
element.all(By.buttonText(@forceName)).first().click()
goBuild: (buildRef) ->
@go()
element.all(By.linkText(buildRef.toString())).click()
getLastSuccessBuildNumber: () ->
element.all(By.css('span.badge-status.results_SUCCESS')).then (elements)->
if elements.length == 0
return 0
return elements[0].getText().then (numberstr) ->
return +numberstr
waitNextBuildFinished: (reference) ->
self = this
buildCountIncrement = () ->
self.getLastSuccessBuildNumber().then (currentBuildCount) ->
return currentBuildCount == reference + 1
browser.wait(buildCountIncrement, 10000)
waitGoToBuild: (expected_buildnumber) ->
isInBuild = () ->
browser.getLocationAbsUrl().then (buildUrl) ->
split = buildUrl.split("/")
builds_part = split[split.length-2]
number = +split[split.length-1]
if builds_part != "builds"
return false
if number != expected_buildnumber
return false
return true
browser.wait(isInBuild, 10000)
getStopButton: ->
return element(By.buttonText('Stop'))
getPreviousButton: ->
element(By.partialLinkText('Previous'))
getNextButton: ->
element(By.partialLinkText('Next'))
getRebuildButton: ->
return element(By.buttonText('Rebuild'))
module.exports = builderPage