From b8ccbb1adc1a5685ebe99437644608f41539e798 Mon Sep 17 00:00:00 2001 From: g1879 Date: Mon, 15 Jan 2024 07:27:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_pages/chromium_base.py | 2 +- DrissionPage/_pages/chromium_frame.py | 2 +- DrissionPage/_pages/chromium_page.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DrissionPage/_pages/chromium_base.py b/DrissionPage/_pages/chromium_base.py index 6ef9b5c..9967f0f 100644 --- a/DrissionPage/_pages/chromium_base.py +++ b/DrissionPage/_pages/chromium_base.py @@ -694,7 +694,7 @@ class ChromiumBase(BasePage): if loc_ind_ele == 0: loc_ind_ele = 1 elif loc_ind_ele < 0: - loc_ind_ele = f'last()-{-loc_ind_ele}' + loc_ind_ele = f'last()+{loc_ind_ele}+1' xpath = f'xpath:(//*[name()="frame" or name()="iframe"])[{loc_ind_ele}]' r = self._ele(xpath, timeout=timeout) diff --git a/DrissionPage/_pages/chromium_frame.py b/DrissionPage/_pages/chromium_frame.py index ed03f8f..e224b23 100644 --- a/DrissionPage/_pages/chromium_frame.py +++ b/DrissionPage/_pages/chromium_frame.py @@ -58,7 +58,7 @@ class ChromiumFrame(ChromiumBase): self.doc_ele = ChromiumElement(self, obj_id=obj_id) self._rect = None - end_time = perf_counter() + 5 + end_time = perf_counter() + 2 while perf_counter() < end_time: if self.url not in (None, 'about:blank'): break diff --git a/DrissionPage/_pages/chromium_page.py b/DrissionPage/_pages/chromium_page.py index 71b3f38..f7d4ac5 100644 --- a/DrissionPage/_pages/chromium_page.py +++ b/DrissionPage/_pages/chromium_page.py @@ -148,7 +148,7 @@ class ChromiumPage(ChromiumBase): if isinstance(id_or_num, str): return ChromiumTab(self, id_or_num) elif isinstance(id_or_num, int): - return ChromiumTab(self, self.tabs[id_or_num - 1 if id_or_num < 0 else id_or_num]) + return ChromiumTab(self, self.tabs[id_or_num - 1 if id_or_num > 0 else id_or_num]) elif id_or_num is None: return ChromiumTab(self, self.tab_id) elif isinstance(id_or_num, ChromiumTab):