Пример #1
0
 def stop_back_car(self):
     # 先上电
     os.popen('adb -s ' + ht.get_conf_value('deviceSerial') +
              ' shell "echo 1 > /sys/devices/virtual/misc/cis_mcu/acc"')
     # 倒车
     os.popen('adb -s ' + ht.get_conf_value('deviceSerial') +
              ' shell "echo 0 > /sys/devices/virtual/misc/cis_mcu/reverse"')
Пример #2
0
def before_all(context):
    print('校验设备是否连接')
    serialNum = ht.get_conf_value('deviceSerial')
    if not ht.check_is_connected(serialNum):
        uit.raise_Exception_info('车机没有连接请检查')

    print('设备已经连接')
    #安装utf7ime输入法并设置为默认输入法
    print('开始设置输入法')
    try:
        utf7apk_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'support', 'Utf7Ime.apk')
        subprocess.call('adb -s ' + serialNum + 'install -r ' + utf7apk_path, shell=True)
        # 设置输入法
        subprocess.call('adb -s ' + serialNum + ' shell settings put secure default_input_method jp.jun_nama.test.utf7ime/.Utf7ImeService', shell=True)
        print('输入法设置完成')
    except Exception as e:
        print(e)



    # 清空logcat日志记录
    log_path = ht.get_conf_value('logPath')

    if sys.platform == 'linux':
        subprocess.call('rm -rf ' + log_path, shell=True)
    else:
        subprocess.call('rd /q/s ' + log_path, shell=True)
Пример #3
0
 def get_media_volume(self):
     if platform.system() == 'Linux':
         cmd = '''adb  -s ''' + ht.get_conf_value(
             'deviceSerial'
         ) + ''' shell "echo 'select * from system;'|sqlite3 /data/data/com.android.providers.settings/databases/settings.db" | grep "volume_music_speaker"'''
     else:
         cmd = '''adb  -s ''' + ht.get_conf_value(
             'deviceSerial'
         ) + ''' shell "echo 'select * from system;'|sqlite3 /data/data/com.android.providers.settings/databases/settings.db" | findstr "volume_music_speaker"'''
     volume_ret = os.popen(cmd).read().strip()
     volume_value = volume_ret.split('|')[2].strip()
     print(volume_value)
     return volume_value
Пример #4
0
def before_all(context):
    # 发送消息到客户端
    cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        cli.connect(('localhost', 8899))
        cli.send('start'.encode('utf-8'))
        time.sleep(2)
    except:
        pass
    finally:
        cli.close()

    print('校验设备是否连接')
    serialNum = ht.get_conf_value('deviceSerial')
    if not ht.check_is_connected(serialNum):
        uit.raise_Exception_info('车机没有连接请检查')

    print('设备已经连接')
    # 安装utf7ime输入法并设置为默认输入法
    print('开始设置输入法')
    try:
        utf7apk_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                    'support', 'Utf7Ime.apk')
        subprocess.call('adb -s ' + serialNum + ' install -r ' + utf7apk_path,
                        shell=True)
        # 设置输入法
        subprocess.call(
            'adb -s ' + serialNum +
            ' shell settings put secure default_input_method jp.jun_nama.test.utf7ime/.Utf7ImeService',
            shell=True)
        print('输入法设置完成')
    except Exception as e:
        print(e)
Пример #5
0
 def raise_exception_for_phone(self, message):
     file_name = time.strftime('%Y%m%d%H%M%S') + '.png'
     # file_path = os.path.join(Utils().get_conf_value('storePath'), time.strftime('%Y%m%d%H%M%S') + '.png')
     file_path = os.path.join(ht.get_conf_value('logPath'),
                              time.strftime('%Y%m%d'), 'screenshots',
                              file_name)
     dphone.screenshot(file_path)
     raise Exception(message + ',请参考截图信息: ' + 'file:///' + file_path)
Пример #6
0
def after_all(context):
    # 恢复输入法
    try:
        print('还原输入法')
        serialNum = ht.get_conf_value('deviceSerial')
        subprocess.call('adb -s ' + serialNum + ' shell settings put secure default_input_method com.android.inputmethod.qingganime/.QingganIME', shell=True)
        print('还原输入法完成')
    except Exception as e:
        print('还原输入法失败')
        print(e)
Пример #7
0
    def take_screenshot(self):
        file_name = time.strftime('%Y%m%d%H%M%S') + '.png'
        file_path = os.path.join(ht.get_conf_value('logPath'),
                                 time.strftime('%Y%m%d'), 'screenshots',
                                 file_name)
        dir_path = os.path.dirname(file_path)
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        ht.get_device_obj().screenshot(file_path)
        # self.__set_file_path('file://' + file_path)
        print(file_path)
        return file_path
Пример #8
0
    def take_screenshot(self):
        '''
        截图
        :return: 截图保存路径
        '''
        file_name = time.strftime('%Y%m%d%H%M%S') + '.png'
        log_path = ht.get_conf_value('logPath')
        time_dir = time.strftime('%Y%m%d')

        file_path = os.path.join(log_path, time_dir, 'screenshots', file_name)
        dir_path = os.path.dirname(file_path)

        # 判断目录是否存在, 不存在创建目录
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        d.screenshot(file_path)
        return file_path
Пример #9
0
def before_scenario(context, scenario):
    sce_name = scenario.name
    print('=' * 60)
    print('场景《' + sce_name + '》开始执行!')
    serialNum = ht.get_conf_value('deviceSerial')
    if ':' in serialNum:
        try:
            subprocess.call('adb connect ' + serialNum, shell=True)
        except:
            pass

    print('执行场景前处理,回到主界面')
    try:
        com.back_to_launcher()
    except Exception as e:
        if uit.crash_handler():
            print('回到主界面有CRASH')
            print(e)
        else:
            print('回到主界面异常输出:')
            print(e)
    print('清空上下文数据')
    MAP_VAR.clear()
    print('场景前处理执行结束')
Пример #10
0
def after_all(context):
    # 发送消息到客户端
    cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        cli.connect(('localhost', 8899))
        cli.send('end'.encode('utf-8'))
        time.sleep(2)
    except:
        pass
    finally:
        cli.close()

    # 恢复输入法
    try:
        print('还原输入法')
        serialNum = ht.get_conf_value('deviceSerial')
        subprocess.call(
            'adb -s ' + serialNum +
            ' shell settings put secure default_input_method com.android.inputmethod.qingganime/.QingganIME',
            shell=True)
        print('还原输入法完成')
    except Exception as e:
        print('还原输入法失败')
        print(e)
Пример #11
0
def step_impl(context):
    device_serial = ht.get_conf_value('deviceSerial')
    os.popen('adb -s ' + device_serial + ' shell reboot')