| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623 |
- """
- 启动app
- """
- def start_app(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto", timeout=10, sleep_time=3):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "start_app",
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 关闭app
- """
- def stop_app(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto", timeout=10, sleep_time=10):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "stop_app",
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 根据控件id单击
- """
- def single_click_by_control(request_id, target_app="dongchedi",
- target_version="7.9.0",
- package_name="com.ss.android.auto",
- control_ids="",
- control_id="com.ss.android.auto:id/c7p",
- item_index=None,
- sub_item_index=None,
- timeout=10, sleep_time=10):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "click",
- "type": "1",
- "control_id": control_id,
- "control_ids": control_ids,
- "item_index": item_index,
- "sub_item_index": sub_item_index,
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 根据控件id单击
- """
- def single_click_by_control_exact(request_id, target_app="dongchedi",
- target_version="7.9.0",
- package_name="com.ss.android.auto",
- control_ids="",
- control_id="com.ss.android.auto:id/c7p",
- item_index=None,
- sub_item_index=None,
- timeout=10, sleep_time=10):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "exact_click",
- "type": "1",
- "control_id": control_id,
- "control_ids": control_ids,
- "item_index": item_index,
- "sub_item_index": sub_item_index,
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 根据屏幕位置点击多次
- """
- def many_click_by_position(request_id, target_app="dongchedi",
- target_version="7.9.0",
- package_name="com.ss.android.auto",
- position="center",
- count=5,
- timeout=10, sleep_time=10):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "many_click",
- "type": "1",
- "position": position,
- "count": count,
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- '''
- 根据文本单击
- '''
- def single_click_by_text(request_id, target_app="dongchedi", target_version="7.9.0", sleep_time=10,
- package_name="com.ss.android.auto", text="车友圈", timeout=10, similarity=1, max_page="5"):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "click",
- "type": "2",
- "control_text": text,
- "timeout": timeout,
- "sleep_time": sleep_time,
- "similarity": similarity,
- "max_page": max_page
- }
- }
- }
- return data
- """
- 通过图片识别后单击
- """
- def single_click_by_pic(request_id, target_app="dongchedi", target_version="7.9.0", sleep_time=10,
- package_name="com.ss.android.auto", base64_pic="data:image/gif;base64,"
- "R0lGODlhHAAmAKIHAKqqqsvLy0hISObm5vf394uLiwAAAP///yH5BEoqQqJKAIBaQOVKHAXr3t7txgBjboSvB8EpLoFZywOAo3LFE5lYs/QW9LT1TRk1V7S2xYJADs=",
- timeout=10):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "click",
- "type": "3",
- "base64_pic": base64_pic,
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- '''
- 滑动手机屏幕的百分比
- '''
- def swipe_screen(request_id, target_app="dongchedi", target_version="7.9.0", package_name="com.ss.android.auto",
- scale=0.5, timeout=10, sleep_time=10, direction="up", scale_from=None, scale_to=None, duration=None):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "swipe",
- "timeout": timeout,
- "direction": direction,
- "scale": scale,
- "sleep_time": sleep_time,
- "scaleFrom": scale_from,
- "scaleTo": scale_to,
- "duration": duration
- }
- }
- }
- return data
- '''
- 连续滑动手机屏幕的百分比
- '''
- def continual_swipe_screen(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto",
- scale=0.5, timeout=10, sleep_time=10, direction="up", continuous_time=None,
- continuous_time_interval=None, continuous_count=None):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "swipe",
- "timeout": timeout,
- "direction": direction,
- "scale": scale,
- "sleep_time": sleep_time,
- # 持续时间 单位:s
- "continuous_time": continuous_time,
- # 睡眠时间区间(传输一个string类型 区间首尾使用,分割。eg:'3,50')
- "sleep_time_interval": continuous_time_interval,
- # 持续次数与continuous_time互斥 都传以continuous_time为主
- "continuous_count": continuous_count
- }
- }
- }
- return data
- '''
- 根据控件id长按某个控件
- '''
- def long_press_by_control(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto",
- control_id="com.ss.android.auto:id/c7d", timeout=10, sleep_time=10):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "long_press",
- "control_id": control_id,
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 根据控件id输入文本(包括emoj表情)
- """
- def send_text_by_control(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto", control_id="com.ss.android.auto:id/cg",
- content="文章不错,写的很好👍", timeout=10, sleep_time=10, item_index=None):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "send_text",
- "control_id": control_id,
- "text": content,
- "timeout": timeout,
- "sleep_time": sleep_time,
- "item_index": item_index
- }
- }
- }
- return data
- """
- 根据控件id获取内容
- 如果id/帖子正文内容未获取到 接口返回eleNotFound,包含点击操作
- :param
- type - 1- 帖子正文内容 2- 控件id的文本
- """
- """
- """
- def get_content_by_control(request_id, target_app="dongchedi", target_version="7.9.0", operator_type=1, max_page="10",
- package_name="com.ss.android.auto", control_id="com.ss.android.auto:id/cg",
- timeout=10, sleep_time=10, title="听说24年不送绿牌"):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "spider_content",
- "type": operator_type,
- "title": title,
- "max_page": max_page,
- "control_id": control_id,
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 先下滑若干屏幕
- 然后根据匹配到的文本点击
- """
- def click_by_content(request_id, target_app="dongchedi", target_version="7.9.0", max_page="10", operator_type=1,
- package_name="com.ss.android.auto", timeout=10, sleep_time=10, title="听说24年不送绿牌"):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "spider_content",
- "title": title,
- "type": operator_type,
- "max_page": max_page,
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 根据图片判断页面图片是否存在
- """
- def check_pic_exist(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto",
- pic_base64="com.ss.android.auto:id/c7p", timeout=10, sleep_time=10, direction="up", swipe_count=0):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "check_pic",
- "type": "1",
- "pic_base64": pic_base64,
- "timeout": timeout,
- "sleep_time": sleep_time,
- # (默认up。up 向上滑动(及屏幕向下翻取),down向下滑动(及屏幕向上翻取))
- "direction": direction,
- # 滑动次数(默认0 不滑动)
- "swipe_count": swipe_count
- }
- }
- }
- return data
- """
- 根据图片进行点击
- """
- def click_pic(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto",
- pic_base64="com.ss.android.auto:id/c7p", timeout=10, sleep_time=10):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "click_pic",
- "type": "1",
- "pic_base64": pic_base64,
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 操作失败
- """
- def operation_fail(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto", step="action0"):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "step": step
- }
- }
- }
- return data
- """
- 返回上一页
- """
- def back_last_page(request_id, target_app="dongchedi", target_version="7.9.0", package_name="com.ss.android.auto",
- sleep_time=10,
- timeout=10):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "back",
- "timeout": timeout,
- "sleep_time": sleep_time
- }
- }
- }
- return data
- """
- 根据元素id获取到对应text信息
- text信息返回在下一次调用接口result中的performActionText字段返回
- """
- def get_text_by_control(request_id, target_app="dongchedi", target_version="7.9.0", max_page="10",
- package_name="com.ss.android.auto", control_id="com.ss.android.auto:id/cg",
- timeout=10, sleep_time=10, item_index=None, sub_item_index=None):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "spider_text_get",
- # 最大下滑页
- "max_page": max_page,
- "control_id": control_id,
- "timeout": timeout,
- "sleep_time": sleep_time,
- "item_index": item_index,
- "sub_item_index": sub_item_index
- }
- }
- }
- return data
- """
- 根据元素id获取到对应text信息
- text信息返回在下一次调用接口result中的performActionText字段返回
- """
- def get_text_by_control_comment(request_id, target_app="dongchedi", target_version="7.9.0", max_page="10",
- package_name="com.ss.android.auto", control_id="com.ss.android.auto:id/cg",
- timeout=10, sleep_time=10, item_index=None, sub_item_index=None):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "spider_text_list_get",
- # 最大下滑页
- "max_page": max_page,
- "control_id": control_id,
- "timeout": timeout,
- "sleep_time": sleep_time,
- "item_index": item_index,
- "sub_item_index": sub_item_index
- }
- }
- }
- return data
- '''
- 根据text 点击对应的子元素id
- '''
- def spider_content_parent_find_click(request_id, target_app="dongchedi", target_version="7.9.0",
- package_name="com.ss.android.auto", title=None,
- child_control_id=None, timeout=10, sleep_time=10, item_index=None):
- data = {
- "jsonrpcVersion": "2.0",
- "id": request_id,
- "type": "scenes",
- "target_app": target_app,
- "package_name": package_name,
- "target_version": target_version,
- "params": {
- "action": {
- "method": "spider_content_parent_find_click",
- "child_control_id": child_control_id,
- "timeout": timeout,
- "title": title,
- "item_index": item_index,
- "sleep_time": sleep_time
- }
- }
- }
- return data
|