使用python在控制台Appium测试中输入变量的循环

2024-05-18 07:53:51 发布

您现在位置:Python中文网/ 问答频道 /正文

对于我的Appium测试,我想输入不同的手机和语言进行测试

我有一个文件,其中定义了所有电话和语言,我只是试图通过在控制台中输入电话名来加载该文件

Test.py:

import time
import subprocess
import os
from Mobiles import *
from Languages import *

print('Insert Mobile')
deviceName = input()
print('Insert Language')
language = input()

try:
    os.system("LoginTest.py")
except:
    time.sleep(0.5)

try:
    os.system("DetailPagesTest.py")
except:
    time.sleep(0.5)

现在我有一个循环(4次)输入我的手机和语言,我不知道如何解决这个问题

Mobiles.py如下所示:

import os
import sys
from Test import *

print('Insert Mobile')
deviceName = input()

# Returns abs path relative to this file and not cwd

PATH = lambda p: os.path.abspath(
    os.path.join(os.path.dirname(__file__), p)
)

if (deviceName == 'Honor8_'):
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '7.0'
    desired_caps['deviceName'] = '73QDU16B30003518'
    desired_caps ['automationName'] = 'UiAutomator2'
    desired_caps['app'] = PATH( 'PATH')
elif (deviceName == 'Honor10_'):
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '9'
    desired_caps['deviceName'] = 'CLCDU18709011839'
    desired_caps['automationName'] = 'UiAutomator2'
    desired_caps['app'] = PATH( 'PATH')

Tags: pathfrompyimport语言inputtimeos