-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeapwork UI CustomizationScript.txt
124 lines (100 loc) · 9.08 KB
/
Leapwork UI CustomizationScript.txt
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Leapwork Integration
description: Run a Leapwork schedule and adds test results for step case type
author: Leapwork
version: 1.0
includes: ^runs/view
excludes:
js:
$(document).ready(
function() {
var button = $('<div class="toolbar content-header-toolbar"><a class="toolbar-button toolbar-button-last toolbar-button-first content-header-button button-start" onclick="ShowLeapworkDialog()" >Select Schedule</a></div>');
$("#content-header .content-header-inner").prepend(button);
$('<div id="leapworkDialog" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable dialog ui-resizable" tabindex="-1" role="dialog" aria- labelledby="ui-dialog-title-runLeapworkSchedule" style="display:none;outline:0;height:500px;width:800px;position:absolute;top:175px;left:190px"><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" style="background:#1fa6f5;color:#fff"><span class="ui-dialog-title" id="ui-dialog-title-runLeapworkSchedule">Run Leapwork Schedule</span><a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button"><span class="ui-icon ui-icon-closethick" onclick="HideLeapworkDialog()">close</span></a></div><div class="dialog ui-dialog-content ui-widget-content" id="runLeapworkScheduleDialog" style="width:auto;height:404px;display:block;min-height:0"><div class="dialog-title"><span class="addResult">Run Leapwork Schedule</span></div><form id="runLeapworkScheduleForm"><div class="dialog-body result-dialog-body" style="height:440px"><div class="result-dialog-busy resultBusy" style="margin:auto;padding-top:151px;display:none"><img src="images/animations/progressLarge.gif" width="32" height="32" alt=""><p></p></div><div class="result-dialog-container resultContainer hidden" style="display:block"><div class="message message-error hidden validationError" id="runLeapworkScheduleErrors"></div><div class="table"><div class="column result-dialog-column-left" style="width:50%"><div class="form-group"><label for="leapworkControllerURL">Leapwork controller URL<span class="form-required">*</span></label><input type="text" id="leapworkControllerURL" class="form-control form-control-full" name="LeapworkControllerURL"><div class="form-description">Set Leapwork controller URL like http://{hostname}:9001</div></div><div class="form-group"><label for="leapworkaccesskey">Leapwork Access Key<span class="form-required">*</span></label><input type="text" id="leapworkAccesskey" class="form-control form-control-full" name="LeapworkAccesskey"><div class="form-description">Set leapwork accesskey</div><button type="button" id="getSchedules" onclick="GetSchedules()" class="button button-left button-dark"><span>Get Schedules</span></button></div><br><div class="form-group"><label for="leapworkScheduleSelect">Leapwork schedule<span class="form-required">*</span></label><select class="form-control form-control-small form-select" name="leapworkSchedule" id="leapworkScheduleSelect"></select></div><div class="form-group"><label for="timeDelay">Time delay in seconds<span class="form-required">*</span></label><input type="text" id="timeDelay" class="form-control form-control-full" name="timeDelay" value="20"><div class="form-description">After schedule is run, wait and ask for schedule state</div></div><div class="form-group"><label for="doneStatusAsSelect">Done status As</label><select class="form-control form-control-small form-select" name="doneStatusAsSelect" id="doneStatusAsSelect"><option value="5" selected="selected">Failed</option><option value="1">Passed</option><option value="4">Retest</option><option value="2">Blocked</option></select><div class="form-description">How done status should be interpreted</div></div></div><div class="column result-dialog-column-right"><div class="form-group"><label for="testRailURL">TestRail Address<span class="form-required">*</span></label><input type="text" id="testRailURL" class="form-control form-control-full" name="testRailURL"><div class="form-description">Enter here TestRail url like http://{hostname}/testrail/</div></div><div class="form-group"><label for="testRailUser">Your TestRail Login<span class="form-required">*</span></label><input type="text" id="testRailUser" class="form-control form-control-full" name="testRailUser"><div class="form-description">Enter here your login</div></div><div class="form-group"><label for="testRailPassword">Your TestRail Password<span class="form-required">*</span></label><input type="password" id="testRailPassword" class="form-control form-control-full" name="testRailPassword"><div class="form-description">Enter here password. This is required for TestRail API</div></div></div></div></div></div></form></div><div class="dialog-buttons-pane-container dialog-buttons-pane-container-dark"><div id="runScheduleButtons" class="button-group dialog-buttons-pane"><button type="button" id="runScheduleButton" onclick="RunSchedule()" style="display:block" class="button button-left button-positive button-ok button-dark"><span class="addResult">Run Schedule</span></button><button type="button" id="runScheduleCancelButton" class="button button-left button-negative button-cancel button-dark" onclick="HideLeapworkDialog()"><span>Cancel</span></button></div></div></div>').appendTo('body');
});
function GetSchedules()
{
if (!document.getElementById('leapworkControllerURL').value) {
alert("URL field is empty! Cannot connect to controller!");
}
else {
GetSchedule();
}
}
function GetSchedule()
{
(jQuery).ajax({
url: document.getElementById('leapworkControllerURL').value + "/api/v4/Schedules",
headers: {'AccessKey': leapworkAccesskey.value},
type: 'GET',
dataType: "json",
success: function (jsonSchedules) {
var scheduleSelect = document.getElementById('leapworkScheduleSelect');
scheduleSelect.innerHTML = "<!-- AJAX GET REQUEST LEAPTEST API Schedules -->";
for (var i = 0; i < jsonSchedules.length; i++) {
if(jsonSchedules[i].IsEnabled == true)
{
var option = document.createElement('option');
option.value = jsonSchedules[i].Id;
option.innerHTML = jsonSchedules[i].Title;
scheduleSelect.appendChild(option);
if (i == 0) scheduleSelect.value = option.value;
}}
jsonSchedules = null;
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(
"Error occurred! Cannot get the list of Schedules\n" +
"Status: " + textStatus + "\n" +
"Error: " + errorThrown + "\n" +
"This may occur because of the next reasons:\n" +
"1.Wrong Controller URL\n" +
"2.Controller is not running or updating now, check it in services\n" +
"3.Your Leapwork Controller port is blocked.\nUse 'netstat -na | find \"9001\"' command, The result should be:\n 0.0.0.0:9001 0.0.0.0:0 LISTENING\n" +
"4.You are using https in controller URL, which is not supported. HTTP only!\n" +
"5.Your browser has such a setting enabled that blocks any http requests from https\n" +
"If nothing helps, please contact support https://leapwork.com/support"
);
}
});
}
function RunSchedule()
{
$.ajax(
{
url: document.getElementById('testRailURL').value + '/' + "leapwork.php?",
data: {
runId: uiscripts.context.run.id,
testRailAddress: document.getElementById('testRailURL').value,
testRailUser: document.getElementById('testRailUser').value,
testRailPassword: document.getElementById('testRailPassword').value,
leapworkControllerURL: document.getElementById('leapworkControllerURL').value,
leapworkHeader: document.getElementById('leapworkAccesskey').value,
scheduleId: document.getElementById('leapworkScheduleSelect').value,
delay: document.getElementById('timeDelay').value,
doneStatusAs: document.getElementById('doneStatusAsSelect').value
},
dataType: "json",
type: "POST",
success: function () {
location.reload();
},
error: function () {
App.Dialogs.error(
'An error occurred while trying to trigger the automated tests.'
);
}
});
App.Dialogs.message(
'The tests are being processed in the background and the results are automatically posted back to TestRail. This page refreshes once the tests are finished.',
'Confirmation'
);
HideLeapworkDialog();
return false;
}
function ShowLeapworkDialog()
{
document.getElementById('leapworkDialog').setAttribute('style','display: block; z - index: 1002; outline: 0px; height: 500px; width: 800px; position: absolute; top: 175px; left: 190px;');
}
function HideLeapworkDialog() {
document.getElementById('leapworkDialog').setAttribute('style', 'display: none; z - index: 1002; outline: 0px; height: 500px; width: 800px; position: absolute; top: 175px; left: 190px;');
}