コード例 #1
0
 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
0
 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),
                                      bin=self.bin, profile=self.profile,
                                      baseurl=self.baseurl)
     elif self.address:
         host, port = self.address.split(':')
         if self.emulator:
             self.marionette = Marionette(host=host, port=int(port),
                                          connectToRunningEmulator=True,
                                          homedir=self.homedir,
                                          baseurl=self.baseurl,
                                          logcat_dir=self.logcat_dir)
         else:
             self.marionette = Marionette(host=host,
                                          port=int(port),
                                          baseurl=self.baseurl)
     elif self.emulator:
         self.marionette = Marionette(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)
     else:
         raise Exception("must specify binary, address or emulator")
コード例 #3
0
 def start_marionette(self):
     assert (self.baseurl is not None)
     if self.address:
         host, port = self.address.split(':')
         if self.emulator:
             self.marionette = Marionette(host=host,
                                          port=int(port),
                                          connectToRunningEmulator=True,
                                          homedir=self.homedir,
                                          baseurl=self.baseurl,
                                          logcat_dir=self.logcat_dir)
         if self.b2gbin:
             self.marionette = Marionette(host=host,
                                          port=int(port),
                                          b2gbin=self.b2gbin,
                                          baseurl=self.baseurl)
         else:
             self.marionette = Marionette(host=host,
                                          port=int(port),
                                          baseurl=self.baseurl)
     elif self.emulator:
         self.marionette = Marionette(emulator=self.emulator,
                                      emulatorBinary=self.emulatorBinary,
                                      homedir=self.homedir,
                                      baseurl=self.baseurl,
                                      noWindow=self.noWindow,
                                      logcat_dir=self.logcat_dir)
     else:
         raise Exception("must specify address or emulator")
コード例 #4
0
    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")
コード例 #5
0
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])
 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")
コード例 #7
0
ファイル: set_up_device.py プロジェクト: tempbottle/webpay
def set_up_device(opt):
    if not opt.wifi_ssid or not opt.wifi_key or not opt.wifi_pass:
        raise ValueError('Missing --wifi options')

    mc = Marionette('localhost', opt.adb_port)
    for i in range(2):
        try:
            mc.start_session()
            break
        except socket.error:
            sh('adb forward tcp:%s tcp:%s' % (opt.adb_port, opt.adb_port))
    if opt.shell:
        from pdb import set_trace
        set_trace()
        return

    # watch out! This is how gaiatest does it.
    mc.__class__ = type('Marionette', (Marionette, MarionetteTouchMixin), {})
    device = GaiaDevice(mc)

    device.restart_b2g()

    apps = GaiaApps(mc)
    data_layer = GaiaData(mc)
    lockscreen = LockScreen(mc)
    mc.setup_touch()

    lockscreen.unlock()
    apps.kill_all()

    data_layer.enable_wifi()
    if opt.wifi_key == 'WPA-PSK':
        pass_key = 'psk'
    elif opt.wifi_key == 'WEP':
        pass_key = 'wep'
    else:
        assert 0, 'unknown key management'
    data = {'ssid': opt.wifi_ssid, 'keyManagement': opt.wifi_key,
            pass_key: opt.wifi_pass}
    data_layer.connect_to_wifi(data)

    mc.switch_to_frame()
    all_apps = set(a['manifest']['name'] for a in get_installed(apps))
    if 'Marketplace Dev' not in all_apps:
        mc.execute_script(
            'navigator.mozApps.install'
            '("https://marketplace-dev.allizom.org/manifest.webapp");')
        wait_for_element_displayed(mc, 'id', 'app-install-install-button')
        yes = mc.find_element('id', 'app-install-install-button')
        mc.tap(yes)
        wait_for_element_displayed(mc, 'id', 'system-banner')

    print 'Pushing payment prefs'
    sh('adb shell stop b2g')
    sh('adb push "%s" /data/local/user.js' % (
        os.path.join(os.path.dirname(__file__), 'payment-prefs.js')))
    sh('adb shell start b2g')

    print 'When your device reboots, Marketplace Dev will be installed'
