fix new tab a issue (#2437)
This commit is contained in:
@@ -1378,6 +1378,15 @@ async function buildElementObject(
|
||||
isSelect2MultiChoice(element),
|
||||
};
|
||||
|
||||
// if element is an "a" tag and has a target="_blank" attribute, remove the target attribute but keep it in the elementObj
|
||||
// We're doing this so that skyvern can do all the navigation in a single page/tab and not open new tab
|
||||
if (elementTagNameLower === "a") {
|
||||
if (element.getAttribute("target") === "_blank") {
|
||||
elementObj.target = "_blank";
|
||||
element.removeAttribute("target");
|
||||
}
|
||||
}
|
||||
|
||||
let isInShadowRoot = element.getRootNode() instanceof ShadowRoot;
|
||||
if (isInShadowRoot) {
|
||||
let shadowHostEle = element.getRootNode().host;
|
||||
@@ -1472,14 +1481,6 @@ async function buildElementTree(
|
||||
"]";
|
||||
}
|
||||
|
||||
// if element is an "a" tag and has a target="_blank" attribute, remove the target attribute
|
||||
// We're doing this so that skyvern can do all the navigation in a single page/tab and not open new tab
|
||||
if (tagName === "a") {
|
||||
if (element.getAttribute("target") === "_blank") {
|
||||
element.removeAttribute("target");
|
||||
}
|
||||
}
|
||||
|
||||
let shadowDOMchildren = [];
|
||||
// sometimes the shadowRoot is not visible, but the elemnets in the shadowRoot are visible
|
||||
if (element.shadowRoot) {
|
||||
|
||||
@@ -869,6 +869,9 @@ def trim_element(element: dict) -> dict:
|
||||
if "afterPseudoText" in queue_ele and not queue_ele.get("afterPseudoText"):
|
||||
del queue_ele["afterPseudoText"]
|
||||
|
||||
if "target" in queue_ele:
|
||||
del queue_ele["target"]
|
||||
|
||||
return element
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user