fix selection issues (#1515)
This commit is contained in:
@@ -770,6 +770,21 @@ const isComboboxDropdown = (element) => {
|
||||
return role && haspopup && controls && readonly;
|
||||
};
|
||||
|
||||
const isDivComboboxDropdown = (element) => {
|
||||
const tagName = element.tagName.toLowerCase();
|
||||
if (tagName !== "div") {
|
||||
return false;
|
||||
}
|
||||
const role = element.getAttribute("role")
|
||||
? element.getAttribute("role").toLowerCase()
|
||||
: "";
|
||||
const haspopup = element.getAttribute("aria-haspopup")
|
||||
? element.getAttribute("aria-haspopup").toLowerCase()
|
||||
: "";
|
||||
const controls = element.hasAttribute("aria-controls");
|
||||
return role === "combobox" && controls && haspopup;
|
||||
};
|
||||
|
||||
const isDropdownButton = (element) => {
|
||||
const tagName = element.tagName.toLowerCase();
|
||||
const type = element.getAttribute("type")
|
||||
@@ -1182,6 +1197,7 @@ function buildElementObject(frame, element, interactable, purgeable = false) {
|
||||
elementTagNameLower === "svg" || element.closest("svg") !== null,
|
||||
isSelectable:
|
||||
elementTagNameLower === "select" ||
|
||||
isDivComboboxDropdown(element) ||
|
||||
isDropdownButton(element) ||
|
||||
isAngularDropdown(element) ||
|
||||
isSelect2Dropdown(element) ||
|
||||
@@ -2083,9 +2099,12 @@ if (window.globalObserverForDOMIncrement === undefined) {
|
||||
}
|
||||
if (mutation.attributeName === "class") {
|
||||
const node = mutation.target;
|
||||
if (node.nodeType === Node.TEXT_NODE) continue;
|
||||
if (node.tagName.toLowerCase() === "body") continue;
|
||||
if (!mutation.oldValue) continue;
|
||||
if (
|
||||
!mutation.oldValue ||
|
||||
!isClassNameIncludesHidden(mutation.oldValue)
|
||||
!isClassNameIncludesHidden(mutation.oldValue) &&
|
||||
!node.hasAttribute("data-menu-uid") // google framework use this to trace dropdown menu
|
||||
)
|
||||
continue;
|
||||
const newStyle = getElementComputedStyle(node);
|
||||
|
||||
@@ -541,6 +541,12 @@ class IncrementalScrapePage:
|
||||
self.element_tree_trimmed: list[dict] = list()
|
||||
self.skyvern_frame = skyvern_frame
|
||||
|
||||
def check_id_in_page(self, element_id: str) -> bool:
|
||||
css_selector = self.id_to_css_dict.get(element_id, "")
|
||||
if css_selector:
|
||||
return True
|
||||
return False
|
||||
|
||||
async def get_incremental_element_tree(
|
||||
self,
|
||||
cleanup_element_tree: CleanupElementTreeFunc,
|
||||
|
||||
Reference in New Issue
Block a user