コード例 #8
0
def main():
    parser = B2GOptions()
    options, args = parser.parse_args()
    options = parser.verifyRemoteOptions(options)

    # Create the Marionette instance
    kwargs = {}
    if options.emulator:
        kwargs['emulator'] = options.emulator
        if options.no_window:
            kwargs['noWindow'] = True
        if options.geckoPath:
            kwargs['gecko_path'] = options.geckoPath
        if options.logcat_dir:
            kwargs['logcat_dir'] = options.logcat_dir
        if options.busybox:
            kwargs['busybox'] = options.busybox
        if options.symbolsPath:
            kwargs['symbols_path'] = options.symbolsPath
    if options.b2g_path:
        kwargs['homedir'] = options.emu_path or options.b2g_path
    if options.address:
        host, port = options.address.split(':')
        kwargs['host'] = host
        kwargs['port'] = int(port)
        kwargs['baseurl'] = 'http://%s:%d/' % (host, int(port))
        if options.emulator:
            kwargs['connectToRunningEmulator'] = True
    marionette = Marionette(**kwargs)

    if options.emulator:
        dm = marionette.emulator.dm
    else:
        # Create the DeviceManager instance
        kwargs = {'adbPath': options.adb_path}
        if options.deviceIP:
            kwargs['host'] = options.deviceIP
            kwargs['port'] = options.devicePort
        kwargs['deviceRoot'] = options.remoteTestRoot
        dm = devicemanagerADB.DeviceManagerADB(**kwargs)

    if not options.remoteTestRoot:
        options.remoteTestRoot = dm.getDeviceRoot()
    xpcsh = B2GXPCShellRemote(dm, options, args)

    # we don't run concurrent tests on mobile
    options.sequential = True

    try:
        if not xpcsh.runTests(xpcshell='xpcshell',
                              testdirs=args[0:],
                              testClass=B2GXPCShellTestThread,
                              mobileArgs=xpcsh.mobileArgs,
                              **options.__dict__):
            sys.exit(1)
    except:
        print "Automation Error: Exception caught while running tests"
        traceback.print_exc()
        sys.exit(1)
コード例 #9
0
 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
コード例 #10
0
def main():
    scriptdir = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
    auto = B2GRemoteAutomation(None, "fennec")
    parser = B2GOptions(auto, scriptdir)
    options, args = parser.parse_args()

    # create our Marionette instance
    kwargs = {'emulator': options.emulator}
    if options.b2gPath:
        kwargs['homedir'] = options.b2gPath
    if options.marionette:
        host,port = options.marionette.split(':')
        kwargs['host'] = host
        kwargs['port'] = int(port)
    marionette = Marionette(**kwargs)

    auto.marionette = marionette

    # create the DeviceManager
    kwargs = {'adbPath': options.adbPath}
    if options.deviceIP:
        kwargs.update({'host': options.deviceIP,
                       'port': options.devicePort})
    dm = devicemanagerADB.DeviceManagerADB(**kwargs)

    auto.setDeviceManager(dm)
    options = parser.verifyRemoteOptions(options, auto)
    if (options == None):
        print "ERROR: Invalid options specified, use --help for a list of valid options"
        sys.exit(1)

    auto.setProduct("b2g")

    mochitest = B2GMochitest(auto, dm, options)

    options = parser.verifyOptions(options, mochitest)
    if (options == None):
        sys.exit(1)

    logParent = os.path.dirname(options.remoteLogFile)
    dm.mkDir(logParent);
    auto.setRemoteLog(options.remoteLogFile)
    auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)

    retVal = 1
    try:
        retVal = mochitest.runTests(options)
    except:
        print "TEST-UNEXPECTED-FAIL | %s | Exception caught while running tests." % sys.exc_info()[1]
        mochitest.stopWebServer(options)
        mochitest.stopWebSocketServer(options)
        try:
            mochitest.cleanup(None, options)
        except:
            pass
            sys.exit(1)

    sys.exit(retVal)
