mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-05 04:27:09 +00:00
feat(chrome): emit editable flag in hierarchy dump
This commit is contained in:
1 parent
1d01ca77dc
commit
5d21b8c2cf
1 file changed
+6
-1
@@ -218,7 +218,8 @@ func (d *Driver) Hierarchy(_ context.Context) (string, error) {
|
|||||||
if (el.id) attrs['resource-id'] = el.id;
|
if (el.id) attrs['resource-id'] = el.id;
|
||||||
const label = el.getAttribute('aria-label') || el.getAttribute('alt') || el.getAttribute('title') || '';
|
const label = el.getAttribute('aria-label') || el.getAttribute('alt') || el.getAttribute('title') || '';
|
||||||
if (label) attrs['content-desc'] = label;
|
if (label) attrs['content-desc'] = label;
|
||||||
if (el.tagName) attrs['tag'] = el.tagName.toLowerCase();
|
const tag = (el.tagName || '').toLowerCase();
|
||||||
|
if (tag) attrs['tag'] = tag;
|
||||||
if (el.className && typeof el.className === 'string' && el.className.trim()) {
|
if (el.className && typeof el.className === 'string' && el.className.trim()) {
|
||||||
attrs['class'] = el.className.trim();
|
attrs['class'] = el.className.trim();
|
||||||
}
|
}
|
||||||
@@ -226,6 +227,9 @@ func (d *Driver) Hierarchy(_ context.Context) (string, error) {
|
|||||||
const isClickable = !!(el.onclick || el.tagName === 'A' || el.tagName === 'BUTTON' ||
|
const isClickable = !!(el.onclick || el.tagName === 'A' || el.tagName === 'BUTTON' ||
|
||||||
el.tagName === 'INPUT' || el.tagName === 'SELECT' ||
|
el.tagName === 'INPUT' || el.tagName === 'SELECT' ||
|
||||||
el.getAttribute('role') === 'button' || el.getAttribute('onclick'));
|
el.getAttribute('role') === 'button' || el.getAttribute('onclick'));
|
||||||
|
const isEditable = el.isContentEditable || tag === 'textarea' ||
|
||||||
|
(tag === 'input' && !['button','submit','checkbox','radio','range','color','file','image','reset']
|
||||||
|
.includes((el.type || '').toLowerCase()));
|
||||||
const children = [];
|
const children = [];
|
||||||
for (const child of el.children) {
|
for (const child of el.children) {
|
||||||
children.push(buildTree(child, false));
|
children.push(buildTree(child, false));
|
||||||
@@ -238,6 +242,7 @@ func (d *Driver) Hierarchy(_ context.Context) (string, error) {
|
|||||||
focused: document.activeElement === el || null,
|
focused: document.activeElement === el || null,
|
||||||
checked: el.checked || null,
|
checked: el.checked || null,
|
||||||
selected: el.selected || null,
|
selected: el.selected || null,
|
||||||
|
editable: isEditable || null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return buildTree(document.body, true);
|
return buildTree(document.body, true);
|
||||||
|
|||||||
Reference in new issue
Block a user