fix: avoid focusing chrome during collection
This commit is contained in:
+8
-7
@@ -753,7 +753,7 @@ def _close_open_product_failure(cdp):
|
||||
pass
|
||||
|
||||
|
||||
def open_product(account, item_id, on_step=None) -> CDP:
|
||||
def open_product(account, item_id, on_step=None, bring_to_front=True) -> CDP:
|
||||
"""Open or reuse a product edit tab, navigate to a clean edit URL, and wait ready."""
|
||||
|
||||
_notify_collect_step(on_step, "open_product")
|
||||
@@ -763,7 +763,7 @@ def open_product(account, item_id, on_step=None) -> CDP:
|
||||
tab = find_product_tab(item_id, host=host)
|
||||
created_by_app = tab is None
|
||||
if tab is None:
|
||||
tab = create_tab_info(url, host=host)
|
||||
tab = create_tab_info(url, host=host, background=not bring_to_front)
|
||||
ws = tab["webSocketDebuggerUrl"]
|
||||
cdp = CDP(ws)
|
||||
cdp.target_id = tab.get("id")
|
||||
@@ -772,10 +772,11 @@ def open_product(account, item_id, on_step=None) -> CDP:
|
||||
try:
|
||||
_ensure_page_domains(cdp)
|
||||
install_toast_observer(cdp)
|
||||
try:
|
||||
cdp.send("Page.bringToFront")
|
||||
except Exception:
|
||||
pass
|
||||
if bring_to_front:
|
||||
try:
|
||||
cdp.send("Page.bringToFront")
|
||||
except Exception:
|
||||
pass
|
||||
cdp.send("Page.navigate", {"url": url})
|
||||
install_toast_observer(cdp)
|
||||
_notify_collect_step(on_step, "wait_ready")
|
||||
@@ -826,7 +827,7 @@ def collect(account, task, on_step=None) -> dict:
|
||||
"""Collect current title and cover snapshot before any edits."""
|
||||
|
||||
item_id = _item_id(task)
|
||||
cdp = open_product(account, item_id, on_step=on_step)
|
||||
cdp = open_product(account, item_id, on_step=on_step, bring_to_front=False)
|
||||
try:
|
||||
_notify_collect_step(on_step, "read_title")
|
||||
old_title = read_title(cdp)
|
||||
|
||||
Reference in New Issue
Block a user