添加run_cdp()方法

This commit is contained in:
g1879 2022-02-09 11:44:34 +08:00
parent 5a558308bc
commit ca23c6b0d7
3 changed files with 12 additions and 4 deletions

View File

@ -1,11 +1,11 @@
[paths]
chromedriver_path = D:\coding\Chrome92\chromedriver.exe
chromedriver_path =
tmp_path =
[chrome_options]
debugger_address = 127.0.0.1:9222
binary_location = D:\coding\Chrome92\chrome.exe
arguments = ['--no-sandbox', '--disable-gpu', '--ignore-certificate-errors', '--disable-infobars', '--user-data-dir=D:\\coding\\Chrome92\\user_data']
binary_location =
arguments = ['--no-sandbox', '--disable-gpu', '--ignore-certificate-errors', '--disable-infobars']
extensions = []
experimental_options = {'prefs': {'profile.default_content_settings.popups': 0, 'profile.default_content_setting_values': {'notifications': 2}, 'plugins.plugins_list': [{'enabled': False, 'name': 'Chrome PDF Viewer'}]}, 'useAutomationExtension': False, 'excludeSwitches': ['enable-automation']}
timeouts = {'implicit': 10.0, 'pageLoad': 30.0, 'script': 30.0}

View File

@ -329,6 +329,14 @@ class DriverPage(BasePage):
"""
return self.driver.execute_async_script(script, *args)
def run_cdp(self, cmd: str, cmd_args: dict) -> Any:
"""执行Chrome DevTools Protocol语句
:param cmd: 协议项目
:param cmd_args: 参数
:return: 执行的结果
"""
return self.driver.execute_cdp_cmd(cmd, cmd_args)
def create_tab(self, url: str = '') -> None:
"""新建并定位到一个标签页,该标签页在最后面 \n
:param url: 新标签页跳转到的网址

View File

@ -113,7 +113,7 @@ class MixPage(SessionPage, DriverPage, BasePage):
def get(self,
url: str,
go_anyway=True,
go_anyway: bool = False,
show_errmsg: bool = False,
retry: int = None,
interval: float = None,