本文整理汇总了Python中marionette_driver.marionette.Marionette类的典型用法代码示例。如果您正苦于以下问题:Python Marionette类的具体用法?Python Marionette怎么用?Python Marionette使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Marionette类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup
def setup(self):
I18nSetup.locale_path = os.path.join(site.getsitepackages()[0], 'OWDTestToolkit/locale')
if not I18nSetup.configured:
marionette = Marionette()
marionette.start_session()
# Configure the translation to be used based on the previously retrieved language. Should
# the translation is not found, the fallback will prevent a failure
lang = marionette.execute_script("""return window.navigator.language;""")
translation = gettext.translation('default', I18nSetup.locale_path, languages=[lang], fallback=True)
I18nSetup._ = translation.ugettext
I18nSetup.configured = True
return I18nSetup._
开发者ID:owdqa,项目名称:OWD_TEST_TOOLKIT,代码行数:12,代码来源:i18nsetup.py
示例2: get_new_emulator
def get_new_emulator(self):
self.extra_emulator_index += 1
if len(self.marionette.extra_emulators) == self.extra_emulator_index:
qemu = Marionette(emulator=self.marionette.emulator.arch,
emulatorBinary=self.marionette.emulator.binary,
homedir=self.marionette.homedir,
baseurl=self.marionette.baseurl,
noWindow=self.marionette.noWindow,
gecko_path=self.marionette.gecko_path)
qemu.start_session()
self.marionette.extra_emulators.append(qemu)
else:
qemu = self.marionette.extra_emulators[self.extra_emulator_index]
return qemu
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:14,代码来源:marionette_test.py
示例3: test_disable_enable_new_connections
def test_disable_enable_new_connections(self):
# Do not re-create socket if it already exists
self.marionette._send_message("acceptConnections", {"value": True})
try:
# Disabling new connections does not affect existing ones...
self.marionette._send_message("acceptConnections", {"value": False})
self.assertEqual(1, self.marionette.execute_script("return 1"))
# but only new connection attempts
marionette = Marionette(host=self.marionette.host, port=self.marionette.port)
self.assertRaises(socket.timeout, marionette.raise_for_port, timeout=1.0)
self.marionette._send_message("acceptConnections", {"value": True})
marionette.raise_for_port(timeout=10.0)
finally:
self.marionette._send_message("acceptConnections", {"value": True})
开发者ID:luke-chang,项目名称:gecko-1,代码行数:18,代码来源:test_marionette.py
示例4: marionette
def marionette(request, timeout):
"""Return a marionette instance"""
m = Marionette(bin=request.config.option.bin)
m.start_session()
m.set_prefs({'signon.rememberSignons': False})
request.addfinalizer(m.delete_session)
m.set_search_timeout(timeout)
return m
开发者ID:mozilla-services,项目名称:marionette-wrapper,代码行数:8,代码来源:conftest.py
示例5: setUp
def setUp(self):
# Convert the marionette weakref to an object, just for the
# duration of the test; this is deleted in tearDown() to prevent
# a persistent circular reference which in turn would prevent
# proper garbage collection.
self.start_time = time.time()
self.pingServer = PingServer()
self.pingServer.start()
self.marionette = Marionette(bin=self.binary, profile=self.profile)
if self.marionette.session is None:
self.marionette.start_session()
self.marionette.reset_timeouts()
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:12,代码来源:session_test.py
示例6: run_marionette_script
def run_marionette_script(self):
self.marionette = Marionette(**self.marionette_args)
assert(self.marionette.wait_for_port())
self.marionette.start_session()
if self.build_type == "mulet":
self._wait_for_homescreen(timeout=300)
self._unlockScreen()
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
if os.path.isfile(self.test_script):
f = open(self.test_script, 'r')
self.test_script = f.read()
f.close()
self.marionette.execute_script(self.test_script)
开发者ID:DINKIN,项目名称:Waterfox,代码行数:14,代码来源:b2g_desktop.py
示例7: setUp
def setUp(self):
# Convert the marionette weakref to an object, just for the
# duration of the test; this is deleted in tearDown() to prevent
# a persistent circular reference which in turn would prevent
# proper garbage collection.
self.start_time = time.time()
self.marionette = Marionette(bin=self.binary, profile=self.profile)
if self.marionette.session is None:
self.marionette.start_session()
if self.marionette.timeout is not None:
self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, self.marionette.timeout)
self.marionette.timeouts(self.marionette.TIMEOUT_SCRIPT, self.marionette.timeout)
self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, self.marionette.timeout)
else:
self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, 30000)
开发者ID:brendandahl,项目名称:positron,代码行数:15,代码来源:session_test.py
示例8: run
def run(self, args=sys.argv[1:]):
args = self.parser.parse_args()
host, port = args.address.split(':')
self.marionette = Marionette(host=host, port=int(port))
self.marionette.start_session()
self.apps = gaiatest.GaiaApps(self.marionette)
self.data_layer = gaiatest.GaiaData(self.marionette)
self.device = gaiatest.GaiaDevice(self.marionette)
ret = args.func(args)
if ret is None:
ret = 0
self.marionette.delete_session()
sys.exit(ret)
开发者ID:AaskaShah,项目名称:gaia,代码行数:18,代码来源:gcli.py
示例9: B2GDesktopReftest
class B2GDesktopReftest(RefTest):
build_type = "desktop"
marionette = None
def __init__(self, marionette_args):
RefTest.__init__(self)
self.last_test = os.path.basename(__file__)
self.marionette_args = marionette_args
self.profile = None
self.runner = None
self.test_script = os.path.join(here, 'b2g_start_script.js')
self.timeout = None
def run_marionette_script(self):
self.marionette = Marionette(**self.marionette_args)
assert(self.marionette.wait_for_port())
self.marionette.start_session()
if self.build_type == "mulet":
self._wait_for_homescreen(timeout=300)
self._unlockScreen()
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
if os.path.isfile(self.test_script):
f = open(self.test_script, 'r')
self.test_script = f.read()
f.close()
self.marionette.execute_script(self.test_script)
def run_tests(self, tests, options):
manifests = self.resolver.resolveManifests(options, tests)
self.profile = self.create_profile(options, manifests,
profile_to_clone=options.profile)
env = self.buildBrowserEnv(options, self.profile.profile)
kp_kwargs = { 'processOutputLine': [self._on_output],
'onTimeout': [self._on_timeout],
'kill_on_timeout': False }
if not options.debugger:
if not options.timeout:
if mozinfo.info['debug']:
options.timeout = 420
else:
options.timeout = 300
self.timeout = options.timeout + 30.0
log.info("%s | Running tests: start.", os.path.basename(__file__))
cmd, args = self.build_command_line(options.app,
ignore_window_size=options.ignoreWindowSize,
browser_arg=options.browser_arg)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd,
cmdargs=args,
env=env,
process_class=ProcessHandler,
process_args=kp_kwargs,
symbols_path=options.symbolsPath)
status = 0
try:
self.runner.start(outputTimeout=self.timeout)
log.info("%s | Application pid: %d",
os.path.basename(__file__),
self.runner.process_handler.pid)
# kick starts the reftest harness
self.run_marionette_script()
status = self.runner.wait()
finally:
self.runner.check_for_crashes(test_name=self.last_test)
self.runner.cleanup()
if status > 0:
log.testFail("%s | application terminated with exit code %s",
self.last_test, status)
elif status < 0:
log.info("%s | application killed with signal %s",
self.last_test, -status)
log.info("%s | Running tests: end.", os.path.basename(__file__))
return status
def create_profile(self, options, manifests, profile_to_clone=None):
profile = RefTest.createReftestProfile(self, options, manifests,
profile_to_clone=profile_to_clone)
prefs = {}
# Turn off the locale picker screen
prefs["browser.firstrun.show.localepicker"] = False
if not self.build_type == "mulet":
# FIXME: With Mulet we can't set this values since Gaia won't launch
prefs["b2g.system_startup_url"] = \
"app://test-container.gaiamobile.org/index.html"
prefs["b2g.system_manifest_url"] = \
"app://test-container.gaiamobile.org/manifest.webapp"
# Make sure we disable system updates
prefs["app.update.enabled"] = False
prefs["app.update.url"] = ""
prefs["app.update.url.override"] = ""
# Disable webapp updates
#.........这里部分代码省略.........
开发者ID:DINKIN,项目名称:Waterfox,代码行数:101,代码来源:b2g_desktop.py
示例10: MuletReftest
class MuletReftest(RefTest):
build_type = "mulet"
marionette = None
def __init__(self, marionette_args):
RefTest.__init__(self)
self.last_test = os.path.basename(__file__)
self.marionette_args = marionette_args
self.profile = None
self.runner = None
self.test_script = os.path.join(here, 'b2g_start_script.js')
self.timeout = None
def run_marionette_script(self):
self.marionette = Marionette(**self.marionette_args)
assert(self.marionette.wait_for_port())
self.marionette.start_session()
if self.build_type == "mulet":
self._wait_for_homescreen(timeout=300)
self._unlockScreen()
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
if os.path.isfile(self.test_script):
f = open(self.test_script, 'r')
self.test_script = f.read()
f.close()
self.marionette.execute_script(self.test_script)
def run_tests(self, tests, options):
manifests = self.resolver.resolveManifests(options, tests)
self.profile = self.create_profile(options, manifests,
profile_to_clone=options.profile)
env = self.buildBrowserEnv(options, self.profile.profile)
self._populate_logger(options)
outputHandler = OutputHandler(self.log, options.utilityPath, symbolsPath=options.symbolsPath)
kp_kwargs = { 'processOutputLine': [outputHandler],
'onTimeout': [self._on_timeout],
'kill_on_timeout': False }
if not options.debugger:
if not options.timeout:
if mozinfo.info['debug']:
options.timeout = 420
else:
options.timeout = 300
self.timeout = options.timeout + 30.0
self.log.info("%s | Running tests: start." % os.path.basename(__file__))
cmd, args = self.build_command_line(options.app,
ignore_window_size=options.ignoreWindowSize,
browser_arg=options.browser_arg)
self.runner = FirefoxRunner(profile=self.profile,
binary=cmd,
cmdargs=args,
env=env,
process_class=ProcessHandler,
process_args=kp_kwargs,
symbols_path=options.symbolsPath)
status = 0
try:
self.runner.start(outputTimeout=self.timeout)
self.log.info("%s | Application pid: %d" % (
os.path.basename(__file__),
self.runner.process_handler.pid))
# kick starts the reftest harness
self.run_marionette_script()
status = self.runner.wait()
finally:
self.runner.check_for_crashes(test_name=self.last_test)
self.runner.cleanup()
if status > 0:
self.log.testFail("%s | application terminated with exit code %s" % (
self.last_test, status))
elif status < 0:
self.log.info("%s | application killed with signal %s" % (
self.last_test, -status))
self.log.info("%s | Running tests: end." % os.path.basename(__file__))
return status
def create_profile(self, options, manifests, profile_to_clone=None):
profile = RefTest.createReftestProfile(self, options, manifests,
profile_to_clone=profile_to_clone)
prefs = {}
# Turn off the locale picker screen
prefs["browser.firstrun.show.localepicker"] = False
if not self.build_type == "mulet":
# FIXME: With Mulet we can't set this values since Gaia won't launch
prefs["b2g.system_startup_url"] = \
"app://test-container.gaiamobile.org/index.html"
prefs["b2g.system_manifest_url"] = \
"app://test-container.gaiamobile.org/manifest.webapp"
# Make sure we disable system updates
#.........这里部分代码省略.........
开发者ID:bitwiseworks,项目名称:mozilla-os2,代码行数:101,代码来源:runreftestmulet.py
示例11: GCli
#.........这里部分代码省略.........
'setsetting': {
'function': self.set_setting,
'args': [
{'name': 'name',
'help': 'Name of setting to change'},
{'name': 'value',
'help': 'New value for setting'}],
'help': 'Change the value of a setting'},
'sleep': {
'function': self.sleep,
'help': 'Enter sleep mode'},
'unlock': {
'function': self.unlock,
'help': 'Unlock screen'},
'volume': {
'function': self.volume,
'args': [
{'name': 'direction',
'choices': ['down', 'up'],
'help': 'Direction to change the volume'}],
'help': 'Change the volume'},
'wake': {
'function': self.wake,
'help': 'Wake from sleep mode'}}
self.parser = argparse.ArgumentParser()
self.add_options(self.parser)
self.add_commands(self.parser)
def run(self, args=sys.argv[1:]):
args = self.parser.parse_args()
host, port = args.address.split(':')
self.marionette = Marionette(host=host, port=int(port))
self.marionette.start_session()
self.apps = gaiatest.GaiaApps(self.marionette)
self.data_layer = gaiatest.GaiaData(self.marionette)
self.device = gaiatest.GaiaDevice(self.marionette)
ret = args.func(args)
if ret is None:
ret = 0
self.marionette.delete_session()
sys.exit(ret)
def add_options(self, parser):
parser.add_argument(
'--address',
default='localhost:2828',
help='Address (host:port) of running Gecko instance to connect to '
'(default: %(default)s)')
def add_commands(self, parser):
subparsers = parser.add_subparsers(
title='Commands', metavar='<command>')
for (name, props) in sorted(self.commands.iteritems()):
subparser = subparsers.add_parser(name, help=props['help'])
if props.get('args'):
for arg in props['args']:
kwargs = {k: v for k, v in arg.items() if k is not 'name'}
subparser.add_argument(arg['name'], **kwargs)
subparser.set_defaults(func=props['function'])
开发者ID:AaskaShah,项目名称:gaia,代码行数:66,代码来源:gcli.py
示例12: CommonTestCase
#.........这里部分代码省略.........
else:
self.tearDown()
except KeyboardInterrupt:
raise
except _ExpectedFailure as e:
expected_failure(result, e.exc_info)
except:
self._enter_pm()
result.addError(self, sys.exc_info())
success = False
# Here we could handle doCleanups() instead of calling cleanTest directly
self.cleanTest()
if success:
result.addSuccess(self)
finally:
result.stopTest(self)
if orig_result is None:
stopTestRun = getattr(result, "stopTestRun", None)
if stopTestRun is not None:
stopTestRun()
@classmethod
def match(cls, filename):
"""
Determines if the specified filename should be handled by this
test class; this is done by looking for a match for the filename
using cls.match_re.
"""
if not cls.match_re:
return False
m = cls.match_re.match(filename)
return m is not None
@classmethod
def add_tests_to_suite(cls, mod_name, filepath, suite, testloader, testvars):
"""
Adds all the tests in the specified file to the specified suite.
"""
raise NotImplementedError
@property
def test_name(self):
if hasattr(self, "jsFile"):
return os.path.basename(self.jsFile)
else:
return "%s.py %s.%s" % (self.__class__.__module__, self.__class__.__name__, self._testMethodName)
def id(self):
# TBPL starring requires that the "test name" field of a failure message
# not differ over time. The test name to be used is passed to
# mozlog via the test id, so this is overriden to maintain
# consistency.
return self.test_name
def setUp(self):
# Convert the marionette weakref to an object, just for the
# duration of the test; this is deleted in tearDown() to prevent
# a persistent circular reference which in turn would prevent
# proper garbage collection.
self.start_time = time.time()
self.pingServer = PingServer()
self.pingServer.start()
self.marionette = Marionette(bin=self.binary, profile=self.profile)
if self.marionette.session is None:
self.marionette.start_session()
if self.marionette.timeout is not None:
self.marionette.timeouts(self.marionette.TIMEOUT_SEARCH, self.marionette.timeout)
self.marionette.timeouts(self.marionette.TIMEOUT_SCRIPT, self.marionette.timeout)
self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, self.marionette.timeout)
else:
self.marionette.timeouts(self.marionette.TIMEOUT_PAGE, 30000)
def tearDown(self):
self.marionette.cleanup()
self.pingServer.stop()
def cleanTest(self):
self._deleteSession()
def _deleteSession(self):
if hasattr(self, "start_time"):
self.duration = time.time() - self.start_time
if hasattr(self.marionette, "session"):
if self.marionette.session is not None:
try:
self.loglines.extend(self.marionette.get_logs())
except Exception, inst:
self.loglines = [["Error getting log: %s" % inst]]
try:
self.marionette.delete_session()
except (socket.error, MarionetteException, IOError):
# Gecko has crashed?
self.marionette.session = None
try:
self.marionette.client.close()
except socket.error:
pass
self.marionette = None
开发者ID:nwgh,项目名称:gecko-dev,代码行数:101,代码来源:session_test.py
示例13: Marionette
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from marionette_driver.marionette import Marionette
import pdb
client = Marionette("localhost", port=2828)
client.start_session()
client.navigate("http://www.tianyancha.com/company/75507246")
element = client.find_element("class name", 'company_info')
print element.text
开发者ID:lg31415,项目名称:antitools,代码行数:14,代码来源:testtianya.py
示例14: marionette
def marionette(request):
marionette = Marionette(bin=request.config.getoption('firefox_path'))
marionette.start_session()
request.node._marionette = marionette
yield marionette
marionette.cleanup()
开发者ID:davehunt,项目名称:pytest-firefox,代码行数:6,代码来源:plugin.py
示例15: client
def client():
# On MacOS: /Applications/Firefox.app/Contents/MacOS/firefox -marionette
client = Marionette(host='localhost', port=2828)
client.start_session()
return client
开发者ID:AusDTO,项目名称:dto-digitalmarketplace-buyer-frontend,代码行数:5,代码来源:conftest.py
示例16: run_tests
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):
#.........这里部分代码省略.........
开发者ID:palant,项目名称:searchlinkfix,代码行数:101,代码来源:run_tests.py
示例17: marionette
def marionette(request):
m = Marionette(bin=request.config.option.bin)
m.start_session()
m.set_prefs({'signon.rememberSignons': False})
request.addfinalizer(m.delete_session)
return m
开发者ID:amitverma12,项目名称:fxapom,代码行数:6,代码来源:conftest.py
示例18: Marionette
#!/usr/bin/python2.7
#
# Script to work around Marionette bug 879816 (cannot click the modal 'ok' button
# following clicking something else).
#
from marionette_driver.marionette import Marionette
marionette = Marionette(host='localhost', port=2828)
marionette.start_session()
marionette.switch_to_frame()
marionette.execute_script("document.getElementById('modal-dialog-prompt-ok').click();")
开发者ID:owdqa,项目名称:OWD_TEST_TOOLKIT,代码行数:10,代码来源:click_modal_ok_btn.py
示例19: gp_success
init += 1
return gp_success(init)
else:
return True
parser = argparse.ArgumentParser(description='Bulk Reject translations on GlotPress with Firefox')
parser.add_argument('--search', dest='search', help='The term with problems', required=True, type=str)
parser.add_argument('--remove', dest='remove', help='The wrong translation to remove', required=True, type=str)
parser.add_argument('--replace', dest='replace', help='The new translation to submit', required=False, type=str)
parser.add_argument('--lang', dest='lang', help='The locale, eg: it', default="it")
args = parser.parse_args()
# Load configuration
config = ConfigParser.RawConfigParser()
config.readfp(open('config.ini'))
print "Connection in progress to Firefox"
client = Marionette(host='127.0.0.1', port=28288)
client.start_session()
print "Connection to Firefox Done"
# Detect if already logged
try:
client.find_element(By.CSS_SELECTOR, 'body.logged-in')
client.navigate("https://translate.wordpress.org/wp-login.php?action=logout&redirect_to=https%3A%2F%2Ftranslate.wordpress.org%2F&_wpnonce=583839252e")
except:
pass
# Login
client.navigate("https://login.wordpress.org/?redirect_to=https%3A%2F%2Ftranslate.wordpress.org%2F")
try:
#Log In Form
usernameLogin = client.find_element(By.ID, 'user_login')
usernameLogin.click()
usernameLogin.send_keys(config.get('Login', 'user'))
开发者ID:Mte90,项目名称:BulkRejectGP,代码行数:31,代码来源:bulkrejectgp.py
注:本文中的marionette_driver.marionette.Marionette类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论