本文整理汇总了Python中marionette_driver.marionette.Marionette.wait_until方法的典型用法代码示例。如果您正苦于以下问题:Python Marionette.wait_until方法的具体用法?Python Marionette.wait_until怎么用?Python Marionette.wait_until使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marionette_driver.marionette.Marionette
的用法示例。
在下文中一共展示了Marionette.wait_until方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_tests
# 需要导入模块: from marionette_driver.marionette import Marionette [as 别名]
# 或者: from marionette_driver.marionette.Marionette import wait_until [as 别名]
def run_tests(firefox_path=None):
basedir = os.path.dirname(__file__)
if sys.platform == 'darwin' and os.path.isdir(firefox_path):
firefox_path = os.path.join(firefox_path,
'Contents', 'MacOS', 'firefox')
driver = Marionette(app='fxdesktop', bin=firefox_path, gecko_log='-',
prefs={'xpinstall.signatures.required': False})
driver.start_session()
try:
build1 = tempfile.NamedTemporaryFile(mode='wb', suffix='.xpi',
delete=False)
build2 = tempfile.NamedTemporaryFile(mode='wb', suffix='.xpi',
delete=False)
try:
jpm_build(basedir, build1.name)
jpm_build(os.path.join(basedir, 'testhelper'), build2.name)
addons = Addons(driver)
addons.install(build1.name, temp=True)
addons.install(build2.name, temp=True)
finally:
os.unlink(build1.name)
os.unlink(build2.name)
driver.expected = expected
driver.keys = Keys
class restore_url:
def __enter__(self):
self.url = driver.get_url()
def __exit__(self, type, value, traceback):
driver.navigate('about:blank')
driver.navigate(self.url)
driver.restore_url = restore_url
def wait_until(method):
Wait(driver, default_timeout).until(lambda d: method())
driver.wait_until = wait_until
def accept_alert():
driver.switch_to_alert().accept()
driver.accept_alert = accept_alert
max_timestamp = {'value': 0}
def get_urls():
result = []
prefix = '[testhelper] Loading: '
new_timestamp = max_timestamp['value']
with driver.using_context(driver.CONTEXT_CHROME):
messages = driver.execute_script(
'return ' +
'Cc["@mozilla.org/consoleservice;1"]' +
'.getService(Ci.nsIConsoleService).getMessageArray()' +
'.map(m => m instanceof Ci.nsIScriptError ? ' +
'[m.timeStamp, m.errorMessage] : [null, null])'
)
for timestamp, message in messages:
if timestamp <= max_timestamp['value']:
continue
if not message.startswith(prefix):
continue
if timestamp > new_timestamp:
new_timestamp = timestamp
result.append(message[len(prefix):])
max_timestamp['value'] = new_timestamp
return result
driver.get_urls = get_urls
def close_windows(keep):
for h in [h for h in driver.chrome_window_handles if h != keep]:
driver.switch_to_window(h)
driver.close_chrome_window()
driver.switch_to_window(keep)
driver.close_windows = close_windows
def close_background_tabs():
current_tab = driver.current_window_handle
for h in [h for h in driver.window_handles if h != current_tab]:
driver.switch_to_window(h)
driver.close()
driver.switch_to_window(current_tab)
driver.close_background_tabs = close_background_tabs
def wait_for_load():
code = 'return document.readyState == "complete";'
driver.wait_until(lambda: driver.execute_script(code))
driver.wait_for_load = wait_for_load
def click(self):
action = Actions(driver)
action.click(self)
action.perform()
HTMLElement.click = click
def middle_click(self):
#.........这里部分代码省略.........