本文整理汇总了Python中uiautomator.d函数的典型用法代码示例。如果您正苦于以下问题:Python d函数的具体用法?Python d怎么用?Python d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSendMMSWithVideo
def testSendMMSWithVideo(self):
"""
Summary:testSendMMSWithVideo: Send a mms with video attachment.
#Init condition:Clear up all messagebox
Steps:1. Open Messages app
2. Touch Compose button
3. Input deliver number and content
4. Touch Attach button
5. Select Gallery
6. Enter 001 folder, select a video
7. Touch Send button
8. Delete all messages
9. Exit Messages app
"""
#step1
commands.getoutput('adb shell am start ' + self.runComponent)
assert d(text = 'Messaging').wait.exists(), 'Message launch failed'
self._clearMessage()
#step2,3,4,5,6
commands.getoutput('adb shell am start -a android.intent.action.SEND -t video/* --es address ' + MESSAGE_RECEIVER_NUMBER + ' --es sms_body ' + SEND_MESSAGE_CONTENT + ' --eu android.intent.extra.STREAM file:///mnt/sdcard/001/300K/Video.3gp -n com.android.mms/.ui.ComposeMessageActivity')
assert d(text = 'View').wait.exists(), 'message create failed'
#step7
d(description = 'Send MMS').click.wait()
assert d(textContains = ':', className = 'android.widget.TextView').wait.exists(timeout = 60000), 'Message send failed'
#step8
d.press('back')
self._clearMessage()
示例2: testSendSMS
def testSendSMS(self):
"""
Summary:testSendSMS: Send a SMS.
#Init condition:Clear up all messagebox
Steps:1. Open Messages app
2. Touch Compose button
3. Input deliver number and content
4. Touch Send button
5. Delete all messages
6. Exit Messages app
"""
#step1
commands.getoutput('adb shell am start ' + self.runComponent)
assert d(text = 'Messaging').wait.exists(), 'Message launch failed'
self._clearMessage()
#step2,3
commands.getoutput('adb shell am start -a android.intent.action.SEND --es address ' + MESSAGE_RECEIVER_NUMBER + ' --es sms_body ' + SEND_MESSAGE_CONTENT + ' -n com.android.mms/.ui.ComposeMessageActivity')
time.sleep(2)
#step4
d(description = 'Send').click.wait()
assert d(textContains = ':', className = 'android.widget.TextView').wait.exists(timeout = 35000), 'Message send failed'
#step5
d.press('back')
self._clearMessage()
示例3: testOpenMmsWithImage
def testOpenMmsWithImage(self):
"""
Summary:testOpenMmsWithVideo:open a mms with video
#Init condition:Clear up all messagebox
Precondition:
1.There is a 600kb audio file in sdcard
Steps:1.Launch message app
2.Open a mms with audio
3.Delete message
4.Exit message app
"""
#step1
commands.getoutput('adb shell am start ' + self.runComponent)
assert d(text = 'Messaging').wait.exists(), 'Message launch failed'
self._clearMessage()
commands.getoutput('adb shell am start -a android.intent.action.SEND -t image/* --es address ' + MESSAGE_RECEIVER_NUMBER + ' --es sms_body ' + SEND_MESSAGE_CONTENT + ' --eu android.intent.extra.STREAM file:///mnt/sdcard/001/300K/Picture.jpg -n com.android.mms/.ui.ComposeMessageActivity')
time.sleep(2)
d.press('back')
#step2
d(textContains = 'subject').click.wait()
assert d(description = 'Send MMS').wait.exists(), 'MMS open failed'
#step3
d.press('back')
d.press('back')
self._clearMessage()
示例4: testOpenSms
def testOpenSms(self):
"""
Summary:testOpenSMS:open a sms
#Init condition:Clear up all messagebox
Precondition:
1.Prepare a received sms.
Steps:1.Launch Messages app
2.Open a sms
3.Delete message
4.Exit message app
"""
#step1
commands.getoutput('adb shell am start ' + self.runComponent)
assert d(text = 'Messaging').wait.exists(), 'Message launch failed'
self._clearMessage()
commands.getoutput('adb shell am start -a android.intent.action.SEND --es address ' + MESSAGE_RECEIVER_NUMBER + ' --es sms_body ' + SEND_MESSAGE_CONTENT + ' -n com.android.mms/.ui.ComposeMessageActivity')
time.sleep(2)
d.press('back')
#step2
d(textContains = 'test').click.wait()
assert d(description = 'Send').wait.exists(), 'SMS open failed'
#step3
d.press('back')
d.press('back')
self._clearMessage()
示例5: onClickSwitch
def onClickSwitch(textName):
if(d(className="android.widget.ListView", resourceId="com.android.settings:id/listviewApp").child_by_text(textName, className="android.widget.RelativeLayout").child(className="android.widget.Switch", text="OFF").exists):
d(className="android.widget.ListView", resourceId="com.android.settings:id/listviewApp").child_by_text(textName, className="android.widget.RelativeLayout").child(className="android.widget.Switch").click()
return True
else:
print(textName +"Already ONN")
return False
示例6: operation_usage
def operation_usage():
#d.press.home()
result=d(textContains=u'设置').wait.exists(timeout=10000)
#单位是毫秒, 如果timeout还没有找到,就返回false
print("next")
if result:
print("You press setting")
else:
print("You don't touch any thing")
'''
if d(text=u'设置').exists:
d(text='WLAN').click()
else:
print("move")
'''
# d(text=u'显示').click()
#支持unicode
d(scrollable=True).scroll(steps=3)
time.sleep(3)
#d.open.notification()
d.wait.idle()
print("waiting for idle")
示例7: firstdo
def firstdo(self):
'''
app 进入输入手机号界面前的准备操作
:return:
'''
#deviceinfo.startApp('com.coohuaclient/.ui.activity.SplashActivity')
time.sleep(5)
try:
#向右滑动解锁
# d(resourceId='com.coohuaclient:id/tv_slide_horizontal_guide').drag.to(resourceId='com.coohuaclient:id/view_hand',steps=100)
# textclick('点我左划试试')
# d(resourceId='com.coohuaclient:id/tv_slide_horizontal_guide').drag.to(resourceId='com.coohuaclient:id/tv_left_cost',steps=100)
# d(resourceId='com.coohuaclient:id/btn_click_me').click()
# #上划
# d(resourceId='com.coohuaclient:id/wave_circle_up').drag.to(d.info['displaySizeDpX']/2,100,steps=50)
#d(resourceId='com.coohuaclient:id/wave_circle_down').drag.to(d.info['displaySizeDpX']/2,d.info['displaySizeDpY'],steps=50)
#跳过
d(resourceId='com.coohuaclient:id/tv_date').click()
d(resourceId='com.coohuaclient:id/btn_register').click()
except:
print Exception
try:
textclick(u'注册')
except:
print Exception
示例8: inputCode
def inputCode(self):
d(resourceId="com.android.systemui:id/key1").click()
d(resourceId="com.android.systemui:id/key2").click()
d(resourceId="com.android.systemui:id/key3").click()
d(resourceId="com.android.systemui:id/key4").click()
time.sleep(2)
d(resourceId="com.android.systemui:id/key_enter").click()
示例9: loop_sdn
def loop_sdn():
if d(text="Service Dialing Numbers").wait.exists():
d(text="Service Dialing Numbers").click()
d.press("back")
else:
c.common.log("text=Service Dialing Numbers未找到,保存截图")
c.common.save_fail_img()
示例10: drag_txt1_to_txt2
def drag_txt1_to_txt2(txt1,txt2):
"""Drag the ui object to another ui object (center).
Example:
| drag txt1 to txt2| txt1 | txt2 | #drag txt1 to txt2 |
"""
d(text=txt1).drag.to(text=txt2, steps=50)
示例11: runtest
def runtest(serialno, loop):
print "liu: in runtest"
if serialno:
print "liu: in serialno"
from uiautomator import Device
d = Device(serialno)
else:
print "liu: in else"
from uiautomator import device as d
print "总共 %d 次循环" %loop
for i in range(1, loop+1):
print "第 %d 次循环" %i
d.screen.on()
d.press.home()
d(description="Apps").click()
d(text="Basemark ES2 Taiji Free").click()
time.sleep(2)
if d(text="Agree").exists:
d(text="Agree").click()
d(text="Run Benchmark").click()
while not d(text="FRAMES PER SECOND").exists:
time.sleep(2)
else:
d.screenshot("%s/screenshot/%d_taiji_%s.png"\
%(sys.path[0], i, now.strftime(ISOFORMAT)))
d.press.home()
i += 1
print "***** test end ********"
示例12: drag_txt_to_xy
def drag_txt_to_xy(txt,x,y,steps=100):
"""Drag the ui object to point (x, y).
Example:
| drag txt1 to xy| Music | 250 | 300 |
"""
d(text=txt).drag.to(x, y, steps)
示例13: setselftimerstatus
def setselftimerstatus(self,status):
commands.getoutput('adb shell input swipe 530 6 523 22')
time.sleep(1)
d(description=Setting_description).click.wait()
commands.getoutput('adb shell input swipe 670 165 78 165')
commands.getoutput('adb shell input tap 679 182')
time.sleep(1)
if status == '10':
commands.getoutput('adb shell input tap 414 294')
elif status == '5':
commands.getoutput('adb shell input tap 295 294')
elif status == '3':
commands.getoutput('adb shell input tap 181 294')
elif status == '0':
commands.getoutput('adb shell input tap 54 294')
time.sleep(3)
state = commands.getoutput(SelfTimer_STATE)
statevalue = state.find(status)
assert statevalue != -1
def launchcamera(self):
d(description='Apps').click.wait()
while not d.exists(text='Camera'):
d().swipe.right()
time.sleep(3)
d(text='Camera').click.wait()
d(description="Shutter button").wait.exists(timeout=3000)
time.sleep(5)
示例14: runtest
def runtest(serialno, loop, videoname):
if serialno:
from uiautomator import Device
d = Device(serialno)
else:
from uiautomator import device as d
print "总共 %d 次循环" %loop
for i in range(1, loop+1):
print "第 %d 次循环" %i
d.screen.on()
d.press.home()
removeRecentList(d, "File Manager")
d(description="Apps").click()
d(text="File Manager").click()
time.sleep(0.5)
d(text="sdcard").click()
d(text="Movies").click()
d(text=videoname).click()
for i in range(1,20):
x = random.randint(100, 600)
d.click(x, 80)
time.sleep(3)
d.press.back()
d.press.home()
i += 1
print "***** test end ********"
示例15: __pressback
def __pressback(self,c):
for i in range(c):
d.press.back()
if d(text="退出").exists:
d(text="确定",className="android.widget.Button").click()
time.sleep(3)
break