|
|
@@ -6,6 +6,38 @@ import uiautomator2 as u2
|
|
|
from cnocr import CnOcr
|
|
|
|
|
|
|
|
|
+def say_poc(serial):
|
|
|
+ d = u2.connect(serial)
|
|
|
+ d.screen_on()
|
|
|
+ d.unlock()
|
|
|
+ d.debug = False
|
|
|
+
|
|
|
+ d.app_stop("com.instagram.android")
|
|
|
+ d.app_start("com.instagram.android", use_monkey=True)
|
|
|
+ time.sleep(3)
|
|
|
+
|
|
|
+ """搜索"""
|
|
|
+ d.xpath('//*[@resource-id="com.instagram.android:id/search_tab"]/android.widget.ImageView[1]').click(timeout=3)
|
|
|
+ time.sleep(1)
|
|
|
+ d.xpath('//*[@resource-id="com.instagram.android:id/action_bar_search_edit_text"]').click(timeout=3)
|
|
|
+ d(focused=True).set_text('wudejames')
|
|
|
+ time.sleep(3)
|
|
|
+ if d.xpath('//*[@resource-id="com.instagram.android:id/row_search_user_username"]').get_text() == 'wudejames':
|
|
|
+ d.xpath('//*[@resource-id="com.instagram.android:id/row_search_user_username"]').click()
|
|
|
+
|
|
|
+ """发消息"""
|
|
|
+ d.xpath('//*[@text="发消息"]').click(timeout=3)
|
|
|
+
|
|
|
+ """如果存在弹出框"""
|
|
|
+ if d.xpath('//*[@resource-id="com.instagram.android:id/bb_primary_action"]').exists:
|
|
|
+ d.xpath('//*[@resource-id="com.instagram.android:id/bb_primary_action"]').click(timeout=3)
|
|
|
+
|
|
|
+ d.xpath('//*[@resource-id="com.instagram.android:id/row_thread_composer_edittext"]').click(timeout=3)
|
|
|
+ time.sleep(1)
|
|
|
+ d(focused=True).set_text('Good evening')
|
|
|
+ d.xpath('//*[@resource-id="com.instagram.android:id/row_thread_composer_send_button_icon"]').click(timeout=3)
|
|
|
+
|
|
|
+
|
|
|
def spider_poc(serial):
|
|
|
d = u2.connect(serial)
|
|
|
d.screen_on()
|
|
|
@@ -62,4 +94,4 @@ def spider_poc(serial):
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
- spider_poc("5D7HSG5XXCKVBI85")
|
|
|
+ say_poc("5D7HSG5XXCKVBI85")
|