diff --git a/DrissionPage/_elements/chromium_element.py b/DrissionPage/_elements/chromium_element.py index 74aa7de..3413ab3 100644 --- a/DrissionPage/_elements/chromium_element.py +++ b/DrissionPage/_elements/chromium_element.py @@ -866,7 +866,7 @@ class ShadowRoot(BaseElement): else: nod_ids = self.owner._run_cdp('DOM.querySelectorAll', - nodeId=self._node_id, selector=loc[1])['nodeId'] + nodeId=self._node_id, selector=loc[1])['nodeIds'] r = make_chromium_eles(self.owner, _ids=nod_ids, index=index, is_obj_id=False) return None if r is False else r diff --git a/DrissionPage/_units/clicker.py b/DrissionPage/_units/clicker.py index 82b018d..e490138 100644 --- a/DrissionPage/_units/clicker.py +++ b/DrissionPage/_units/clicker.py @@ -5,6 +5,7 @@ @Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. @License : BSD 3-Clause. """ +from pathlib import Path from time import perf_counter, sleep from .._functions.settings import Settings @@ -117,17 +118,24 @@ class Clicker(object): return self.at(count=times) def to_download(self, save_path=None, rename=None, suffix=None, new_tab=False, by_js=False, timeout=None): - if save_path: - self._ele.tab.set.download_path(save_path) - elif not self._ele.tab._browser._dl_mgr._running: + tmp_save_path = None + if not self._ele.tab._browser._dl_mgr._running: self._ele.tab._browser.set.download_path('.') + if save_path: + if new_tab: + tmp_save_path = str(Path(save_path).absolute()) + else: + self._ele.tab.set.download_path(save_path) obj = self._ele.tab._browser if new_tab else self._ele.owner._tab if rename or suffix: obj.set.download_file_name(rename, suffix) self.left(by_js=by_js) - return obj.wait.download_begin(timeout=timeout) + r = obj.wait.download_begin(timeout=timeout) + if tmp_save_path: + r.path = tmp_save_path + return r def to_upload(self, file_paths, by_js=False): self._ele.owner.set.upload_files(file_paths) diff --git a/DrissionPage/_units/downloader.pyi b/DrissionPage/_units/downloader.pyi index 6030f6b..85965c9 100644 --- a/DrissionPage/_units/downloader.pyi +++ b/DrissionPage/_units/downloader.pyi @@ -165,10 +165,10 @@ class DownloadMission(object): :param mgr: BrowserDownloadManager对象 :param tab_id: 标签页id :param _id: 任务id - :param path: 保存路径 + :param path: 最终保存路径 :param name: 文件名 :param url: url - :param save_path: 下载路径 + :param save_path: 下载临时路径 """ ... diff --git a/DrissionPage/_units/rect.py b/DrissionPage/_units/rect.py index ad64c46..3ae3321 100644 --- a/DrissionPage/_units/rect.py +++ b/DrissionPage/_units/rect.py @@ -62,21 +62,33 @@ class ElementRect(object): vx, vy = self._ele.owner.rect.viewport_location ex, ey = self.viewport_location pr = self._ele.owner._run_js('return window.devicePixelRatio;') - return (vx + ex) * pr, (ey + vy) * pr + if getattr(self._ele.owner, '_is_diff_domain', None): + x, y = self._ele.owner.rect.screen_location + return (vx + ex) * pr + x, (ey + vy) * pr + y + else: + return (vx + ex) * pr, (ey + vy) * pr @property def screen_midpoint(self): vx, vy = self._ele.owner.rect.viewport_location ex, ey = self.viewport_midpoint pr = self._ele.owner._run_js('return window.devicePixelRatio;') - return (vx + ex) * pr, (ey + vy) * pr + if getattr(self._ele.owner, '_is_diff_domain', None): + x, y = self._ele.owner.rect.screen_location + return (vx + ex) * pr + x, (ey + vy) * pr + y + else: + return (vx + ex) * pr, (ey + vy) * pr @property def screen_click_point(self): vx, vy = self._ele.owner.rect.viewport_location ex, ey = self.viewport_click_point pr = self._ele.owner._run_js('return window.devicePixelRatio;') - return (vx + ex) * pr, (ey + vy) * pr + if getattr(self._ele.owner, '_is_diff_domain', None): + x, y = self._ele.owner.rect.screen_location + return (vx + ex) * pr + x, (ey + vy) * pr + y + else: + return (vx + ex) * pr, (ey + vy) * pr @property def scroll_position(self):