mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
4.1.0.0b22修复sr内用css找元素的一个问题;修复异域iframe内元素屏幕坐标不准问题;修复new_tab时下载路径不正确问题
This commit is contained in:
parent
f2218cf0d3
commit
adfe62ed25
@ -866,7 +866,7 @@ class ShadowRoot(BaseElement):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
nod_ids = self.owner._run_cdp('DOM.querySelectorAll',
|
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)
|
r = make_chromium_eles(self.owner, _ids=nod_ids, index=index, is_obj_id=False)
|
||||||
return None if r is False else r
|
return None if r is False else r
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved.
|
@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved.
|
||||||
@License : BSD 3-Clause.
|
@License : BSD 3-Clause.
|
||||||
"""
|
"""
|
||||||
|
from pathlib import Path
|
||||||
from time import perf_counter, sleep
|
from time import perf_counter, sleep
|
||||||
|
|
||||||
from .._functions.settings import Settings
|
from .._functions.settings import Settings
|
||||||
@ -117,17 +118,24 @@ class Clicker(object):
|
|||||||
return self.at(count=times)
|
return self.at(count=times)
|
||||||
|
|
||||||
def to_download(self, save_path=None, rename=None, suffix=None, new_tab=False, by_js=False, timeout=None):
|
def to_download(self, save_path=None, rename=None, suffix=None, new_tab=False, by_js=False, timeout=None):
|
||||||
if save_path:
|
tmp_save_path = None
|
||||||
self._ele.tab.set.download_path(save_path)
|
if not self._ele.tab._browser._dl_mgr._running:
|
||||||
elif not self._ele.tab._browser._dl_mgr._running:
|
|
||||||
self._ele.tab._browser.set.download_path('.')
|
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
|
obj = self._ele.tab._browser if new_tab else self._ele.owner._tab
|
||||||
if rename or suffix:
|
if rename or suffix:
|
||||||
obj.set.download_file_name(rename, suffix)
|
obj.set.download_file_name(rename, suffix)
|
||||||
|
|
||||||
self.left(by_js=by_js)
|
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):
|
def to_upload(self, file_paths, by_js=False):
|
||||||
self._ele.owner.set.upload_files(file_paths)
|
self._ele.owner.set.upload_files(file_paths)
|
||||||
|
@ -165,10 +165,10 @@ class DownloadMission(object):
|
|||||||
:param mgr: BrowserDownloadManager对象
|
:param mgr: BrowserDownloadManager对象
|
||||||
:param tab_id: 标签页id
|
:param tab_id: 标签页id
|
||||||
:param _id: 任务id
|
:param _id: 任务id
|
||||||
:param path: 保存路径
|
:param path: 最终保存路径
|
||||||
:param name: 文件名
|
:param name: 文件名
|
||||||
:param url: url
|
:param url: url
|
||||||
:param save_path: 下载路径
|
:param save_path: 下载临时路径
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -62,21 +62,33 @@ class ElementRect(object):
|
|||||||
vx, vy = self._ele.owner.rect.viewport_location
|
vx, vy = self._ele.owner.rect.viewport_location
|
||||||
ex, ey = self.viewport_location
|
ex, ey = self.viewport_location
|
||||||
pr = self._ele.owner._run_js('return window.devicePixelRatio;')
|
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
|
@property
|
||||||
def screen_midpoint(self):
|
def screen_midpoint(self):
|
||||||
vx, vy = self._ele.owner.rect.viewport_location
|
vx, vy = self._ele.owner.rect.viewport_location
|
||||||
ex, ey = self.viewport_midpoint
|
ex, ey = self.viewport_midpoint
|
||||||
pr = self._ele.owner._run_js('return window.devicePixelRatio;')
|
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
|
@property
|
||||||
def screen_click_point(self):
|
def screen_click_point(self):
|
||||||
vx, vy = self._ele.owner.rect.viewport_location
|
vx, vy = self._ele.owner.rect.viewport_location
|
||||||
ex, ey = self.viewport_click_point
|
ex, ey = self.viewport_click_point
|
||||||
pr = self._ele.owner._run_js('return window.devicePixelRatio;')
|
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
|
@property
|
||||||
def scroll_position(self):
|
def scroll_position(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user