def _open_new_tab(self):
url = ChromeAPI.OPEN_NEW_TAB_URL.format(self._host, self._port)
try:
response = requests.get(url)
except Exception as e:
print("Error while access {0}, please check chrome browser.".format(url))
print("Details error: {0}".format(e))
return False
response = response.json()
tab_id = response.get("id")
if not tab_id:
return False
ws_url = response.get("webSocketDebuggerUrl")
if not ws_url:
return False
ws_instance = websocket.create_connection(ws_url, timeout=self._timeout)
if not ws_instance:
return False
self._tab = {
"tab_id": tab_id,
"ws_url": ws_url,
"ws_instance": ws_instance
}
return self._tab
评论列表
文章目录