import os
import sys
import random
import unittest
from time import sleep
from appium import webdriver
class hh (unittest.TestCase):
def test_addContent(self):
desire_caps={}
desire_caps['platformName']='Android'
desire_caps['platformVersioin']='7.1.1'
desire_caps['appPackage']='com.android.calculator2'
desire_caps['appActivity']='.Calculator'
desire_caps['deviceName']='ZY223MPGDF'
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub",desire_caps)
#随机进行n次四则运算
num=[]
num=['0','1','2','3','4','5','6','7','8','9']
numEx='com.android.calculator2:id/digit_'
operator=['com.android.calculator2:id/op_add','com.android.calculator2:id/op_sub',
'com.android.calculator2:id/op_mul','com.android.calculator2:id/op_div']
clearButton='com.android.calculator2:id/clr'
equalButton='com.android.calculator2:id/eq'
i=random.randint(10,15)
while i>=5:
ii=random.randint(3,6)
while ii>=3:
randNum=random.randint(0,9)
numClick=driver.find_element_by_id(numEx+num[randNum]).click()
ii=ii-1
randOP=random.randint(0,3)
operaClick=driver.find_element_by_id(operator[randOP]).click()
ii=random.randint(3,6)
while ii>=3:
randNum=random.randint(0,9)
numClick=driver.find_element_by_id(numEx+num[randNum]).click()
ii=ii-1
equalClick=driver.find_element_by_id(equalButton).click()
clearClick=driver.find_element_by_id(clearButton).click()
sleep(1)
i=i-1
driver.quit()
if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(hh)
unittest.TextTestRunner(verbosity=2).run(suite)
Appium-Python随机进行n次i位数字四则运算
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...