コード例 #11
0
 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,
                                      app_args=self.app_args,
                                      bin=self.bin,
                                      profile=self.profile,
                                      baseurl=self.baseurl,
                                      timeout=self.timeout,
                                      device_serial=self.device_serial)
     elif self.address:
         host, port = self.address.split(':')
         try:
             #establish a socket connection so we can vertify the data come back
             connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
             connection.connect((host, int(port)))
             connection.close()
         except Exception, e:
             raise Exception(
                 "Could not connect to given marionette host:port: %s" % e)
         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,
                 device_serial=self.device_serial)
         else:
             self.marionette = Marionette(host=host,
                                          port=int(port),
                                          baseurl=self.baseurl,
                                          timeout=self.timeout,
                                          device_serial=self.device_serial)
コード例 #12
0
ファイル: testcase.py プロジェクト: oouyang/fxos-certsuite
 def unplug_and_instruct(self, message):
     self.instruct(
         "Unplug the phone.\n%s\nPlug the phone back in after you are "
         "done, and unlock the screen if necessary.\n" % message)
     dm = mozdevice.DeviceManagerADB()
     dm.forward("tcp:2828", "tcp:2828")
     self.marionette = Marionette()
     self.marionette.start_session()
     self.use_cert_app()
コード例 #13
0
ファイル: b2g.py プロジェクト: skull591/rose6icse
    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
コード例 #14
0
 def startTests(self):
     # This is run in a separate thread because otherwise, the app's
     # stdout buffer gets filled (which gets drained only after this
     # function returns, by waitForFinish), which causes the app to hang.
     self.marionette = Marionette(**self.marionette_args)
     thread = threading.Thread(target=self.runMarionetteScript,
                               args=(self.marionette, self.test_script,
                                     self.test_script_args))
     thread.start()
コード例 #15
0
ファイル: b2g_desktop.py プロジェクト: martapiekarska/gecko
    def run_marionette_script(self):
        self.marionette = Marionette(**self.marionette_args)
        assert (self.marionette.wait_for_port())
        self.marionette.start_session()
        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)
コード例 #16
0
def launch_app(app_name,
               adb_path="adb",
               script_timeout=5000,
               marionette=None,
               device_serial=None):
    """
    Launches the given app
    NOTE: if a marionette session is passed, this function switches to the top-most frame.
    """
    dm = mozdevice.DeviceManagerADB(adbPath=adb_path,
                                    deviceSerial=device_serial)
    installed_app_name = app_name.lower()
    installed_app_name = installed_app_name.replace(" ", "-")
    dm.forward("tcp:2828", "tcp:2828")

    if not marionette:
        m = Marionette()
        m.start_session()
    else:
        m = marionette
        m.switch_to_frame()
    launch_app = """
    var launchWithName = function(name) {
        let apps = window.wrappedJSObject.applications || window.wrappedJSObject.Applications;
        let installedApps = apps.installedApps;
        for (let manifestURL in installedApps) {
          let app = installedApps[manifestURL];
          let origin = null;
          let entryPoints = app.manifest.entry_points;
          if (entryPoints) {
            for (let ep in entryPoints) {
              let currentEntryPoint = entryPoints[ep];
              let appName = currentEntryPoint.name;
              if (name == appName.toLowerCase()) {
                app.launch();
                return true;
              }
            }
          } else {
            let appName = app.manifest.name;
            if (name == appName.toLowerCase()) {
              app.launch();
              return true;
            }
          }
        }
        return false;
      };
    return launchWithName("%s");
    """
    m.set_script_timeout(script_timeout)
    m.execute_script(launch_app % app_name.lower())
    if not marionette:
        m.delete_session()
