mercredi 5 février 2020

Loop for entering variables in consile - Appium testing with python

for my Appium Tests i want do enter different mobiles and languages for my tests.

I have a file where all phones and languages are defined, an i just try to load the file, by entering the phonename in the console.

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)

Now i get a loop (4 times) for entering my mobile and language and i have no idea how to fix this.

Mobiles.py looks like this:

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')

Aucun commentaire:

Enregistrer un commentaire