Skip to content

Commit 0a8cf38

Browse files
committed
add an indicator for select element
1 parent f37019f commit 0a8cf38

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

packages/selenium-ide/src/content/indicator.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#content {
1515
color: #E80600;
1616
text-align: center;
17-
padding-top: 20px;
17+
padding-top: 5px;
1818
animation: fadeIn 1s infinite alternate;
1919
}
2020
@keyframes fadeIn {

packages/selenium-ide/src/content/record-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function addRecordingIndicator() {
187187
recordingIndicator.style.bottom = '36px'
188188
recordingIndicator.style.right = '36px'
189189
recordingIndicator.style.width = '280px'
190-
recordingIndicator.style.height = '80px'
190+
recordingIndicator.style.height = '50px'
191191
recordingIndicator.style['background-color'] = 'whitesmoke'
192192
recordingIndicator.style['box-shadow'] = '7px 7px 10px 0 rgba(0,0,0,0.3)'
193193
recordingIndicator.style.transition = 'bottom 100ms linear'

packages/selenium-ide/src/content/targetSelector.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,39 @@ class TargetSelector {
4747
this.div = div
4848
this.e = null
4949
this.r = null
50+
this.banner = doc.createElement('div')
51+
this.banner.setAttribute(
52+
'style',
53+
'position: fixed;top: 0;left: 0;bottom: 0;right: 0;background: trasparent;z-index: 10000;'
54+
)
55+
const header = doc.createElement('div')
56+
header.setAttribute(
57+
'style',
58+
"pointer-events: none;display: flex;align-items: center;justify-content: center;flex-direction: row;position: fixed;top: 20%;left: 35%;right: 35%;background: whitesmoke;color: #444;font-size: 28px;line-height: 50px;z-index: 10001;font-family: system, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;box-shadow: 7px 7px 10px 0 rgba(0,0,0,0.3);border: 1px white solid;"
59+
)
60+
const img = doc.createElement('img')
61+
img.src = browser.runtime.getURL('/icons/icon128.png')
62+
img.setAttribute('style', 'width: 28px;margin-right: 15px;')
63+
header.appendChild(img)
64+
const span = doc.createElement('span')
65+
span.innerText = 'Select an element'
66+
header.appendChild(span)
67+
setTimeout(() => {
68+
// this has to happen after a timeout, since adding it sync will add the event
69+
// before the window is focused which will case mousemove to fire before the
70+
// user actually moves the mouse
71+
this.banner.addEventListener(
72+
'mousemove',
73+
() => {
74+
setTimeout(() => {
75+
this.banner.style.visibility = 'hidden'
76+
}, 300)
77+
},
78+
false
79+
)
80+
}, 300)
81+
this.banner.appendChild(header)
82+
doc.body.insertBefore(this.banner, div)
5083
doc.addEventListener('mousemove', this, true)
5184
doc.addEventListener('click', this, true)
5285
}
@@ -59,6 +92,12 @@ class TargetSelector {
5992
}
6093
this.div = null
6194
}
95+
if (this.header) {
96+
if (this.header.parentNode) {
97+
this.header.parentNode.removeChild(this.header)
98+
}
99+
this.header = null
100+
}
62101
if (this.win) {
63102
const doc = this.win.document
64103
doc.removeEventListener('mousemove', this, true)
@@ -101,7 +140,7 @@ class TargetSelector {
101140
}
102141

103142
highlightElement(element) {
104-
if (element && element != this.e) {
143+
if (element && element != this.e && element !== this.banner) {
105144
this.e = element
106145
} else {
107146
return

0 commit comments

Comments
 (0)