コード例 #17
0
ファイル: runner.py プロジェクト: Mozilla-TWQA/B2G-JS-REPL
    def __init__(self, **kwargs):
        # Added parser
        parser = OptionParser()
        parser.add_option(
            '-a',
            '--address',
            action='store',
            type='string',
            dest='address',
            default='localhost',
            help='The host address of b2g instance. Default=localhost')
        parser.add_option('-p',
                          '--port',
                          action='store',
                          type='int',
                          dest='port',
                          default=2828,
                          help='The port of b2g instance.')
        parser.add_option('-l',
                          '--list',
                          action='store_true',
                          dest='enable_list',
                          default='False',
                          help='List all apps of b2g instance. Default=False')
        parser.add_option('-c', '--connect',
                          action='store', type='string', dest='connect',
                          default=None,
                          help='Connect to the App iframe.' \
                               'Use # ID or App URL to connect.')

        (options, args) = parser.parse_args()
        self.connect = options.connect

        # start marionette session
        self.m = Marionette(options.address, options.port)
        self.m.start_session()

        # list all iframes
        if options.enable_list:
            self.list_all_iframes()
        # list active iframes
        elif self.connect == None:
            self.list_active_iframes()

        # connect to App
        if self.connect == None:
            exit(0)
        else:
            # connect App
            print 'Start...'
            if self.open_app(self.connect):
                self.start_js()
            else:
                exit(-1)
