-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·242 lines (199 loc) · 8.2 KB
/
index.html
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<html lang="en">
<head>
<title>Locator Advicer - improve CSS / XPath locators - test CSS / XPath selectors</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
</head>
<body>
<div class="container-contact100">
<div class="wrap-contact100">
<form class="contact100-form validate-form" action="#">
<span class="contact100-form-title">
<h1>Locator Adviser</h1>
</span>
<h3 class="mb-2 text-center" style="font-size: 16px; margin-bottom: 1rem">
Writing automated browser tests with Selenium? <br>Let's see how good your locators are!
</h3>
<div class="wrap-input100 validate-input">
<input class="input100" type="text" name="locator" placeholder="Enter your XPath or CSS locator">
<span class="focus-input100"></span>
</div>
<div class="container-contact100-form-btn">
<div class="wrap-contact100-form-btn">
<div class="contact100-form-bgbtn"></div>
<button class="contact100-form-btn" type="submit">
<span>
Calculate Score
<i class="fa fa-long-arrow-right m-l-7" aria-hidden="true"></i>
</span>
</button>
</div>
</div>
</form>
<div id="notice" class="alert mt-2">
This site helps test automation engineers to <b>test and improve locators</b>.
Finding element on a page is not a big deal. However, finding the most effective and stable element path is hard.
We analyze your locators by various meterics and recommend how to improve them.
<br><br>
Please note: we do not execute your locators. We test only the locator string itself. If it's compact, uses ID or data attributes, this is probably a good locator. If it's a long long XPath - it's 100% a bad one.
<br><br><hr>
<p class="text-center">
🚀 <a href="https://codecept.io">Write <b>tremendous tests with CodeceptJS</b> testing framework</a>! 🚀 .<br> It's simplifies your locators by 70% → simple and readble tests.
</p>
</div>
<div id="results" >
<div id="chart" style="position: absolute; top: -5000px" ></div>
</div>
</div>
</div>
<footer class="page-footer font-small blue pt-4" style="background: #333; color: #fff">
<!-- Footer Links -->
<div class="container text-center">
Locator Adviser is GPL open source. Check our <a href="https://github.com/DavertMik/locator">GitHub</a> to contribute.<br>
Created by <a href="https://twitter.com/davert">Michael Bodnarchuk</a>
</div>
</footer>
<!--===============================================================================================-->
<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/animsition/js/animsition.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<!--===============================================================================================-->
<script src="js/axis.js"></script>
<script>
(function ($) {
"use strict";
var options = {
chart: {
height: 350,
type: 'radialBar',
},
plotOptions: {
radialBar: {
offsetY: -10,
startAngle: 0,
endAngle: 270,
hollow: {
margin: 5,
size: '30%',
background: 'transparent',
image: undefined,
},
dataLabels: {
name: {
show: false,
},
value: {
show: false,
}
}
}
},
theme: {
palette: 'palette3' // upto palette10
},
series: Object.keys(window.axis).map(a => 0),
labels: Object.keys(window.axis).map(a => a.toUpperCase()),
legend: {
show: true,
floating: true,
fontSize: '16px',
position: 'left',
offsetY: 10,
labels: {
useSeriesColors: true,
},
markers: {
size: 0
},
formatter: function(seriesName, opts) {
return seriesName + ": " + opts.w.globals.series[opts.seriesIndex]
},
itemMargin: {
horizontal: 1,
}
},
responsive: [{
breakpoint: 480,
options: {
legend: {
show: false
}
}
}]
}
var chart = new ApexCharts(
document.getElementById("chart"),
options
);
$('#results').show();
Object.keys(window.axis).forEach((a) => $('#results').append(`<div id="axis-${a}"></div>`));
chart.render();
$('.validate-form').on('submit',function(e) {
var locator = $('input[name="locator"]').val();
if (!locator.length) return false;
$('#chart').css({position: 'relative', top: 0 });
try {
if (detectLocator(locator) === 'CSS') {
document.querySelectorAll(locator);
}
if (detectLocator(locator) === 'XPath') {
document.evaluate(locator, document);
}
} catch (err) {
$('#notice').addClass('alert-danger').html('This is invalid CSS or XPath. <br><br>' + err.message).show();
$('#result').hide();
return false;;
}
$('#result').show();
$('#notice').hide();
var axis = window.axis;
let scores = [];
function detectClass(score) {
if (score > 70) return 'alert alert-success';
if (score > 30) return 'alert alert-warning';
return 'alert alert-danger';
}
Object.keys(axis).forEach((key) => {
let a = axis[key];
let score = a.score(locator);
scores.push(score);
$(`#axis-${key}`).html(`<h5><strong>${key.toUpperCase()}</strong>: ${score}%</h5>` + a.analyze(score, locator)).attr('class', detectClass(score));
});
chart.updateSeries(scores);
return false;
});
})(jQuery);
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-30075781-6"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-30075781-6');
</script>
</body>
</html>