本文整理汇总了Python中marionette.Marionette类的典型用法代码示例。如果您正苦于以下问题:Python Marionette类的具体用法?Python Marionette怎么用?Python Marionette使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Marionette类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_marionette
def get_marionette(self):
if not self.m:
self.m = Marionette(port=self.port)
self.m.start_session()
self.device = GaiaDevice(self.m)
self.device.add_device_manager(self.dm)
self.gaia_apps = GaiaApps(self.m)
else:
tries = 5
while tries > 0:
try:
self.m.get_url()
break
except MarionetteException as e:
if "Please start a session" in str(e):
time.sleep(5)
self.m = Marionette(port=self.port)
self.m.start_session()
self.device = GaiaDevice(self.m)
self.device.add_device_manager(self.dm)
self.gaia_apps = GaiaApps(self.m)
tries -= 1
else:
raise e
else:
self.run_log.error("Can't connect to marionette, rebooting")
self.restart_device()
return self.m
示例2: cli
def cli():
parser = OptionParser(usage='%prog gaia_atoms_path app_name [app_name] ...')
options, args = parser.parse_args()
if not args:
parser.print_usage()
parser.exit()
if not os.path.isdir(args[0]):
parser.print_usage()
print 'must specify valid path for gaia atoms'
parser.exit()
if len(args) != 2:
parser.print_usage()
print 'must specify at one app name'
parser.exit()
marionette = Marionette(host='localhost', port=2828) # TODO command line option for address
marionette.start_session()
launchApp(
marionette,
gaia_atoms=args[0],
app_name=args[1])
示例3: run_marionette
def run_marionette(self, dir):
self.logger.info("Starting test run")
# Start up marionette
m = Marionette(emulator=True, homedir=dir)
assert m.start_session()
for test in self.testlist:
run_test(test, m)
m.delete_session()
示例4: get_new_emulator
def get_new_emulator(self):
_qemu = Marionette(emulator=True,
homedir=self.marionette.homedir,
baseurl=self.marionette.baseurl,
noWindow=self.marionette.noWindow)
_qemu.start_session()
self._qemu.append(_qemu)
return _qemu
示例5: create_marionette
def create_marionette():
"""Creates a new Marionette session if one does not exist."""
m = TestCase.stored.marionette
if not m:
m = Marionette()
m.start_session()
TestCase.stored.marionette = m
return TestCase.stored.marionette
示例6: get_marionette
def get_marionette(args):
mc = Marionette('localhost', args.adb_port)
for i in range(3):
try:
mc.start_session()
break
# Catching SystemExit because tracebacks are suppressed.
# This won't be necessary after
# https://bugzilla.mozilla.org/show_bug.cgi?id=863377
except (socket.error, SystemExit):
sh('adb forward tcp:%s tcp:%s' % (args.adb_port, args.adb_port))
return mc
示例7: 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,
homedir=self.marionette.homedir,
baseurl=self.marionette.baseurl,
noWindow=self.marionette.noWindow)
qemu.start_session()
self.marionette.extra_emulators.append(qemu)
else:
qemu = self.marionette.extra_emulators[self.extra_emulator_index]
return qemu
示例8: start_marionette
def start_marionette(self):
assert(self.baseurl is not None)
if self.bin:
if self.address:
host, port = self.address.split(':')
else:
host = 'localhost'
port = 2828
self.marionette = Marionette(host=host,
port=int(port),
app=self.app,
bin=self.bin,
profile=self.profile,
baseurl=self.baseurl,
timeout=self.timeout)
elif self.address:
host, port = self.address.split(':')
try:
#establish a telnet connection so we can vertify the data come back
tlconnection = Telnet(host, port)
except:
raise Exception("could not connect to given marionette host/port")
if self.emulator:
self.marionette = Marionette.getMarionetteOrExit(
host=host, port=int(port),
connectToRunningEmulator=True,
homedir=self.homedir,
baseurl=self.baseurl,
logcat_dir=self.logcat_dir,
gecko_path=self.gecko_path,
symbols_path=self.symbols_path,
timeout=self.timeout)
else:
self.marionette = Marionette(host=host,
port=int(port),
baseurl=self.baseurl,
timeout=self.timeout)
elif self.emulator:
self.marionette = Marionette.getMarionetteOrExit(
emulator=self.emulator,
emulatorBinary=self.emulatorBinary,
emulatorImg=self.emulatorImg,
emulator_res=self.emulator_res,
homedir=self.homedir,
baseurl=self.baseurl,
noWindow=self.noWindow,
logcat_dir=self.logcat_dir,
gecko_path=self.gecko_path,
symbols_path=self.symbols_path,
timeout=self.timeout)
else:
raise Exception("must specify binary, address or emulator")
示例9: ftu_toggler
def ftu_toggler(skip_ftu=True):
dm = mozdevice.DeviceManagerADB(runAdbAsRoot=True)
dm.forward("tcp:2828", "tcp:2828")
m = Marionette()
m.start_session()
data_layer = GaiaData(m)
url = "null" if skip_ftu else "app://ftu.gaiamobile.org/manifest.webapp"
data_layer.set_setting('ftu.manifestURL', url)
m.close()
# restart b2g to enable
dm.reboot()
示例10: startMarionette
def startMarionette():
# FW port for ADB via USB
return_code = subprocess.call(["adb root"], shell=True)
if return_code:
raise Exception("Failed to start adb in root mode. Ensure device is attached to USB.")
return_code = subprocess.call(["adb forward tcp:2828 tcp:2828"], shell=True)
if return_code:
raise Exception("Failed to connect to device via ADB; ensure device is attached to USB.")
# Start Marionette
marionette = Marionette(host='localhost', port=2828)
marionette.start_session()
marionette.set_script_timeout(60000)
return marionette
示例11: create_marionette
def create_marionette():
"""Returns current Marionette session, or creates one if
one does not exist.
"""
m = TestCase.stored.marionette
if m is None:
m = Marionette()
m.wait_for_port()
m.start_session()
TestCase.stored.marionette = m
return TestCase.stored.marionette
示例12: setup
def setup(self):
try:
self.client = Marionette(host='localhost', port=2828)
self.client.start_session()
self.client.set_pref('general.warnOnAboutConfig', False)
except:
sys.exit("Could not find Firefox browser running")
示例13: run_desktop_mochitests
def run_desktop_mochitests(parser, options):
# create our Marionette instance
kwargs = {}
if options.marionette:
host, port = options.marionette.split(':')
kwargs['host'] = host
kwargs['port'] = int(port)
marionette = Marionette.getMarionetteOrExit(**kwargs)
mochitest = B2GDesktopMochitest(marionette, options.profile_data_dir)
# add a -bin suffix if b2g-bin exists, but just b2g was specified
if options.app[-4:] != '-bin':
if os.path.isfile("%s-bin" % options.app):
options.app = "%s-bin" % options.app
options = MochitestOptions.verifyOptions(parser, options, mochitest)
if options == None:
sys.exit(1)
if options.desktop and not options.profile:
raise Exception("must specify --profile when specifying --desktop")
options.browserArgs += ['-marionette']
sys.exit(mochitest.runTests(options, onLaunch=mochitest.startTests))
示例14: restart_device
def restart_device(self, restart_tries=0):
self.run_log.info("rebooting")
# TODO restarting b2g doesn't seem to work... reboot then
while restart_tries < 3:
restart_tries += 1
self.dm.reboot(wait=True)
self.run_log.info("forwarding")
if not self.forward_port():
self.run_log.error("couldn't forward port in time, rebooting")
continue
self.m = Marionette(port=self.port)
if not self.m.wait_for_port(180):
self.run_log.error("couldn't contact marionette in time, rebooting")
continue
time.sleep(1)
self.m.start_session()
try:
Wait(self.m, timeout=240).until(lambda m: m.find_element("id", "lockscreen-container").is_displayed())
# It retuns a little early
time.sleep(2)
self.device = GaiaDevice(self.m)
self.device.add_device_manager(self.dm)
self.device.unlock()
self.gaia_apps = GaiaApps(self.m)
except (MarionetteException, IOError, socket.error) as e:
self.run_log.error("got exception: %s, going to retry" % e)
try:
self.m.delete_session()
except:
# at least attempt to clear the session if possible
pass
continue
break
else:
raise Exception("Couldn't restart the device in time, even after 3 tries")
示例15: _StartProcess
def _StartProcess(self):
if not self.isEmulatorInitialized:
print("Starting Emulator ...")
self.emulatorProcess = subprocess.Popen(
[self.emulatorStartScript], cwd=os.path.dirname(self.emulatorStartScript), shell=True)
# adb shell setprop net.dns1 10.0.2.3
self._isBootFinished()
self.monitoringProcessId = self.adb.getPID(self.monitoredProcessName)
print("Forwarding TCP port %d ..." % self.forwardedPortADB)
self.adb.command(["forward", "tcp:%d" % self.forwardedPortADB, "tcp:%d" % self.forwardedPortADB])
self.isEmulatorInitialized = True
time.sleep(20)
if self.crashSuccess:
print("Restarting %s ..." % self.monitoredProcessName)
self.adb.killProcess(self.monitoredProcessName, True)
time.sleep(40)
self.monitoringProcessId = self.adb.getPID(self.monitoredProcessName)
self.crashSuccess = False
self.debugLogData = str()
self.adb.checkCmd(["logcat", "-c"])
print("Starting Marionette session ...")
marionette = Marionette('localhost', self.forwardedPortADB)
print(marionette.status())
marionette.start_session()
marionette.set_script_timeout(self.scriptTimeout)
marionette.switch_to_frame()
lock = gaia.LockScreen(marionette)
lock.unlock()
apps = gaia.GaiaApps(marionette)
print(apps.runningApps())
print("Launching Browser application")
apps.launch(self.appName, switch_to_frame=True)
print("Navigating to %s ..." % self.publisherURL)
marionette.execute_script("return window.wrappedJSObject.Browser.navigate('%s')" % self.publisherURL)
self.isMonitorInitialized = True