コード例 #18
0
ファイル: executor.py プロジェクト: poacher69/b2g-monkey
 def __init__(self, app_name, app_id, device=False):
     self.device = device
     if self.device:
         call(['adb', 'forward', 'tcp:2828', 'tcp:2828'])
     self._app_name = app_name
     self._app_id = app_id
     self._marionette = Marionette()
     self._marionette.start_session()
     self._gaia_apps = GaiaApps(self._marionette)
     self._gaia_data = GaiaData(self._marionette)
     self._gaia_device = GaiaDevice(self._marionette)
     ''' Deprecated
コード例 #19
0
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
コード例 #20
0
 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)
         qemu.start_session()
         self.marionette.extra_emulators.append(qemu)
     else:
         qemu = self.marionette.extra_emulators[self.extra_emulator_index]
     return qemu
コード例 #21
0
ファイル: runtestsb2g.py プロジェクト: LyeSS/mozilla-central
def main():
    parser = B2GOptions()
    options, args = parser.parse_args()

    if options.objdir is None:
        try:
            options.objdir = os.path.join(options.b2g_path, 'objdir-gecko')
        except:
            print >> sys.stderr, "Need to specify a --b2gpath"
            sys.exit(1)

    # Create the Marionette instance
    kwargs = {}
    if options.emulator:
        kwargs['emulator'] = options.emulator
        if options.no_window:
            kwargs['noWindow'] = True
    if options.b2g_path:
        kwargs['homedir'] = options.emu_path or options.b2g_path
    if options.address:
        host, port = options.address.split(':')
        kwargs['host'] = host
        kwargs['port'] = int(port)
        kwargs['baseurl'] = 'http://%s:%d/' % (host, int(port))
        if options.emulator:
            kwargs['connectToRunningEmulator'] = True
    marionette = Marionette(**kwargs)

    # Create the DeviceManager instance
    kwargs = {'adbPath': options.adb_path}
    if options.deviceIP:
        kwargs['host'] = options.deviceIP
        kwargs['port'] = options.devicePort
    kwargs['deviceRoot'] = DEVICE_TEST_ROOT
    dm = devicemanagerADB.DeviceManagerADB(**kwargs)

    options.remoteTestRoot = dm.getDeviceRoot()

    xpcsh = B2GXPCShellRemote(dm, options, args)

    try:
        success = xpcsh.runTests(xpcshell='xpcshell',
                                 testdirs=args[0:],
                                 **options.__dict__)
    except:
        print "TEST-UNEXPECTED-FAIL | %s | Exception caught while running tests." % sys.exc_info(
        )[1]
        traceback.print_exc()
        sys.exit(1)

    sys.exit(int(success))
 def execute(self):
     self.marionette.cleanup()
     self.marionette = Marionette(device_serial=self.serial, port=self.port)
     self.marionette.wait_for_port()
     # run test runner here
     self.remove_settings_opt()
     self.kwargs = {}
     if self.port:
         self.kwargs['address'] = "localhost:" + str(self.port)
     logger.info("Using address[localhost:" + str(self.port) + "]")
     self.start_monitoring()
     self.mtbf_daily()
     self.run_mtbf()
     self.stop_monitoring()
コード例 #23
0
ファイル: runner.py プロジェクト: AutomatedTester/eideticker
    def restart_b2g(self):
        #restart b2g so we start with a clean slate
        self.dm.checkCmd(['shell', 'stop', 'b2g'])
        # Wait for a bit to make sure B2G has completely shut down.
        time.sleep(10)
        self.dm.checkCmd(['shell', 'start', 'b2g'])

        #wait for marionette port to come up
        if not self.wait_for_port(30000):
            raise Exception(
                "Could not communicate with Marionette port after restarting B2G"
            )
        self.marionette = Marionette(self.marionette_host,
                                     self.marionette_port)
コード例 #24
0
ファイル: testcase.py プロジェクト: luser/fxos-certsuite
    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
コード例 #25
0
    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=15)
            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)
コード例 #26
0
ファイル: b2gmixin.py プロジェクト: roytam1/palemoon26
 def setupMarionette(self):
     """
     Start a marionette session.
     If no host is given, then this will get the ip
     of the device, and set up networking if needed.
     """
     if not self.marionetteHost:
         self.setupDHCP()
         self.marionetteHost = self.getIP()
     if not self.marionette:
         self.marionette = Marionette(self.marionetteHost,
                                      self.marionettePort)
     if not self.marionette.session:
         self.waitForPort(30)
         self.marionette.start_session()
コード例 #27
0
ファイル: b2g.py プロジェクト: skull591/rose6icse
    def _StartProcess(self):
        if not self.isDeviceInitialized:
            print("Starting ...")
            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.isDeviceInitialized = True

        print("Sleeping ...")
        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)
        assert (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
コード例 #28
0
def runemulator(homedir=None, url=None, pidfile=None, arch='x86'):
    qemu = Emulator(homedir=homedir, arch=arch)
    qemu.start()
    port = qemu.setup_port_forwarding(2828)
    assert (qemu.wait_for_port())
    if pidfile:
        f = open(pidfile, 'w')
        f.write("%d" % qemu.proc.pid)
        f.close()
    print 'emulator launched, pid:', qemu.proc.pid

    if url:
        marionette = Marionette(port=port)
        marionette.start_session()
        marionette.navigate(url)
        marionette.delete_session()
コード例 #29
0
def init():
    ret = subprocess.check_output("adb devices", shell=True)
    print(ret)
    ## TODO: find more error handling if available

    import socket
    s = socket.socket()
    try:
        s.bind(("localhost", 2828))
        s.close()
        ret = subprocess.check_output("adb forward tcp:2828 tcp:2828",
                                      shell=True)
    except socket.error:
        print("address already in use")
    mar = Marionette()
    mar.start_session()
    return mar
コード例 #30
0
    def setupMarionette(self, scriptTimeout=60000):
        """
        Starts a marionette session.
        If no host was given at init, the ip of the device will be retrieved
        and networking will be established.
        """
        if not self.marionetteHost:
            self.setupDHCP()
            self.marionetteHost = self.getIP()
        if not self.marionette:
            self.marionette = Marionette(self.marionetteHost,
                                         self.marionettePort)
        if not self.marionette.session:
            self.waitForPort(30)
            self.marionette.start_session()

        self.marionette.set_script_timeout(scriptTimeout)