How to use the airtest.connect function in airtest

To help you get started, we’ve selected a few airtest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NetEase / airtest / airtest / cli.py View on Github external
def run_snapshot():
    global serialno
    if not serialno and platform=='android':
        print F
        ds = airtest.getDevices()
        print ds
        if len(ds) == 1:
            serialno=ds[0][0]
        else:
            sys.exit("too many devices, don't know which you want")
    assert serialno != None
    print 'snapshot', serialno
    app = airtest.connect(serialno, device=platform)
    app.globalSet(dict(tmpdir='.'))
    print 'ROTATION:', rotation
    app.globalSet(dict(rotation=rotation))
    app.takeSnapshot('screen.png')
    print 'screenshot save to "screen.png"'
    #if platform == 'android':
github NetEase / airtest / gui / main.py View on Github external
def airConnect(self):
        device = self.cbDevice.currentText()
        phoneno = self.cbPhoneno.currentText()
        try:
            self.app = airtest.connect(str(phoneno), device=str(device), monitor=False)
            self.app.globalSet(image_match_method='template', threshold=0.7)
        except Exception as e:
            print 'CONNECT FAILED: %s' %(str(e))
        else:
            self.cbDestdir.clear()
            self.cbDestdir.addItem('image-%d_%d'%(self.app.width, self.app.height))
            self.cbDestdir.addItem('image-'+str(device))
            self.cbDestdir.addItem('image')

            suffix = '-%dx%d.png'%(self.app.width, self.app.height)
            tmpname = tempfile.mktemp(prefix='', suffix=suffix, dir='')
            print tmpname
            self.leCrop1.setText(tmpname)
        # self.textBrowser.clear()
        # code = "app=airtest.connect(\""+str(phoneno)+"\",device=\""+str(device)+"\")"
        # self.textBrowser.append(code)
github NetEase / airtest / example / flappybird / main.py View on Github external
def main():
    serialno = os.getenv('AIRTEST_PHONENO') or 'yykksj1231'
    appname = os.getenv('APPNAME') or 'com.dotgears.flappybird'
    print 'SERIALNO:', serialno
    print 'APPNAME:', appname

    app = airtest.connect(serialno, appname=appname)

    #app.stop()
    #app.start()

    app.sleep(2)

    #app.globalSet({'threshold': 0.1})
    app.click('start.png')
    w, h = app.shape()
    middle_point = (w*0.5, h*0.5)
    for i in range(5):
        app.click(middle_point)
        app.sleep(0.02)
    app.sleep(4)
    #assert app.exists('gameover.png')
github NetEase / airtest / test / test_dummy.py View on Github external
def test_connect_monitor():
    ap = airtest.connect('test-connect', appname='hello', device='dummy', monitor=False, logfile='log/1')
    ap.dev._getCpu = False
    time.sleep(2.0)
    assert ap.dev._getCpu == False
    ap.globalSet(enable_monitor=False)

    ap = airtest.connect('test-connect', appname='hello', device='dummy', monitor=True, logfile='log/2')
    ap.dev._getCpu = False
    time.sleep(2.0)
    assert ap.dev._getCpu == True
    ap.globalSet(enable_monitor=False)

    ap = airtest.connect('test-connect', appname='hello', device='dummy', logfile='log/3')
    ap.dev._getCpu = False
    time.sleep(2.0)
    assert ap.dev._getCpu == True
    ap.globalSet(enable_monitor=False)
github NetEase / airtest / airtest / console.py View on Github external
@cli.command(help='Take a picture of phone')
@click.option('--phoneno', help='If multi android dev connected, should specify serialno')
@click.option('--platform', default='android', type=click.Choice(['android', 'windows', 'ios']), show_default=True)
@click.option('--out', default='snapshot.png', type=click.Path(dir_okay=False),
        help='out filename [default: "snapshot.png"]', show_default=True)
def snapshot(phoneno, platform, out):
    try:
        app = airtest.connect(phoneno, device=platform)
        app.takeSnapshot(out)
    except Exception, e:
        click.echo(e)
github NetEase / airtest / airtest / webgui / routers / api.py View on Github external
@bp.route('/connect')
def connect():
    global app
    device = flask.request.args.get('device')
    devno = flask.request.args.get('devno')
    try:
        app = airtest.connect(devno, device=device, monitor=False)
    except Exception, e:
        return flask.jsonify(dict(success=False, message=str(e)))
        
    return flask.jsonify(dict(success=True, message="连接成功"))
github NetEaseGame / ATX / atx / console.py View on Github external
@cli.command(help='Take a picture of phone')
@click.option('--phoneno', help='If multi android dev connected, should specify serialno')
@click.option('--platform', default='android', type=click.Choice(['android', 'windows', 'ios']), show_default=True)
@click.option('--out', default='snapshot.png', type=click.Path(dir_okay=False),
        help='out filename [default: "snapshot.png"]', show_default=True)
def snapshot(phoneno, platform, out):
    try:
        app = airtest.connect(phoneno, device=platform)
        app.takeSnapshot(out)
    except Exception, e:
        click.echo(e)
github NetEaseGame / ATX / atx / webgui / routers / api.py View on Github external
@bp.route('/connect')
def connect():
    global app
    device = flask.request.args.get('device')
    devno = flask.request.args.get('devno')
    try:
        app = airtest.connect(devno, device=device, monitor=False)
    except Exception, e:
        return flask.jsonify(dict(success=False, message=str(e)))
        
    return flask.jsonify(dict(success=True, message="连接成功"))