# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. """ Helpers to build scenarii """ from condprof.util import logger
async def create_windows(self): # on mobile we don't use tabs for now # see https://bugzil.la/1559120 if self._mobile: return # creating tabs for i in range(self.num_tabs): # see https://github.com/HDE/arsenic/issues/71
await self.session._request(
url="/window/new", method="POST", data={"type": "tab"}
)
async def switch(self): if self._mobile: return try: if self.handles isNone:
self.handles = await self.session.get_window_handles()
self.current = 0 except Exception:
logger.error("Could not get window handles") return
handle = self.handles[self.current] if self.current == len(self.handles) - 1:
self.current = 0 else:
self.current += 1 try:
await self.session.switch_to_window(handle) except Exception:
logger.error("Could not switch to handle %s" % str(handle))
async def close_extra_windows(session):
logger.info("Closing all tabs")
handles = await session.get_window_handles() # we're closing all tabs except the last one for handle in handles[:-1]:
await session.switch_to_window(handle)
await session._request(url="/window", method="DELETE")
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.