op_tab快捷方法

This commit is contained in:
2022-06-06 15:07:07 +08:00
parent d57287507a
commit 218082fed6
3 changed files with 42 additions and 18 deletions

View File

@ -1,12 +1,32 @@
import contextlib
class IDriver():
def new_tab(self) -> str:
...
def get_current_tab(self) -> str:
...
def change_tab(self, tab_handler: str):
...
def open_url(self, url: str, tab_handler: str = ""):
...
@contextlib.contextmanager
def op_tab(self, tab_handler: str):
cur_handle = self.get_current_tab()
if tab_handler == "":
tab_handler = cur_handle
try:
self.change_tab(tab_handler)
yield self
finally:
self.change_tab(cur_handle)
def refresh(self, tab_handler: str = ""):
...
def screenshot(self, tab_handler: str = "") -> str:
...