from pytestreport import TestRunner
import uiautomator2 as u2
import email
import os
import smtplib
import random
import re
import logging
import time
import config
from time import sleep
#from resource.baidumap import BaiduMap
import unittest
#from util import Action, UIChecker, Judge, Common
#from resource import basemap
#from util.DuerOSHelper.interface_element import ElementUse
#from config import case
from email.mime.application import MIMEApplication
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
#from case_ford_phase4_CX727 import map
#from map import test_mapauto
time_now = time.strftime(’%Y%m%d_%H%M%S’, time.localtime())
def get_deviceid():
‘’‘获取设备号’’’
listdevice = ’ ’
command = os.popen(‘adb devices’).readlines()
for i in range(len(command)):
listdevice += command[i]
devices_name = re.findall(’\n(.+?)\t’, listdevice, re.S)
return devices_name
listname = get_deviceid()
deviceid = ‘’.join(listname)
d = u2.connect_usb(deviceid)
#@case.attrs(package_name=ElementUse().codriver_package_name)
class TestStringMethods(unittest.TestCase):
# def setUp(self):
# """
# 每个测试用例执行之前做操作"""
# Action.clearLog()
# # Action.adb_cmd("adb shell pm clear com.baidu.naviauto")
# # Action.adb_cmd("adb shell am start -n com.baidu.naviauto/.NaviAutoActivity")
# # Judge.passIf(self,
# # UIChecker.checkByPackageNameWait("com.baidu.naviauto"), "启动地图,fail"
# # )
# d.app_start("com.baidu.naviauto")
#
# def tearDown(self):
# """
# 每个测试用例执行之后做操作"""
# # Action.adb_cmd("adb shell pm clear com.baidu.naviauto")
# # Action.adb_cmd("adb shell am force-stop com.baidu.naviauto")
# d.app_stop("com.baidu.naviauto")
def click_message_page(self):
'''首页初始化'''
time.sleep(3)
d.app_start("com.baidu.naviauto")
if d(text="接受").wait(timeout=10):
d(text="接受").click()
time.sleep(10)
if d(text="是否继续上次导航?").wait(timeout=5):
d(text="取消").click()
time.sleep(2)
# os.popen('start /b adb logcat -v -d threadtime > /Users/v_wangjiwei01/Desktop/autolog/')
def test_onlineCalculation_searchPages(self):
'''搜索页的在线算路'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击历史记录第一条")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_lion_search"]/android.widget.FrameLayout[1]/'
'android.widget.LinearLayout[1]/android.widget.LinearLayout[2]').click()
# if d(resourceId="com.baidu.naviauto:id/lion_map_poi_panel_right_distance_layout").exists(timeout=2):
# time.sleep(1)
# d(resourceId="com.baidu.naviauto:id/lion_map_poi_panel_right_distance_layout").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
# if d(resourceId="com.baidu.naviauto:id/lion_map_poi_panel_right_phone_layout").exists(timeout=2):
# time.sleep(1)
# d(resourceId="com.baidu.naviauto:id/ll_poi_back").click()
logging.info("途径点")
d(resourceId="com.baidu.naviauto:id/ib_lion_search_add").click()
d(text="输入途经点").click()
time.sleep(2)
d(text="输入途经点").send_keys("欢乐谷")
d(text="搜索").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]').click()
d(text="搜索").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("收藏夹")
d(text="输入目的地").click()
d(text="收藏夹").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]'
'/android.widget.LinearLayout[3]').click() # 点击列表第一个地址
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/iv_left").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("地图选点")
d.long_click(550, 860) # 地图选点
d(resourceId="com.baidu.naviauto:id/lion_map_poi_panel_right_distance_layout").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/ll_poi_back").click()
time.sleep(3)
logging.info("语音")
os.popen("adb shell am broadcast -a duerosrun -n com.baidu.che.codriver/"
"com.baidu.che.codriver.debug.QueryReceiver --es enQuery 导航到天安门")
time.sleep(5)
d(resourceId="com.baidu.che.codriver:id/v_BaiduMic").exists(timeout=6)
os.popen("adb shell am broadcast -a duerosrun -n com.baidu.che.codriver/"
"com.baidu.che.codriver.debug.QueryReceiver --es enQuery 第一个")
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_onlineCalculation_searchPages_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_onlineCalculation_searchPages_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_offlineCalculation_searchPages(self):
'''搜索页的离线算路'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
d(scrollable=True).scroll(steps=10)
logging.info("关闭在线算路优先")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/bt_routplan_mode"]/android.widget.LinearLayout[1]/'
'android.widget.RadioGroup[1]/android.widget.RadioButton[2]').click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击历史记录第一条")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_lion_search"]/android.widget.FrameLayout[1]/'
'android.widget.LinearLayout[1]/android.widget.LinearLayout[2]').click()
d(resourceId="com.baidu.naviauto:id/lion_map_poi_panel_right_distance_layout").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/ll_poi_back").click()
logging.info("途径点")
d(resourceId="com.baidu.naviauto:id/ib_lion_search_add").click()
d(text="输入途经点").click()
time.sleep(2)
d(text="输入途经点").send_keys("欢乐谷")
d(text="搜索").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]').click()
d(text="搜索").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
# d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("收藏夹")
d(text="输入目的地").click()
d(text="收藏夹").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]'
'/android.widget.LinearLayout[3]').click() # 点击列表第一个地址
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/iv_left").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("地图选点")
d.long_click(550, 860) # 地图选点
d(resourceId="com.baidu.naviauto:id/lion_map_poi_panel_right_distance_layout").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/ll_poi_back").click()
time.sleep(3)
logging.info("语音")
os.popen("adb shell am broadcast -a duerosrun -n com.baidu.che.codriver/"
"com.baidu.che.codriver.debug.QueryReceiver --es enQuery 导航到天安门")
time.sleep(5)
d(resourceId="com.baidu.che.codriver:id/v_BaiduMic").exists(timeout=6)
time.sleep(3)
os.popen("adb shell am broadcast -a duerosrun -n com.baidu.che.codriver/"
"com.baidu.che.codriver.debug.QueryReceiver --es enQuery 第一个")
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_offlineCalculation_searchPages_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_offlineCalculation_searchPages_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_goHome_goCompany(self):
'''回家、去公司'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
d(scrollable=True).scroll(steps=10)
logging.info("打开在线算路优先")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/bt_routplan_mode"]/android.widget.LinearLayout[1]/'
'android.widget.RadioGroup[1]/android.widget.RadioButton[1]').click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="回家").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(text="去公司").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
d(scrollable=True).scroll(steps=10)
logging.info("关闭在线算路优先")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/bt_routplan_mode"]/android.widget.LinearLayout[1]/'
'android.widget.RadioGroup[1]/android.widget.RadioButton[2]').click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="回家").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="去公司").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_goHome_goCompany_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_goHome_goCompany_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_search_cityName(self):
'''搜索poi出现poi列表,点击后发起算路'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
d(scrollable=True).scroll(steps=10)
logging.info("打开在线算路优先")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/bt_routplan_mode"]/android.widget.LinearLayout[1]/'
'android.widget.RadioGroup[1]/android.widget.RadioButton[1]').click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("天津")
d(text="搜索").click()
d(text="1. 天津市").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/btn_poi_gonavi").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/ll_search_result_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
d(scrollable=True).scroll(steps=10)
logging.info("关闭在线算路优先")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/bt_routplan_mode"]/android.widget.LinearLayout[1]/'
'android.widget.RadioGroup[1]/android.widget.RadioButton[2]').click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("天津")
d(text="搜索").click()
d(text="1. 天津市").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/btn_poi_gonavi").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/ll_search_result_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_search_cityName_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_search_cityName_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_city_calculateRoad(self):
'''市内算路'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
d(scrollable=True).scroll(steps=10)
logging.info("打开在线算路优先")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/bt_routplan_mode"]/android.widget.LinearLayout[1]/'
'android.widget.RadioGroup[1]/android.widget.RadioButton[1]').click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
time.sleep(2)
d(text="输入目的地").send_keys("香山")
d(text="搜索").click()
d(text="1. 香山公园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/ll_search_result_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
d(scrollable=True).scroll(steps=10)
logging.info("关闭在线算路优先")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/bt_routplan_mode"]/android.widget.LinearLayout[1]/'
'android.widget.RadioGroup[1]/android.widget.RadioButton[2]').click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("香山")
d(text="搜索").click()
d(text="1. 香山公园").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/btn_poi_gonavi").click()
d(text="开始导航").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/iv_back").click()
d(resourceId="com.baidu.naviauto:id/ll_search_result_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_city_calculateRoad_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_city_calculateRoad_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_no_high_speed(self):
'''不走高速算路'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
d(scrollable=True).scroll(steps=10)
logging.info("打开在线算路优先")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/bt_routplan_mode"]/android.widget.LinearLayout[1]/'
'android.widget.RadioGroup[1]/android.widget.RadioButton[1]').click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
logging.info("设置偏好")
d(text="偏好").click()
d(text="不走高速").click()
time.sleep(3)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_no_high_speed_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_no_high_speed_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_high_speed_priority(self):
'''高速优先算路'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
logging.info("设置偏好")
d(text="偏好").click()
d(text="高速优先").click()
time.sleep(3)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_high_speed_priority_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_high_speed_priority_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_avoid_congestion(self):
'''躲避拥堵算路'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
logging.info("设置偏好")
d(text="偏好").click()
d(text="躲避拥堵").click()
time.sleep(3)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_avoid_congestion_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_avoid_congestion_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_priority_time(self):
'''时间优先算路'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
logging.info("设置偏好")
d(text="偏好").click()
d(text="时间优先").click()
time.sleep(3)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_priority_time_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_priority_time_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_intelligent_recommendation(self):
'''智能推荐算路'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
logging.info("设置偏好")
d(text="偏好").click()
d(text="智能推荐").click()
time.sleep(3)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_intelligent_recommendation_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_intelligent_recommendation_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_selectionPage_detailsPage_information(self):
'''路线选择页路线信息与路线详情页信息一致'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]').click()
d(text="1.北京野生动物园").exists(timeout=3)
d(resourceId="com.baidu.naviauto:id/ll_poi_back").click()
d(resourceId="com.baidu.naviauto:id/ll_search_result_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_selectionPage_detailsPage_information_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_selectionPage_detailsPage_information_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_openClose_naviSound(self):
'''开启/关闭导航声音'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("点击底图")
d.click(1150, 640)
logging.info("点击关闭导航声音")
d(resourceId="com.baidu.naviauto:id/bnav_rg_cp_voice_iv").click()
time.sleep(3)
# logging.info("抓取语音播报log")
# os.popen(f'adb -s {deviceid} logcat -t 10000 threadtime > /wjw/project-work/auto_framework/log/speech.txt')
# logging.info("查找文件中的已关闭导航关键词")
logging.info("点击底图")
d.click(1150, 640)
logging.info("点击开启导航声音")
d(resourceId="com.baidu.naviauto:id/bnav_rg_cp_voice_iv").click()
time.sleep(2)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_openClose_naviSound_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_openClose_naviSound_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_route_preference(self):
'''路线偏好(智能推荐/时间邮件/距离优先/躲避拥堵/不走高速/高速优先都可切换成功,且离线不能切换)'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
preference = ['智能推荐', '时间优先', '少收费', '躲避拥堵', '不走高速', '高速优先']
for i in preference:
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
logging.info("设置偏好")
d(text="偏好").click()
d(text=i).click()
time.sleep(3)
logging.info("关闭网络")
os.popen('adb shell svc wifi disable')
time.sleep(2)
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
logging.info("设置偏好")
d(text="偏好").click()
if d(text="智能推荐").exists(timeout=2):
return False
else:
pass
os.popen('adb shell svc wifi enable')
time.sleep(5)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_route_preference_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_route_preference_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_incident_reporting(self):
'''事件上报'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
incident_list = ["事故", "拥堵", "危险", "修路", "封路", "道路报错"]
for incident in incident_list:
logging.info("点击底图任意位置")
d.click(1340, 770)
time.sleep(1)
logging.info("点击事件上报按键")
d(resourceId="com.baidu.naviauto:id/bnav_rg_cp_iv_ugc_report").click()
time.sleep(1)
logging.info("点击事件")
d(text=incident).click()
time.sleep(1)
logging.info("点击上报按键")
d(resourceId="com.baidu.naviauto:id/navi_common_dialog_submit").click()
d(text="感谢您的反馈!").exists(timeout=5)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_incident_reporting_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_incident_reporting_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_searchAlong_theWay(self):
'''沿途搜'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
way_list = ["加油站", "充电站", "厕所", "银行ATM", "酒店住宿", "旅游景点"]
for route_search in way_list:
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="沿途搜").click()
d(text=route_search).click()
d(text="清空结果并继续导航").exists(timeout=5)
d(text="清空结果并继续导航").click()
time.sleep(1)
logging.info("关闭网络")
os.popen('adb shell svc wifi disable')
time.sleep(2)
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="沿途搜").click()
if d(text="加油站").exists(timeout=3):
return False
logging.info("打开网络")
os.popen('adb shell svc wifi enable')
time.sleep(2)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_searchAlong_theWay_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_searchAlong_theWay_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_global_mode_switch(self):
'''全览模式切换'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
logging.info("点击全览小窗")
d(text="全览小窗").click()
if d(resourceId="com.baidu.naviauto:id/bnav_rg_cp_fullview_mode_btn").exists(timeout=3):
pass
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
logging.info("点击路况条")
d(text="路况条").click()
if d(resourceId="com.baidu.naviauto:id/bnav_rg_cp_map_switch").exists(timeout=3):
pass
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_global_mode_switch_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_global_mode_switch_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_page_display(self):
'''导航语音页面显示'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
logging.info("点击导航语音")
d(text="导航语音").click()
logging.info("查看UI展示")
if d(text="导航语音").exists(timeout=3):
pass
voicelist = ['普通话', '粤语导航语音', 'angel萌', '百度CEO 李彦宏', '萌萌哒']
for i in voicelist:
if d(text=i).exists(timeout=3):
pass
if d(resourceId="com.baidu.naviauto:id/btnBack").exists(timeout=3):
pass
logging.info("切换语音")
if d(text="使用").exists(timeout=2):
pass
else:
d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_voice"]/android.widget.LinearLayout[2]/'
'android.widget.RelativeLayout[1]/android.widget.ImageView[1]').click()
d(text="使用").exists(timeout=10)
d(text="普通话").click()
d(text="取消").exists(timeout=5)
d(text="粤语导航语音").long_click()
d(text="确定").click()
time.sleep(2)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
os.popen("adb shell input keyevent 4")
d(text="退出导航").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_page_display_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_page_display_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_clickAgree_disclaimerPage(self):
'''免责声明页点击同意'''
try:
logging.info("打开导航")
d.app_start("com.baidu.naviauto")
d(text="接受").click()
logging.info("导航界面")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").exists(timeout=5)
os.popen("adb shell input keyevent 4")
d(text="退出导航").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_clickAgree_disclaimerPage_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_clickAgree_disclaimerPage_{time_now}.txt')
print(e)
return False
return True
def test_clickNoAgree_disclaimerPage(self):
'''免责声明页点击不同意'''
try:
logging.info("打开导航")
d.app_start("com.baidu.naviauto")
d(text="拒绝").click()
logging.info("home界面")
d(text="百度地图").exists(timeout=5)
time.sleep(5)
except Exception as e:
d.screenshot(f'test_clickNoAgree_disclaimerPage_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_clickNoAgree_disclaimerPage_{time_now}.txt')
print(e)
return False
return True
def test_set_home_address(self):
'''设置家地址'''
try:
logging.info("打开导航")
d.app_start("com.baidu.naviauto")
d(text="接受").click()
logging.info("导航界面")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").exists(timeout=5)
time.sleep(2)
logging.info("语音唤醒指令")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 设置家地址')
d(text="请说出您家的地址").exists(timeout=10)
time.sleep(2)
logging.info("语音输入:世界之窗")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 世界之窗')
d(text="已设置成功,将为您发起导航").exists(timeout=10)
time.sleep(2)
d(resourceId="com.baidu.che.codriver:id/voice_shut_down_button").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_set_home_address_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_set_home_address_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_set_company_address(self):
'''设置公司地址'''
try:
self.click_message_page()
logging.info("语音唤醒指令")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 小度小度,设置公司地址')
d(text="请说出您公司的地址").exists(timeout=10)
logging.info("语音输入:百度大厦")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 百度大厦')
d(text="已设置成功,将为您发起导航").exists(timeout=10)
d(resourceId="com.baidu.che.codriver:id/voice_shut_down_button").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_set_home_address_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_set_home_address_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_switch_browse_mode(self):
'''语音切换全览模式'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("语音唤醒指令")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 查看全程')
time.sleep(5)
# logging.info("检查语音已展示路线全览")
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_switch_browse_mode_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_switch_browse_mode_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_input_keywords(self):
'''输入关键字'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
logging.info("显示X按钮和搜索按钮")
d(resourceId="com.baidu.naviauto:id/relative_lion_search_delete").exists(timeout=3)
d(text="搜索").exists(timeout=3)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(5)
except Exception as e:
d.screenshot(f'test_input_keywords_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_input_keywords_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_keyword_search(self):
'''关键字搜索'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
time.sleep(2)
d(text="输入目的地").send_keys("动物园")
d(text="搜索").click()
logging.info("进入POI列表页")
d(resourceId="com.baidu.naviauto:id/btn_poi_gonavi").exists(timeout=8)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(5)
except Exception as e:
d.screenshot(f'test_keyword_search_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_keyword_search_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_click_sug_search(self):
'''点击sug开始搜索'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
time.sleep(2)
d(text="输入目的地").send_keys("北京野生动物园")
logging.info("点击sug开始搜索")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_lion_search"]/'
'android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').click()
d(resourceId="com.baidu.naviauto:id/lion_map_poi_panel_right_phone_layout").exists(timeout=5)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(5)
except Exception as e:
d.screenshot(f'test_click_sug_search_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_click_sug_search_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_passing_point_icon(self):
'''搜索页点击添加途经点图标'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击添加途径点图标")
d(resourceId="com.baidu.naviauto:id/ib_lion_search_add").click()
logging.info("途径点页面")
d(text="输入途经点").exists(timeout=3)
d(text="输入目的地").exists(timeout=3)
d(text="搜索").exists(timeout=3)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(5)
except Exception as e:
d.screenshot(f'test_passing_point_icon_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_passing_point_icon_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_routePoint_inputDestination(self):
'''途径点点击输入目的地的输入框,进入目的地的输入页面'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击添加途径点图标")
d(resourceId="com.baidu.naviauto:id/ib_lion_search_add").click()
logging.info("途径点页面")
d(text="输入目的地").click()
d(text="更多").exists(timeout=3)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(5)
except Exception as e:
d.screenshot(f'test_routePoint_inputDestination_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_routePoint_inputDestination_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_team_management(self):
'''队员队伍管理'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="组队出行").click()
logging.info("创建队伍")
d(text="创建队伍").click()
d(text="我的队伍").exists(timeout=10)
logging.info("点击右上角管理按钮")
d(resourceId="com.baidu.naviauto:id/ib_team_manage").click()
d(text="管理").exists(timeout=2)
d(text="车队名称").exists(timeout=2)
d(text="我的昵称").exists(timeout=2)
d(resourceId="com.baidu.naviauto:id/tv_expire_time").exists(timeout=2)
logging.info("解散队伍")
d(text="解散队伍").click()
d(text="确认").click()
time.sleep(5)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_team_management_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_team_management_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_team_name_modification(self):
'''队名修改'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="组队出行").click()
logging.info("创建队伍")
d(text="创建队伍").click()
d(text="我的队伍").exists(timeout=10)
logging.info("点击右上角管理按钮")
d(resourceId="com.baidu.naviauto:id/ib_team_manage").click()
d(resourceId="com.baidu.naviauto:id/custom_editable_operate").click()
d(resourceId="com.baidu.naviauto:id/custom_editable_content").clear_text()
d(resourceId="com.baidu.naviauto:id/custom_editable_content").send_keys("123")
os.popen('adb shell input keyevent 4')
time.sleep(5)
logging.info("解散队伍")
d(text="解散队伍").click()
d(text="确认").click()
time.sleep(5)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_team_name_modification_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_team_name_modification_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_favorites_set_company_address(self):
'''设置公司地址'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击收藏夹")
d(text="收藏夹").click()
if not d(text="点击设置").exists(timeout=2):
d(resourceId="com.baidu.naviauto:id/ib_right").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/android.widget.LinearLayout[2]/'
'android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').click()
d.press("back")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/'
'android.widget.LinearLayout[2]/android.widget.LinearLayout[1]').click()
time.sleep(2)
d(text="输入目的地").send_keys("北京欢乐谷")
d(text="搜索").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/'
'android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]').click()
d(resourceId="com.baidu.naviauto:id/ib_right0").exists(timeout=5)
time.sleep(2)
logging.info("点击公司地址发起导航")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/'
'android.widget.LinearLayout[2]/android.widget.LinearLayout[1]').click()
d(text="添加途经点").exists(timeout=10)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_favorites_set_company_address_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_favorites_set_company_address_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_favorites_set_home_address(self):
'''设置家地址'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击收藏夹")
d(text="收藏夹").click()
if not d(text="点击设置").exists(timeout=2):
d(resourceId="com.baidu.naviauto:id/ib_right").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/android.widget.LinearLayout[1]/'
'android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').click()
d.press("back")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/'
'android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').click()
time.sleep(2)
d(text="输入目的地").send_keys("天安门")
d(text="搜索").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/'
'android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]').click()
d(resourceId="com.baidu.naviauto:id/ib_right0").exists(timeout=5)
time.sleep(2)
logging.info("点击家地址发起导航")
time.sleep(5)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/'
'android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').click()
d(text="添加途经点").exists(timeout=10)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_favorites_set_home_address_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_favorites_set_home_address_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_favorites_del_home_address(self):
'''删除家地址'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击收藏夹")
d(text="收藏夹").click()
logging.info("点击编辑按键")
d(resourceId="com.baidu.naviauto:id/ib_right").click()
logging.info("点击删除")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/android.widget.LinearLayout[1]/'
'android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').click()
time.sleep(2)
d(text="完成").click()
time.sleep(2)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_favorites_del_home_address_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_favorites_del_home_address_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_favorites_del_company_address(self):
'''删除公司地址'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击收藏夹")
d(text="收藏夹").click()
logging.info("点击编辑按键")
d(resourceId="com.baidu.naviauto:id/ib_right").click()
logging.info("点击删除")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/android.widget.LinearLayout[2]/'
'android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]').click()
time.sleep(2)
d(text="完成").click()
time.sleep(2)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_favorites_del_company_address_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_favorites_del_company_address_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_del_favorites_address(self):
'''删除收藏地址'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("点击收藏夹")
d(text="收藏夹").click()
logging.info("点击编辑按键")
d(resourceId="com.baidu.naviauto:id/ib_right").click()
logging.info("删除收藏地址")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_list_view"]/'
'android.widget.LinearLayout[3]/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(3)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_del_favorites_address_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_del_favorites_address_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report(self):
'''泛需求-我要上报'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 我要上报')
d(text="请选择一种类型进行上报,你需要选择第几个?").exists(timeout=5)
time.sleep(2)
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 第一个')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report5(self):
'''泛需求-我要上报-施工多轮'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 我要上报')
d(text="请选择一种类型进行上报,你需要选择第几个?").exists(timeout=5)
time.sleep(2)
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 第五个')
time.sleep(2)
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 第一个')
# d(resourceId="com.baidu.che.codriver:id/voice_shut_down_button").click()
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report5_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report5_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report1(self):
'''精准需求-单槽位-上报拥堵'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 上报拥堵')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report1_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report1_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report2(self):
'''精准需求-单槽位-上报危险'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 上报危险')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report2_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report2_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report3(self):
'''精准需求-单槽位-上报路上有障碍物'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 上报路上有障碍物')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report3_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report3_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report4(self):
'''精准需求-单槽位-路上有积水'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 路上有积水')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report4_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report4_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report6(self):
'''精准需求-单槽位-火灾上报'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 火灾上报')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report6_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report6_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report7(self):
'''精准需求-单槽位-有车辆逆行'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 有车辆逆行')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report7_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report7_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report8(self):
'''精准需求-单槽位-路上有人'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 路上有人')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report8_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report8_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report9(self):
'''精准需求-单槽位-路上有动物'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 路上有动物')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report9_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report9_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report10(self):
'''精准需求-单槽位-发现路上有东西'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 发现路上有东西')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report10_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report10_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report11(self):
'''精准需求-单槽位-发现危险驾驶'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 发现危险驾驶')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report11_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report11_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report12(self):
'''精准需求-单槽位-发现危险驾驶'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 上报事故')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report12_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report12_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report13(self):
'''精准需求-单槽位-路上施工'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 路上施工')
time.sleep(3)
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 第一个')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report13_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report13_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report14(self):
'''精准需求-单槽位-封路了'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 封路了')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report14_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report14_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report15(self):
'''精准需求-多槽位-前方拥堵'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方拥堵')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report15_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report15_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report17(self):
'''精准需求-多槽位-前方有危险'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方有危险')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report17_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report17_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report18(self):
'''精准需求-多槽位-前方有障碍物'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方有障碍物')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report18_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report18_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report19(self):
'''精准需求-多槽位-前方有积水'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方有积水')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report19_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report19_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report20(self):
'''精准需求-多槽位-前方有火灾'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方有火灾')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report20_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report20_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report21(self):
'''精准需求-多槽位-前方有车辆逆行'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方有车辆逆行')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report21_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report21_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report22(self):
'''精准需求-多槽位-前方路上有人'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方路上有人')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report22_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report22_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report23(self):
'''精准需求-多槽位-前方路上有动物'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方路上有动物')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report23_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report23_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report24(self):
'''精准需求-多槽位-前方有危险驾驶'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方有危险驾驶')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report24_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report24_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report25(self):
'''精准需求-多槽位-前方有事故'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方有事故')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report25_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report25_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report26(self):
'''精准需求-多槽位-前方施工'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方施工')
time.sleep(3)
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 第一个')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report26_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report26_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_i_want_report27(self):
'''精准需求-多槽位-前方封路'''
try:
self.click_message_page()
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 前方封路')
d(text="上报成功,感谢你的反馈,我们会尽快处理的").exists(timeout=5)
time.sleep(10)
except Exception as e:
d.screenshot(f'test_i_want_report27_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_i_want_report27_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_delete_voice_package(self):
'''删除语音包'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
logging.info("点击导航语音")
d(text="导航语音").click()
logging.info("下载多个语音包")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_voice"]/'
'android.widget.LinearLayout[2]/android.widget.RelativeLayout[1]/android.widget.ImageView[1]').click()
time.sleep(1)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_voice"]/'
'android.widget.LinearLayout[5]/android.widget.RelativeLayout[1]/android.widget.ImageView[1]').click()
d(text="使用").exists(timeout=10)
time.sleep(2)
logging.info("删除正在下载中的语音包")
d(text="萌萌哒").long_click()
d(text="确定").click()
time.sleep(2)
d(text="普通话").click()
d(text="取消").exists(timeout=5)
d(text="粤语导航语音").long_click()
d(text="确定").click()
time.sleep(2)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_delete_voice_package_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_delete_voice_package_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_download_voice_package(self):
'''正常网络下,各类都能正常下载完成,语音使用正常'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
logging.info("点击导航语音")
d(text="导航语音").click()
logging.info("下载所有语音包")
d(text="粤语导航语音").click()
d(text="使用")[0].exists(timeout=120)
time.sleep(2)
d(text="angel萌").click()
d(text="使用")[1].exists(timeout=120)
time.sleep(2)
d(text="百度CEO 李彦宏").click()
d(text="使用")[2].exists(timeout=120)
time.sleep(2)
d(text="萌萌哒").click()
d(text="使用")[3].exists(timeout=120)
time.sleep(2)
logging.info("删除所有下载语音包")
d(text="普通话").click()
time.sleep(2)
d(text="粤语导航语音").long_click()
d(text="确定").click()
time.sleep(2)
d(text="angel萌").long_click()
d(text="确定").click()
time.sleep(2)
d(text="百度CEO 李彦宏").long_click()
d(text="确定").click()
time.sleep(2)
d(text="萌萌哒").long_click()
d(text="确定").click()
time.sleep(2)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_download_voice_package_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_download_voice_package_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_download_status_display(self):
'''下载语音下载状态显示'''
try:
self.click_message_page()
logging.info("点击个人设置")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="导航设置").click()
logging.info("点击导航语音")
d(text="导航语音").click()
logging.info("下载语音包")
d(text="萌萌哒").click()
logging.info("下载进度条")
d(resourceId="com.baidu.naviauto:id/voice_pb").exists(timeout=3)
logging.info("删除语音包")
d(text="萌萌哒").long_click()
d(text="确定").click()
time.sleep(2)
d.press("back")
time.sleep(1)
d.press("back")
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_download_status_display_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_download_status_display_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_preference_message_notification(self):
'''导航中设置为不同的偏好,出现消息通知'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
preference = ['智能推荐', '时间优先', '少收费', '躲避拥堵', '不走高速', '高速优先']
for i in preference:
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
logging.info("设置偏好")
d(text="偏好").click()
d(text=i).click()
d(text="更改路线偏好,计算路线中").wait_gone(timeout=5)
logging.info("3S后toast消失")
if d(resourceId="com.baidu.naviauto:id/bnav_rg_common_notification_layout").wait_gone(timeout=3):
return False
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_preference_message_notification_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_preference_message_notification_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_searchAlongTheWay_gasStation(self):
'''沿途搜加油站'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(text="输入目的地").send_keys("北京野生动物园")
d(text="搜索").click()
d(text="1. 北京野生动物园").exists(timeout=3)
d.xpath('//*[@resource-id="com.baidu.naviauto:id/lv_search_result"]/android.widget.RelativeLayout[1]/'
'android.widget.RelativeLayout[1]/android.widget.LinearLayout[2]').click()
time.sleep(2)
d.click(220, 900)
d(text="开始导航").exists(timeout=3)
d(text="开始导航").click()
if d(text="沿途搜加油站").exists(timeout=3):
d(resourceId="com.baidu.naviauto:id/img_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="沿途搜").click()
d(text="加油站").click()
logging.info("点击中国石油")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/route_search_filter_brands_recycler_view"]/'
'android.widget.LinearLayout[1]/android.widget.FrameLayout[1]').click()
d(text="沿途搜索中...").wait_gone(timeout=3)
# d(text="清空结果并继续导航").exists(timeout=5)
logging.info("点击中国石化")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/route_search_filter_brands_recycler_view"]/'
'android.widget.LinearLayout[2]').click()
d(text="沿途搜索中...").wait_gone(timeout=3)
d(text="清空结果并继续导航").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_searchAlongTheWay_gasStation_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_searchAlongTheWay_gasStation_{time_now}.txt')
print(e)
return False
return True
def test_searchAlongTheWay_atm(self):
'''沿途搜银行ATM'''
try:
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="沿途搜").click()
d(text="银行ATM").click()
logging.info("点击工商银行")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/route_search_filter_brands_recycler_view"]/'
'android.widget.LinearLayout[1]/android.widget.FrameLayout[1]').click()
d(text="沿途搜索中...").wait_gone(timeout=3)
# d(text="清空结果并继续导航").exists(timeout=5)
logging.info("点击建设银行")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/route_search_filter_brands_recycler_view"]/'
'android.widget.LinearLayout[2]').click()
d(text="沿途搜索中...").wait_gone(timeout=3)
logging.info("点击农业银行")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/route_search_filter_brands_recycler_view"]/'
'android.widget.LinearLayout[3]').click()
d(text="沿途搜索中...").wait_gone(timeout=3)
logging.info("点击中国银行")
d(resourceId="com.baidu.naviauto:id/route_search_end_arrow").click()
d.xpath('//*[@resource-id="com.baidu.naviauto:id/route_search_filter_brands_recycler_view"]/'
'android.widget.LinearLayout[3]').click()
d(text="沿途搜索中...").wait_gone(timeout=3)
d(resourceId="com.baidu.naviauto:id/route_search_start_arrow").click()
d(text="清空结果并继续导航").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_searchAlongTheWay_atm_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_searchAlongTheWay_atm_{time_now}.txt')
print(e)
return False
return True
def test_searchAlongTheWay_chargingStation(self):
'''沿途搜充电站'''
try:
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="沿途搜").click()
d(text="充电站").click()
logging.info("点击国家电网")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/route_search_filter_brands_recycler_view"]/'
'android.widget.LinearLayout[1]/android.widget.FrameLayout[1]').click()
d(text="沿途搜索中...").wait_gone(timeout=3)
# d(text="清空结果并继续导航").exists(timeout=5)
logging.info("点击特来电")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/route_search_filter_brands_recycler_view"]/'
'android.widget.LinearLayout[2]/android.widget.FrameLayout[1]').click()
d(text="沿途搜索中...").wait_gone(timeout=3)
d(text="清空结果并继续导航").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_searchAlongTheWay_chargingStation_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_searchAlongTheWay_chargingStation_{time_now}.txt')
print(e)
return False
return True
def test_searchAlongTheWay_frontBackSwitch(self):
'''搜索完成全览路线时,前后台切换,底图不变化'''
try:
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="沿途搜").click()
d(text="厕所").click()
d(text="沿途搜索中...").wait_gone(timeout=3)
logging.info("点击home键")
d.press("Home")
time.sleep(2)
logging.info("点击地图")
d.app_start("com.baidu.naviauto")
d(text="清空结果并继续导航").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_searchAlongTheWay_frontBackSwitch_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_searchAlongTheWay_frontBackSwitch_{time_now}.txt')
print(e)
return False
return True
def test_auto_day_nightMode(self):
'''自动模式/白天模式/黑夜模式'''
try:
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="更多").click()
logging.info("切换夜间模式")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/navi_night_mode_rb"]').click()
d(resourceId="com.baidu.naviauto:id/navi_common_dialog_title_bar_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="更多").click()
logging.info("切换日间模式")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/navi_day_mode_rb"]').click()
d(resourceId="com.baidu.naviauto:id/navi_common_dialog_title_bar_close").click()
logging.info("点击更多设置")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_open_close_ly").click()
time.sleep(1)
d(text="更多").click()
logging.info("切换自动模式")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/navi_night_mode_auto_rb"]').click()
d(resourceId="com.baidu.naviauto:id/navi_common_dialog_title_bar_close").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_auto_day_nightMode_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_auto_day_nightMode_{time_now}.txt')
print(e)
return False
return True
def test_voic_avoidCongestion(self):
'''导航中设置路线偏好为躲避拥堵'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 躲避拥堵')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_voic_avoidCongestion_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_voic_avoidCongestion_{time_now}.txt')
print(e)
return False
return True
def test_voic_noHighSpeedRoute(self):
'''导航中设置路线偏好为不走高速路线'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 不走高速路线')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_voic_noHighSpeedRoute_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_voic_noHighSpeedRoute_{time_now}.txt')
print(e)
return False
return True
def test_voic_chargeLess(self):
'''导航中设置路线偏好为少收费'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 少收费')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_voic_chargeLess_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_voic_chargeLess_{time_now}.txt')
print(e)
return False
return True
def test_voic_highSpeedPriority(self):
'''导航中设置路线偏好为高速优先路线'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 高速优先路线')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_voic_highSpeedPriority_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_voic_highSpeedPriority_{time_now}.txt')
print(e)
return False
return True
def test_openRoad(self):
'''打开路况'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 打开路况')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_openRoad_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_openRoad_{time_now}.txt')
print(e)
return False
return True
def test_closeRoad(self):
'''关闭路况'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 关闭路况')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_closeRoad_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_closeRoad_{time_now}.txt')
print(e)
return False
return True
def test_switchFollowMode(self):
'''切换跟随模式'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 车头朝上')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_switchFollowMode_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_switchFollowMode_{time_now}.txt')
print(e)
return False
return True
def test_switchDueNorthMode(self):
'''切换正北模式'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 正北朝上')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_switchDueNorthMode_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_switchDueNorthMode_{time_now}.txt')
print(e)
return False
return True
def test_switch2DMode(self):
'''切换2D模式'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 2D视图')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_switch2DMode_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_switch2DMode_{time_now}.txt')
print(e)
return False
return True
def test_switch3DMode(self):
'''切换3D模式'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 3D视图')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_switch3DMode_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_switch3DMode_{time_now}.txt')
print(e)
return False
return True
def test_switchDayMode(self):
'''切换白天模式'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 白天模式')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_switchDayMode_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_switchDayMode_{time_now}.txt')
print(e)
return False
return True
def test_switchNightMode(self):
'''切换黑夜模式'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 黑夜模式')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_switchNightMode_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_switchNightMode_{time_now}.txt')
print(e)
return False
return True
def test_zoomInMap(self):
'''放大地图'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 放大地图')
time.sleep(5)
except Exception as e:
d.screenshot(f'test_zoomInMap_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_zoomInMap_{time_now}.txt')
print(e)
return False
return True
def test_zoomOutMap(self):
'''缩小地图'''
try:
logging.info("语音唤醒")
os.popen('adb shell am broadcast -a duerosrun -n '
'com.baidu.che.codriver/com.baidu.che.codriver.debug.QueryReceiver --es enQuery 缩小地图')
time.sleep(2)
logging.info("退出导航")
d(resourceId="com.baidu.naviauto:id/bnav_rg_toolbox_quit_ly").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_zoomOutMap_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_zoomOutMap_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_HomeUIDisplay(self):
'''首页UI展示'''
try:
self.click_message_page()
logging.info("搜索栏中显示返回按钮和文案『输入目的地』")
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").exists(timeout=2)
d(text="输入目的地").exists(timeout=2)
logging.info("搜索栏右侧显示登录账号图标")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").exists(timeout=2)
logging.info("右侧竖排依次展示路况图标、定位图标、放大+缩小图标,缩小图标左侧显示比例尺")
d(resourceId="com.baidu.naviauto:id/its_btn").exists(timeout=2)
d(resourceId="com.baidu.naviauto:id/location_btn").exists(timeout=2)
d(resourceId="com.baidu.naviauto:id/zoomin_btn").exists(timeout=2)
d(resourceId="com.baidu.naviauto:id/zoomout_btn").exists(timeout=2)
d(resourceId="com.baidu.naviauto:id/scale_indicator").exists(timeout=2)
time.sleep(5)
except Exception as e:
d.screenshot(f'test_HomeUIDisplay_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_HomeUIDisplay_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_morePanels_UIDisplay(self):
'''首页展开更多面板,UI展示'''
try:
self.click_message_page()
logging.info("点击个人账号")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
logging.info("搜索框右侧的图标变为收起图标")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").exists(timeout=2)
logging.info("面板上依次展示 收藏夹、离线地图数据、组队出行、微信互联、导航设置、关于我们,可上下滑动")
iteamlist = ["收藏夹", "离线地图数据", "组队出行", "微信互联", "导航设置", "关于我们"]
for iteam in iteamlist:
if d(text=iteam).exists(timeout=2):
pass
else:
return False
d(scrollable=True).scroll(steps=10)
logging.info("返回导航主界面")
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_morePanels_UIDisplay_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_morePanels_UIDisplay_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_packUp_morePanels(self):
'''收起更多面板'''
try:
self.click_message_page()
logging.info("点击个人账号")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="离线地图数据").exists(timeout=2)
logging.info("收起更多面板")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
if not d(text="离线地图数据").exists(timeout=2):
pass
else:
return False
time.sleep(5)
except Exception as e:
d.screenshot(f'test_packUp_morePanels_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_packUp_morePanels_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_morePanels_clickSearch(self):
'''展开更多面板时点击搜索框'''
try:
self.click_message_page()
logging.info("点击个人账号")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(text="离线地图数据").exists(timeout=2)
logging.info("点击搜索框")
d(text="输入目的地").click()
logging.info("添加途径点icon")
if d(resourceId="com.baidu.naviauto:id/ib_lion_search_add").exists(timeout=2):
pass
else:
return False
logging.info("返回导航界面")
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_morePanels_clickSearch_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_morePanels_clickSearch_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_favorites_page(self):
'''点击收藏夹入口进入收藏夹页面'''
try:
self.click_message_page()
logging.info("点击个人账号")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
d(scrollable=True).scroll.vert.backward()
d(text="收藏夹").click()
logging.info("进入收藏夹页面(展示家和公司)")
if d(text="家").exists(timeout=2):
pass
else:
return False
if d(text="公司").exists(timeout=2):
pass
else:
return False
logging.info("返回导航界面")
d(resourceId="com.baidu.naviauto:id/iv_left").click()
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_favorites_page_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_favorites_page_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_search_record_display(self):
'''历史搜索记录展示'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(scrollable=True).scroll.toEnd()
logging.info("尾部展示『清空历史记录』按钮")
if d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_lion_search"]/'
'android.widget.FrameLayout[4]').wait(timeout=2):
pass
else:
return False
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_search_record_display_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_search_record_display_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_click_clearHistory(self):
'''点击『清空历史记录』按钮,弹出确认dialog'''
try:
self.click_message_page()
logging.info("点击搜索框")
d(text="输入目的地").click()
d(scrollable=True).scroll.toEnd()
logging.info("点击『清空历史记录』按钮")
d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_lion_search"]/'
'android.widget.FrameLayout[4]').click()
time.sleep(1)
logging.info("点击确定")
d(text="确定").click()
time.sleep(1)
if d.xpath('//*[@resource-id="com.baidu.naviauto:id/listview_lion_search"]/'
'android.widget.FrameLayout[4]').wait(timeout=2):
return False
else:
pass
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_click_clearHistory_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_click_clearHistory_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_clear_cache_page_display(self):
'''查看清除缓存页面显示'''
try:
self.click_message_page()
logging.info("点击个人账号")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
logging.info("点击导航设置")
d(text="导航设置").click()
d(scrollable=True).scroll.toEnd()
logging.info("查看缓存")
if not d(text="0KB").exists(timeout=2):
pass
else:
return False
d(resourceId="com.baidu.naviauto:id/btnBack").click()
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_clear_cache_page_display_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_clear_cache_page_display_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_clear_cache(self):
'''清除缓存点击确认和取消按钮'''
try:
self.click_message_page()
logging.info("点击个人账号")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
logging.info("点击导航设置")
d(text="导航设置").click()
d(scrollable=True).scroll.toEnd()
logging.info("点击清除缓存")
d(text="清除缓存").click()
logging.info("点击取消")
d(text="取消").click()
time.sleep(1)
logging.info("点击清除缓存")
d(text="清除缓存").click()
logging.info('点击确定')
d(text="确定").click()
if d(text="0KB").exists(timeout=2):
pass
else:
return False
d(resourceId="com.baidu.naviauto:id/btnBack").click()
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_clear_cache_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_clear_cache_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_clear_cache_field_display(self):
'''有缓存的情况下点击当前缓存字段热区'''
try:
self.click_message_page()
logging.info("点击个人账号")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
logging.info("点击导航设置")
d(text="导航设置").click()
d(scrollable=True).scroll.toEnd()
logging.info("点击清除缓存")
d(text="清除缓存").click()
logging.info("当前缓存字段热区显示")
d(text="确认要清除缓存吗?").exists(timeout=2)
d(text="取消").exists(timeout=2)
d(text="确定").exists(timeout=2)
logging.info('点击确定')
d(text="确定").click()
d(resourceId="com.baidu.naviauto:id/btnBack").click()
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_clear_cache_field_display_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_clear_cache_field_display_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_cacheDataIs0_click_clear_cache(self):
'''当前缓存数据为0点击清除缓存按钮'''
try:
self.click_message_page()
logging.info("点击个人账号")
d(resourceId="com.baidu.naviauto:id/ll_menu_check_box").click()
logging.info("点击导航设置")
d(text="导航设置").click()
d(scrollable=True).scroll.toEnd()
logging.info("点击清除缓存")
for i in range(2):
d(text="清除缓存").click()
logging.info('点击确定')
d(text="确定").click()
if d(text="0KB").exists(timeout=2):
pass
else:
return False
d(resourceId="com.baidu.naviauto:id/btnBack").click()
time.sleep(1)
d(resourceId="com.baidu.naviauto:id/relative_lion_search_back").click()
time.sleep(5)
except Exception as e:
d.screenshot(f'test_cacheDataIs0_click_clear_cache_{time_now}.png')
os.popen(f'adb logcat -v -t threadtime 10000> test_cacheDataIs0_click_clear_cache_{time_now}.txt')
print(e)
return False
finally:
d.app_stop("com.baidu.naviauto")
return True
def test_01(self):
"""启动地图
通过包名判断首页元素是否启动成功
"""
print("1111")
basemap.enter_map()
Judge.passIf(self, UIChecker.checkByText("输入目的地"), "进入地图")
def test_02(self):
print("2222")
"""勾选不在提醒选项
通过再次进入地图判断是否有弹窗
"""
basemap.enter_map()
# Action.adb_cmd("adb shell input keyevent 4")
# Action.clickByText(u"退出导航")
Action.adb_cmd("adb shell am start -n com.baidu.naviauto/.NaviAutoActivity")
sleep(2)
Judge.passUnless(self,
UIChecker.checkByText("免责声明"), "进入免责声明"
)
def test_03(self):
"""进入事故上报界面
"""
print("3333")
basemap.enter_map()
basemap.enter_ugc()
Action.clickByText("事故")
Judge.passIf(self, UIChecker.checkByTextWait("严重事故"), "进入事故上报界面")
Action.clickByResourceId(BaiduMap.UGC_Close_id)
def test_04(self):
"""进入拥堵上报界面
"""
print("44444")
basemap.enter_map()
basemap.enter_ugc()
sleep(2)
Action.clickByText("拥堵")
Judge.passIf(self, UIChecker.checkByTextWait("轻微拥堵"), "进入拥堵上报界面")
Action.clickByResourceId(BaiduMap.UGC_Close_id)
def test_05(self):
print("5555")
"""进入危险上报界面
"""
basemap.enter_map()
basemap.enter_ugc()
Action.clickByText("危险")
Judge.passIf(self, UIChecker.checkByTextWait("积水"), "进入危险上报界面")
Action.clickByResourceId(BaiduMap.UGC_Close_id)
def test_06(self):
"""进入修路上报界面
"""
print("6666")
basemap.enter_map()
basemap.enter_ugc()
Action.clickByText("修路")
Judge.passIf(self, UIChecker.checkByTextWait("可以通行"), "进入修路上报界面")
Action.clickByResourceId(BaiduMap.UGC_Close_id)
def test_07(self):
"""进入封路上报界面
"""
basemap.enter_map()
basemap.enter_ugc()
Action.clickByText("封路")
Judge.passIf(self, UIChecker.checkByTextWait("临时封路"), "进入封路上报界面")
Action.clickByResourceId(BaiduMap.UGC_Close_id)
def test_08(self):
"""进入道路报错上报界面
"""
basemap.enter_map()
basemap.enter_ugc()
Action.clickByText("道路报错")
Judge.passIf(self, UIChecker.checkByTextWait("道路不存在"), "进入道路报错上报界面")
Action.clickByResourceId(BaiduMap.UGC_Close_id)
def test_09(self):
"""进入更多设置界面
"""
basemap.enter_map()
basemap.enter_settings()
self.assertTrue(Judge.passIf(self, UIChecker.checkByTextWait("收藏夹"), "进入更多设置界面"))
def test_10(self):
"""进入收藏夹
"""
basemap.enter_map()
basemap.enter_settings()
Action.clickByText("收藏夹")
sleep(5)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Setting_refresh_id), "进入收藏夹")
def test_11(self):
"""点击收藏夹编辑按钮
"""
basemap.enter_map()
basemap.enter_settings()
Action.clickByText("收藏夹")
sleep(8)
Action.clickByResourceId(BaiduMap.Collection_edit_id)
Action.clickByResourceId(BaiduMap.Succees_edit_id)
# Judge.passIf(self, UIChecker.checkByTextWait("完成"), "点击收藏夹编辑按钮")
# Action.clickByText("完成")
def test_12(self):
"""进入离线地图数据界面
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
sleep(3)
Judge.passIf(self, UIChecker.checkByTextWait("零流量更新"), "进入离线地图界面")
def test_13(self):
"""进入零流量更新界面
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
Action.clickByText("零流量更新")
Judge.passIf(self, UIChecker.checkByTextWait("U盘更新"), "进入零流量更新界面")
'''
‘’’
def test_14(self):
"""进入U盘更新界面
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
Action.clickByText("零流量更新")
Action.clickByText("U盘更新")
Judge.passIf(self, UIChecker.checkByTextWait("未发现U盘"), "进入零流量更新界面")
# def test_15(self):
# """进入手机更新界面
# """
# basemap.enter_map()
# basemap.enter_settings()
# basemap.enter_0fflinedata()
# Action.clickByText("零流量更新")
# Action.clickByText("手机更新")
# Judge.passIf(self, UIChecker.checkByTextContains("打开手机热点"), "进入手机更新界面")
@unittest.skip("test")
def test_16(self):
"""进入Wi-Fi界面再返回
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
Action.clickByText("零流量更新")
Action.clickByText("手机更新")
Action.clickByText("网络设置 >")
Judge.passIf(self, UIChecker.checkByTextWait("Wi-Fi"), "进入Wi-Fi界面")
Action.adb_cmd("adb shell input keyevent 4")
sleep(2)
def test_17(self):
"""进入离线地图界面
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
Action.clickByText("离线地图")
sleep(3)
Judge.passIf(self, UIChecker.checkByTextWait("热门城市"), "进入离线地图界面")
def test_18(self):
"""进入热门城市并返回
"""
basemap.enter_map()
basemap.enter_settings()
sleep(2)
basemap.enter_0fflinedata()
Action.clickByText("离线地图")
Action.clickByText("热门城市")
Judge.passIf(self, UIChecker.checkByTextWait("北京市"), "进入热门城市")
Action.adb_cmd("adb shell input keyevent 4")
Judge.passIf(self, UIChecker.checkByTextWait("离线地图"), "返回离线地图界面")
def test_19(self):
"""进入城市搜索,并搜索
"""
basemap.enter_map()
sleep(2)
basemap.enter_settings()
sleep(2)
basemap.enter_0fflinedata()
Action.clickByText("离线地图")
Action.clickByResourceId(BaiduMap.Offline_search_id)
input = "请输入城市名或首字母"
Judge.passIf(self, UIChecker.checkByTextWait(input), "进入城市搜索界面")
Action.clickByText(input)
Action.setTextByResourceId(BaiduMap.Offline_input_id, "haer")
Judge.passIf(self, UIChecker.checkByText("哈尔滨市"), "搜索哈尔滨")
def test_20(self):
"""进入下载管理界面
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
Action.clickByText("离线地图")
Action.clickByResourceId(BaiduMap.Offline_setting_id)
Judge.passIf(self, UIChecker.checkByText("全部更新"), "进入下载管理界面")
def test_21(self):
"""滑动查找浙江省并点击
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
Action.clickByText("离线地图")
sleep(2)
Action.clickByScrollText("浙江省")
Judge.passIf(self, UIChecker.checkByText("杭州市"), "滑动查找浙江省并点击")
Action.clickByResourceId(BaiduMap.Offline_download_id)
def test_22(self):
"""点击回家按钮,进行导航
"""
basemap.enter_map()
input = "输入目的地"
Action.clickByText(input)
Action.clickByText("回家")
# 没有设置公司地址,输入关键词,选择第一个结果设为家地址
# if UIChecker.checkByTextWait(input):
# sleep(1)
# Action.setTextByResourceId(BaiduMap.Input_via_id, "世界之窗")
# sleep(5)
# Action.clickByResourceId(BaiduMap.Search_jc_id)
# sleep(3)
# Judge.passIf(self, UIChecker.checkByTextWait("回家"), "设置家地址")
# Action.clickByText("回家")
sleep(6)
# Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Start_navigation), "跳转到路线规划界面")
# Action.clickByResourceId(BaiduMap.Start_navigation)
# Judge.passIf(self, UIChecker.checkByText('同意'), "百度地图导航使用提示页面")
Action.clickByText('同意')
sleep(3)
# basemap.click_agree_buttom()
basemap.close_navi()
def test_23(self):
"""点击更多-停车场,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("停车场")
sleep(2)
# 点击退出导航按钮
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_24(self):
"""点击更多-加油站,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("加油站")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_25(self):
"""点击更多-4S店,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("4S店")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_26(self):
"""点击更多-洗车,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("洗车")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_27(self):
"""点击更多-卫生间,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("卫生间")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_28(self):
"""点击更多-中餐,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("中餐")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_29(self):
"""点击更多-西餐,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("西餐")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_30(self):
"""点击更多-小吃,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("小吃")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_31(self):
"""点击更多-机场,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("机场")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_32(self):
"""点击更多-火车站,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("火车站")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_33(self):
"""点击更多-服务区,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("服务区")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_34(self):
"""点击更多-风景区,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("风景区")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_35(self):
"""点击更多-度假村,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("度假村")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_36(self):
"""点击更多-公园,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("公园")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_37(self):
"""点击更多-星级酒店,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("星级酒店")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_38(self):
"""点击更多-快捷酒店,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("快捷酒店")
sleep(2)
if UIChecker.checkByTextWait("发送"):
Action.clickByText("发送")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
@unittest.skip("test")
def test_39(self):
"""点击更多-旅馆,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("旅馆")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_40(self):
"""点击更多-银行,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("银行")
sleep(2)
if UIChecker.checkByTextWait("发送"):
Action.clickByText("发送")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_41(self):
"""点击更多-医院,进行导航
"""
basemap.enter_map()
basemap.enter_morepage("医院")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_42(self):
"""开启路况
"""
basemap.enter_navi()
Action.swipeLeftAtCenter()
# 判断路况控件是否可点击
sleep(2)
Judge.passIf(self, UIChecker.checkByTextWait("继续当前导航"), "进入操作态")
# 点击开启路况
Action.clickByResourceId(BaiduMap.Traffic_panel_id)
# 数据网络下会弹框提示
if UIChecker.checkByTextWait("提示"):
Action.clickByText("我知道了")
config.logger.info("实时路况已打开")
def test_43(self):
"""关闭导航声音
"""
basemap.enter_navi()
Action.swipeLeftAtCenter()
# 判断是否进入操作态
Action.waiting(2)
Judge.passIf(self, UIChecker.checkByTextWait("继续当前导航"), "进入操作态")
# 点击关闭导航声音
Action.clickByResourceId(BaiduMap.Traffic_voice_id)
Judge.passIf(self, UIChecker.checkByTextWait("已关闭“导航声音”"), "关闭导航声音")
def test_44(self):
"""开启导航声音
在导航时拖动地图
"""
basemap.enter_navi()
Action.swipeLeftAtCenter()
# 判断是否进入操作态
Action.waiting(1)
Judge.passIf(self, UIChecker.checkByTextWait("继续当前导航"), "进入操作态")
# 点击关闭导航声音
Action.clickByResourceId(BaiduMap.Traffic_voice_id)
Judge.passIf(self, UIChecker.checkByTextWait("已关闭“导航声音”"), "关闭导航声音")
Action.swipeLeftAtCenter()
Action.waiting(1)
# 点击开启导航声音
Action.clickByResourceId(BaiduMap.Traffic_voice_id)
Judge.passIf(self, UIChecker.checkByTextWait("已开启“导航声音”"), "开启导航声音")
def test_45(self):
"""点击刷新路线按钮
"""
basemap.enter_navi()
Action.swipeLeftAtCenter()
sleep(2)
Judge.passIf(self, UIChecker.checkByTextWait("继续当前导航"), "进入操作态")
Action.clickByResourceId(BaiduMap.Traffic_refresh_id)
sleep(3)
Judge.passIf(self, UIChecker.checkByTextContains("优路线"), "点击刷新路线")
if UIChecker.checkByText("当前已是最优路线"):
Action.clickByText("继续当前导航")
def test_46(self):
"""查看导航设置
进入导航设置,收起导航设置
"""
basemap.enter_navi()
Action.clickByResourceId(BaiduMap.More_btn_id)
Judge.passIf(self, UIChecker.checkByTextWait("更多"), "进入导航设置界面")
Action.clickByResourceId(BaiduMap.More_btn_id)
config.logger.info("收起导航设置界面,pass")
def test_47(self):
"""切换为路况条
进入导航设置,切换成路况条
"""
basemap.enter_navi()
# 进入导航设置
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("全览小窗")
if UIChecker.checkByText("GPS信号弱,请谨慎驾驶"):
Action.waiting(3)
else:
Judge.passIf(self, UIChecker.checkByTextWait("已切换为“路况条”"), "切换导航小窗为路况条")
def test_48(self):
"""切换全览小窗
进入导航设置,切换成路况条,再切换成全览小窗
"""
basemap.enter_navi()
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("全览小窗")
if UIChecker.checkByText("GPS信号弱,请谨慎驾驶"):
Action.waiting(3)
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("路况条")
Judge.passIf(self, UIChecker.checkByTextWait("已切换为“全览小窗”"), "切换路况条为全览小窗")
def test_49(self):
"""切换为2D模式
进入导航设置,切换成2D模式
"""
basemap.enter_navi()
sleep(2)
Action.clickByResourceId(BaiduMap.More_btn_id)
# 点击车头朝上
Action.clickByText("车头朝上")
if UIChecker.checkByText("GPS信号弱,请谨慎驾驶"):
Action.waiting(3)
else:
Judge.passIf(self, UIChecker.checkByTextWait("已切换导航视角为“正北朝上”"), "切换导航视角为正北朝上")
def test_50(self):
"""切换为3D模式
"""
basemap.enter_navi()
Action.clickByResourceId(BaiduMap.More_btn_id)
# 点击车头朝上
Action.clickByText("车头朝上")
if UIChecker.checkByText("GPS信号弱,请谨慎驾驶"):
Action.waiting(3)
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("正北朝上")
sleep(2)
# Judge.passIf(self, UIChecker.checkByTextWait("已切换导航视角为“车头朝上”"), "切换导航视角为车头朝上")
def test_51(self):
"""点击限行按钮
"""
basemap.enter_navi()
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("限行")
Action.waiting(2)
Judge.passIf(self, UIChecker.checkByTextContains("车牌限行"), "点击限行按钮")
# 点击界面关闭按钮
if UIChecker.checkByResourceId(BaiduMap.Quit_common_id):
Action.clickByResourceId(BaiduMap.Quit_common_id)
def test_52(self):
"""进入沿途搜界面
"""
basemap.enter_navi()
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("沿途搜")
Action.waiting(1)
Judge.passIf(self, UIChecker.checkByTextWait("厕所"), "进入沿途搜索界面")
# 点击界面关闭按钮
if UIChecker.checkByResourceId(BaiduMap.Quit_common_id):
Action.clickByResourceId(BaiduMap.Quit_common_id)
def test_53(self):
"""沿途搜索加油站
"""
basemap.enter_navi()
basemap.enter_navi_search("加油站")
Judge.passUnless(self, UIChecker.checkByResourceId(BaiduMap.Traffic_voice_id), "回到继续导航状态")
def test_54(self):
"""沿途搜充电站
"""
basemap.enter_navi()
basemap.enter_navi_search("充电站")
Judge.passUnless(self, UIChecker.checkByResourceId(BaiduMap.Traffic_voice_id), "回到继续导航状态")
def test_55(self):
"""沿途搜厕所
"""
basemap.enter_navi()
basemap.enter_navi_search("厕所")
Judge.passUnless(self, UIChecker.checkByResourceId(BaiduMap.Traffic_voice_id), "回到继续导航状态")
def test_56(self):
"""沿途搜银行ATM
"""
basemap.enter_navi()
basemap.enter_navi_search("银行")
Judge.passUnless(self, UIChecker.checkByResourceId(BaiduMap.Traffic_voice_id), "回到继续导航状态")
def test_57(self):
"""沿途搜酒店住宿
"""
basemap.enter_navi()
basemap.enter_navi_search("酒店")
Judge.passUnless(self, UIChecker.checkByResourceId(BaiduMap.Traffic_voice_id), "回到继续导航状态")
def test_58(self):
"""沿途搜旅游景点
"""
basemap.enter_navi()
basemap.enter_navi_search("景点")
Judge.passUnless(self, UIChecker.checkByResourceId(BaiduMap.Traffic_voice_id), "回到继续导航状态")
def test_59(self):
"""进入路线偏好界面
"""
basemap.enter_navi()
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("偏好")
Judge.passIf(self, UIChecker.checkByTextWait("路线偏好"), "进入路线偏好界面")
if UIChecker.checkByResourceId(BaiduMap.Quit_common_id):
Action.clickByResourceId(BaiduMap.Quit_common_id)
def test_60(self):
"""使用时间优先
路线偏好设置为时间优先
"""
basemap.enter_navi()
basemap.navi_choice_routeplan("时间优先")
Judge.passIf(self, UIChecker.checkByTextWait("已使用时间优先方案"), "切换路线偏好为时间优先")
def test_61(self):
"""使用少收费
路线偏好设置为少收费
"""
basemap.enter_navi()
sleep(3)
basemap.navi_choice_routeplan("少收费")
Judge.passIf(self, UIChecker.checkByTextWait("已使用少收费方案"), "切换路线偏好为少收费")
def test_62(self):
"""使用躲避拥堵
路线偏好设置为躲避拥堵
"""
basemap.enter_navi()
basemap.navi_choice_routeplan("躲避拥堵")
Judge.passIf(self, UIChecker.checkByTextWait("已使用躲避拥堵方案"), "切换路线偏好为躲避拥堵")
def test_63(self):
"""使用不走高速
路线偏好设置为不走高速
"""
basemap.enter_navi()
basemap.navi_choice_routeplan("不走高速")
Judge.passIf(self, UIChecker.checkByTextWait("已使用不走高速方案"), "切换路线偏好为不走高速")
def test_64(self):
"""使用高速优先
路线偏好设置为高速优先
"""
basemap.enter_navi()
basemap.navi_choice_routeplan("高速优先")
Judge.passIf(self, UIChecker.checkByTextWait("已使用高速优先方案"), "切换路线偏好为高速优先")
def test_65(self):
"""使用智能推荐
路线偏好设置为智能推荐
"""
basemap.enter_navi()
basemap.navi_choice_routeplan("高速优先")
sleep(2)
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("偏好")
Action.clickByText("智能推荐")
sleep(2)
Judge.passIf(self, UIChecker.checkByTextWait("已使用智能推荐方案"), "切换路线偏好为智能推荐")
def test_66(self):
"""点击行程分享
"""
basemap.enter_navi()
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("行程分享")
Action.waiting(2)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Quit_common_id), "进入行程分享界面")
def test_67(self):
"""查看更多设置界面
进入更多设置界面
"""
basemap.enter_navi()
Action.clickByResourceId(BaiduMap.More_btn_id)
Action.clickByText("更多")
Judge.passIf(self, UIChecker.checkByTextWait("更多设置"), "进入更多设置界面")
def test_68(self):
"""查看导航中事件上报界面
进入事件上报界面
"""
basemap.enter_navi()
Action.swipeLeftAtCenter()
# 判断是否进入操作态
Judge.passIf(self, UIChecker.checkByTextWait("继续当前导航"), "进入操作态,fail")
# 点击进入事件上报界面
Action.clickByResourceId(BaiduMap.Traffic_report_id)
Judge.passIf(self, UIChecker.checkByTextWait("事故"), "进入导航中事件上报界面")
Action.clickByResourceId(BaiduMap.Traffic_report_id)
def test_69(self):
"""点击事故上报发送
进入事故上报界面
"""
basemap.enter_navi()
basemap.enter_ugc_page("事故")
Judge.passIf(self, UIChecker.checkByTextWait("追尾"), "进入事故界面")
Action.clickByResourceId(BaiduMap.UGC_Send_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContainsWait("感谢您的反馈!"), "点击事故上报发布")
def test_70(self):
"""点击拥堵上报发送
进入拥堵上报界面
"""
basemap.enter_navi()
sleep(3)
basemap.enter_ugc_page("拥堵")
Judge.passIf(self, UIChecker.checkByTextWait("缓慢行驶"), "进入拥堵界面")
Action.clickByResourceId(BaiduMap.UGC_Send_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContainsWait("感谢您的反馈!"), "点击拥堵上报发布")
def test_71(self):
"""点击危险上报发送
进入危险上报界面
"""
basemap.enter_navi()
basemap.enter_ugc_page("危险")
Judge.passIf(self, UIChecker.checkByTextWait("积水"), "进入危险界面")
Action.clickByResourceId(BaiduMap.UGC_Send_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContainsWait("感谢您的反馈!"), "点击危险上报发布")
def test_72(self):
"""点击修路上报发送
进入修路上报界面
"""
basemap.enter_navi()
basemap.enter_ugc_page("修路")
Judge.passIf(self, UIChecker.checkByTextWait("可以通行"), "进入修路界面")
Action.clickByResourceId(BaiduMap.UGC_Send_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContainsWait("感谢您的反馈!"), "点击修路上报发布")
def test_73(self):
"""点击封路上报发送
进入封路上报界面
"""
basemap.enter_navi()
basemap.enter_ugc_page("封路")
Judge.passIf(self, UIChecker.checkByTextWait("临时封路"), "进入封路界面")
Action.clickByResourceId(BaiduMap.UGC_Send_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContainsWait("感谢您的反馈!"), "点击封路上报发布")
def test_74(self):
"""点击道路报错上报发送
进入道路报错上报界面
"""
basemap.enter_navi()
sleep(3)
basemap.enter_ugc_page("道路报错")
Judge.passIf(self, UIChecker.checkByTextWait("道路不存在"), "进入修路界面")
Action.clickByResourceId(BaiduMap.UGC_Send_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContainsWait("感谢您的反馈!"), "点击道路报错上报发布")
def test_75(self):
"""进入事故录音界面
"""
basemap.enter_navi()
basemap.enter_ugc_page("事故")
Action.swipeDiretion(BaiduMap.UGC_swipe_id, 'up', 5)
Action.clickByResourceId(BaiduMap.UGC_record_id)
Judge.passIf(self, UIChecker.checkByText("详细描述"), "进入事故录音界面")
def test_76(self):
"""点击开始录音,再点击结束录音,发送
"""
basemap.enter_navi()
sleep(3)
basemap.enter_ugc_page("事故")
sleep(2)
Action.swipeDiretion(BaiduMap.UGC_swipe_id, 'up', 5)
Action.clickByResourceId(BaiduMap.UGC_record_id)
Action.clickByResourceId(BaiduMap.UGC_speech_id)
# Action.clickByResourceId(BaiduMap.sys_open_btn)
# Action.clickByText("允许")
Action.clickByResourceId(BaiduMap.UGC_speech_id)
sleep(5)
Judge.passIf(self, UIChecker.checkByResourceId("com.baidu.naviauto:id/ugc_record_page_status"), "点击开始录音")
# Judge.passIf(self, UIChecker.checkByTextContains("剩余"), "点击开始录音")
# Action.clickByResourceId(BaiduMap.UGC_speech_id)
Judge.passIf(self, UIChecker.checkByTextContains("语音描述"), "点击结束录音")
Action.clickByResourceId(BaiduMap.UGC_Send_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContainsWait("感谢您的反馈!"), "录音后发布")
# 备注:此条case需要调试
def test_77(self):
"""进入离线导航界面点击已下载
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
Action.clickByText("离线导航")
Judge.passIf(self, UIChecker.checkByText("已下载"), "进入离线导航界面")
if UIChecker.checkByText("已下载"):
Action.clickByText("已下载")
"""获取不到麦克权限"""
@unittest.skip("error")
def test_78(self):
"""滑动查找澳门
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_0fflinedata()
Action.clickByText("离线导航")
sleep(1)
try:
Action.clickByScrollText("澳门")
if UIChecker.checkByText("取消"):
Action.clickByText("取消")
except:
if UIChecker.checkByText("已下载"):
Action.clickByText("已下载")
finally:
Judge.passIf(self, UIChecker.checkByTextContains("澳门"), "滑动查找澳门")
def test_79(self):
"""进入组队出行,如有队伍,解散队伍
"""
basemap.enter_map()
sleep(2)
basemap.enter_settings()
sleep(3)
basemap.enter_teamtrip_page()
Action.clickByText("取消")
Judge.passIf(self, UIChecker.checkByText("组队出行"), "进入组队出行")
def test_80(self):
"""进入加入队伍界面
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_teamtrip_page()
Action.clickByText("组队出行")
if UIChecker.checkByText("服务协议"):
Action.clickByText("同意并继续")
sleep(2)
Action.clickByText("加入队伍")
sleep(2)
Action.setTextByResourceId(BaiduMap.Team_join_id, 111)
for i in range(6):
Action.clickByResourceId(BaiduMap.Team_keboard_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Team_join_id), "进入加入队伍界面")
def test_81(self):
"""进入组队出行,创建队伍
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_teamtrip_page()
Action.clickByText("组队出行")
sleep(2)
if UIChecker.checkByText("服务协议"):
Action.clickByText("同意并继续")
sleep(2)
Action.clickByText("创建队伍")
sleep(5)
Judge.passIf(self, UIChecker.checkByText("我的队伍"), "进入组队出行")
def test_82(self):
"""进入组队出行,操作后点击邀请好友
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_teamtrip_page()
Action.clickByText("组队出行")
sleep(2)
if UIChecker.checkByText("服务协议"):
Action.clickByText("同意并继续")
Action.clickByText("创建队伍")
sleep(5)
for i in range(5):
Action.clickByResourceId(BaiduMap.Zoom_out_id)
Action.clickByResourceId(BaiduMap.Team_show_id)
Action.clickByText("邀请好友")
Judge.passIf(self, UIChecker.checkByTextContains("您的队伍口令为"), "点击邀请好友")
def test_83(self):
"""进入组队出行,修改队伍名称
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_teamtrip_page()
Action.clickByText("组队出行")
sleep(2)
if UIChecker.checkByText("服务协议"):
Action.clickByText("同意并继续")
Action.clickByText("创建队伍")
sleep(5)
Action.clickByResourceId(BaiduMap.Team_setting_id)
Action.clickByResourceId(BaiduMap.Team_edit_id)
# Action.setTextByResourceId(BaiduMap.Team_input_id, 'T2@i?')
# Action.adb_cmd("adb shell input keyevent 4")
# sleep(1)
# Judge.passIf(self, UIChecker.checkByTextContains("T2@i?"), "修改队伍名称")
# def test_120(self):
#
# os.popen("adb reboot").readline()
# sleep(100)
def test_84(self):
"""进入导航设置的导航语音界面
"""
basemap.enter_map()
# Action.backToPre()
basemap.enter_settings()
sleep(2)
basemap.enter_navi_settings()
sleep(2)
Action.clickByText("导航语音")
sleep(2)
if UIChecker.checkByTextContains("网络未连接"):
pass
else:
Judge.passIf(self, UIChecker.checkByTextContains("普通话"), "进入导航语音界面")
def test_85(self):
"""进入导航语音,点击angel萌语音
"""
basemap.enter_map()
sleep(2)
basemap.enter_settings()
sleep(2)
basemap.enter_navi_settings()
Action.clickByText("导航语音")
sleep(2)
Action.clickByText("angel萌")
sleep(3)
if UIChecker.checkByText("确定"):
Action.clickByText("确定")
Judge.passIf(self, UIChecker.checkByTextContains("使用中"), "点击angel萌语音")
def test_86(self):
"""进入导航设置,清除缓存
"""
basemap.enter_map()
sleep(2)
basemap.enter_settings()
sleep(2)
basemap.enter_navi_settings()
Action.clickByScrollText("清除缓存")
if UIChecker.checkByText("确认要清除缓存吗?"):
Action.clickByText("确定")
Judge.passIf(self, UIChecker.checkByTextContainsWait("0KB"), "清除缓存")
# def test_87(self):
# """进入导航设置,修改爱车名称
# """
# basemap.enter_map()
# basemap.enter_settings()
# basemap.enter_navi_settings()
# Action.clickByScrollText("爱车名称")
# Action.clearTextByResourceId(BaiduMap.Edit_carname_id)
# Action.setTextByResourceId(BaiduMap.Edit_carname_id, "@My_Car_01~")
# sleep(1)
# Action.clickByText("保存")
# Judge.passIf(self, UIChecker.checkByTextContains("@My_Car_01~"), "修改爱车名称")
# def test_88(self):
# """进入导航设置,删除爱车名称并保存
# """
# basemap.enter_map()
# basemap.enter_settings()
# basemap.enter_navi_settings()
# Action.clickByScrollText("爱车名称")
# Action.clearTextByResourceId(BaiduMap.Edit_carname_id)
# sleep(1)
# Action.clickByText("保存")
# Judge.passIf(self, UIChecker.checkByTextContains("我的汽车"), "删除爱车名称并保存")
def test_89(self):
"""进入导航设置,设置经典车标
"""
basemap.enter_map()
sleep(2)
basemap.enter_settings()
sleep(2)
basemap.enter_navi_settings()
sleep(2)
Action.clickByScrollText("设置车标")
Action.clickByText("经典车标")
Action.adb_cmd("adb shell input keyevent 4")
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContains("经典"), "设置经典车标")
def test_90(self):
"""进入导航设置,设置林肯车标
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByScrollText("设置车标")
Action.clickByText("林肯车标")
Action.adb_cmd("adb shell input keyevent 4")
sleep(2)
Judge.passIf(self, UIChecker.checkByTextContains("林肯"), "设置林肯车标")
def test_91(self):
"""进入导航设置,打开限行开关
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.swipeDiretion(BaiduMap.Edit_carlimit_id, 'up', 15)
sleep(2)
Action.clickByText("开启")
Judge.passIf(self, UIChecker.checkByTextContains("限行规定"), "打开限行开关")
@unittest.skip("error")
def test_92(self):
"""进入限行规定,查找珠海并点击
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.swipeDiretion(BaiduMap.Edit_carlimit_id, 'up', 15)
sleep(2)
Action.clickByText("开启")
Action.clickByText("限行规定")
sleep(3)
Action.clickByScrollText("珠海")
sleep(3)
Judge.passIf(self, UIChecker.checkByTextContains("珠海市"), "查找珠海并点击")
def test_93(self):
"""进入关于我们,点击法律资质
"""
basemap.enter_map()
basemap.enter_settings()
Action.swipeDiretion(BaiduMap.Navi_setting_id, 'up', 5)
Action.clickByText("关于我们")
Action.clickByText("法律资质")
config.logger.info("进入法律资质界面")
def test_94(self):
"""进入关于我们,点击服务条款
"""
basemap.enter_map()
basemap.enter_settings()
Action.swipeDiretion(BaiduMap.Navi_setting_id, 'up', 5)
Action.clickByText("关于我们")
Action.clickByText("服务条款")
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Service_text_id), "点击服务条款")
def test_95(self):
"""进入关于我们,点击帮助按钮
"""
basemap.enter_map()
basemap.enter_settings()
Action.swipeDiretion(BaiduMap.Navi_setting_id, 'up', 5)
Action.clickByText("关于我们")
Action.clickByResourceId(BaiduMap.About_Help_id)
Judge.passIf(self, UIChecker.checkByTextContains("帮助"), "点击帮助按钮")
@unittest.skip("error")
def test_96(self):
"""进入关于我们,遍历帮助列表
"""
help = ("1.离线地图有什么用", "2.如何下载或更新离线地图", "3.如何使用二维码扫描登录",
"4.如何设置导航偏好", "5.如何设置我的车牌号限行", "6.如何设置沿途搜索")
basemap.enter_map()
basemap.enter_settings()
Action.swipeDiretion(BaiduMap.Navi_setting_id, 'up', 5)
Action.clickByText("关于我们")
Action.clickByResourceId(BaiduMap.About_Help_id)
for i in help:
Action.clickByText(i)
sleep(2)
Action.adb_cmd("adb shell input keyevent 4")
sleep(2)
config.logger.info("遍历帮助列表")
@unittest.skip("error")
def test_97(self):
"""在首页底图,进行反GEO操作
"""
basemap.enter_map()
Action.swipeLeftAtCenter()
sleep(1)
d.long_click(400, 500)
sleep(2)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Search_around_id), "进行反GEO操作")
@unittest.skip("error")
def test_98(self):
"""从POI详情页进入周边搜,并输入检索词
"""
basemap.enter_map()
Action.swipeLeftAtCenter()
sleep(2)
d.long_click(500, 600)
sleep(3)
Action.clickByResourceId(BaiduMap.Search_around_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Search_input_id), "从POI详情页进入周边搜")
Action.clickByResourceId(BaiduMap.Search_input_id)
Action.setTextByResourceId(BaiduMap.Search_input_id, "~@$UYHdygis/ 打开===++")
sleep(2)
def test_99(self):
"""设置组队出行目的地
"""
input = "输入目的地"
basemap.enter_map()
basemap.enter_settings()
basemap.enter_teamtrip_page()
Action.clickByText("组队出行")
sleep(2)
if UIChecker.checkByText("服务协议"):
Action.clickByText("同意并继续")
Action.clickByText("创建队伍")
sleep(5)
Action.clickByText(input)
sleep(2)
Action.clickByText(input)
Action.setTextByResourceId(BaiduMap.Input_via_id, "世界之窗")
# Action.setTextByResourceId(BaiduMap.Input_via_id, "最好用的导航")
sleep(3)
Action.clickByResourceId(BaiduMap.Poi_gobtn_id)
sleep(3)
Judge.passIf(self, UIChecker.checkByTextContains("同步终点"), "设置组队出行目的地")
Action.clickByText("同步终点")
sleep(2)
@unittest.skip('no need')
def test_100(self):
"""进入组队出行,进行抢麦
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_teamtrip_page()
Action.clickByText("组队出行")
sleep(1)
if UIChecker.checkByText("服务协议"):
Action.clickByText("同意并继续")
Action.clickByText("创建队伍")
sleep(5)
Action.clickByText("点击说话")
sleep(1)
Judge.passIf(self, UIChecker.checkByTextContains("准备中"), "进行抢麦")
@unittest.skip("no need")
def test_101(self):
"""抢麦后点击返回键结束抢麦
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_teamtrip_page()
Action.clickByText("组队出行")
sleep(1)
if UIChecker.checkByText("服务协议"):
Action.clickByText("同意并继续")
Action.clickByText("创建队伍")
sleep(5)
Action.clickByText("点击说话")
Action.adb_cmd("adb shell input keyevent 4")
if UIChecker.checkByText("确认要停止讲话吗"):
Action.clickByText("确认")
Judge.passIf(self, UIChecker.checkByTextContains("组队出行"), "结束抢麦")
def test_102(self):
"""进入路线规划页,切换成时间偏好并导航
"""
basemap.enter_map()
basemap.enter_routeplan()
Action.clickByResourceId(BaiduMap.Route_down_id)
Action.clickByText("时间优先")
sleep(2)
basemap.click_agree_buttom()
basemap.close_navi()
sleep(1)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_103(self):
"""进入路线规划页,切换成少收费并导航
"""
basemap.enter_map()
basemap.enter_routeplan()
Action.clickByResourceId(BaiduMap.Route_down_id)
Action.clickByText("少收费")
sleep(2)
basemap.click_agree_buttom()
basemap.close_navi()
sleep(1)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_104(self):
"""进入路线规划页,切换成躲避拥堵并导航
"""
basemap.enter_map()
basemap.enter_routeplan()
Action.clickByResourceId(BaiduMap.Route_down_id)
Action.clickByText("躲避拥堵")
sleep(2)
basemap.click_agree_buttom()
basemap.close_navi()
sleep(1)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_105(self):
"""进入路线规划页,切换成不走高速并导航
"""
basemap.enter_map()
basemap.enter_routeplan()
Action.clickByResourceId(BaiduMap.Route_down_id)
Action.clickByText("不走高速")
sleep(2)
basemap.click_agree_buttom()
basemap.close_navi()
sleep(1)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_106(self):
"""进入路线规划页,切换成高速优先并导航
"""
basemap.enter_map()
basemap.enter_routeplan()
Action.clickByResourceId(BaiduMap.Route_down_id)
Action.clickByText("高速优先")
sleep(2)
basemap.click_agree_buttom()
basemap.close_navi()
sleep(1)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_107(self):
"""进行sug检索
"""
basemap.enter_map()
basemap.enter_poi_search("世界之窗")
sleep(3)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Poi_gobtn_id), "sug检索")
def test_108(self):
"""进行精确匹配搜索
"""
basemap.enter_map()
basemap.enter_poi_search("世界之窗")
sleep(1)
Action.clickByText("搜索")
sleep(3)
Judge.passIf(self, UIChecker.checkByTextContains("世界之窗"), "进行精确匹配检索")
def test_109(self):
"""检索不到结果
"""
basemap.enter_map()
basemap.enter_poi_search("****&?")
sleep(1)
Action.clickByText("搜索")
sleep(2)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Search_nothing_id), "检索不到结果")
def test_110(self):
"""清空历史记录
"""
basemap.enter_map()
basemap.enter_poi_search("世界之窗")
sleep(1)
Action.clickByText("搜索")
sleep(3)
Action.adb_cmd("adb shell input keyevent 4")
Action.adb_cmd("adb shell input keyevent 4")
Judge.passIf(self, UIChecker.checkByTextContains("清空历史记录"), "一次检索")
Action.clickByText("清空历史记录")
sleep(1)
Action.clickByText("确定")
Judge.passUnless(self, UIChecker.checkByTextContains("清空历史记录"), "确认清空历史记录")
def test_111(self):
"""跨市导航
"""
basemap.enter_map()
sleep(2)
basemap.enter_poi_and_navi("广州南站")
Action.clickByText("搜索")
sleep(2)
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_112(self):
"""跨省导航
"""
basemap.enter_map()
basemap.enter_poi_search("张家界")
# basemap.enter_poi_and_navi("张家界")
if UIChecker.checkByResourceId(BaiduMap.Quit_btn_id):
Action.clickByResourceId(BaiduMap.Quit_btn_id)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.First_location_id), "退出导航")
def test_113(self):
"""进入POI详情页
"""
basemap.enter_map()
basemap.enter_poi_search("广州大学城")
sleep(3)
Action.clickByText("搜索")
sleep(3)
Action.clickByResourceId(BaiduMap.Poi_title_id)
sleep(1)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Search_around_id), "进入POI详情页")
def test_114(self):
"""搜索结果包含多城市
"""
basemap.enter_map()
basemap.enter_poi_search("迪士尼乐园")
sleep(3)
Action.clickByText("搜索")
sleep(3)
Judge.passIf(self, UIChecker.checkByTextContains("请选择下列城市进行搜索"), "搜索结果包含多城市")
def test_115(self):
"""电话搜索
"""
basemap.enter_map()
basemap.enter_poi_search("10086")
sleep(3)
Judge.passIf(self, UIChecker.checkByTextContains("移动营业厅"), "电话搜索")
def test_116(self):
"""切换黑夜模式
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByText("黑夜")
Action.adb_cmd("adb shell input keyevent 4")
basemap.enter_poi_and_navi("世界之窗")
def test_117(self):
"""导航前切换到静音,导航中打开声音
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByText("静音")
Action.adb_cmd("adb shell input keyevent 4")
basemap.enter_poi_and_navi("世界之窗")
Action.swipeLeftAtCenter()
Action.waiting(1)
Action.clickByResourceId(BaiduMap.Traffic_voice_id)
sleep(1)
Judge.passIf(self, UIChecker.checkByTextWait("已开启“导航声音”"), "开启导航声音")
def test_118(self):
"""点击去公司按钮,进行导航
"""
basemap.enter_map()
input = "输入目的地"
Action.clickByText(input)
Action.clickByText("去公司")
# if UIChecker.checkByTextWait(input):
# sleep(1)
# Action.setTextByResourceId(BaiduMap.Input_via_id, "世界之窗")
# sleep(5)
# Action.clickByResourceId(BaiduMap.Search_jc_id)
# sleep(3)
# Judge.passIf(self, UIChecker.checkByTextWait("去公司"), "设置公司地址")
# Action.clickByText("去公司")
sleep(5)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Start_navigation), "跳转到路线规划界面")
Action.clickByResourceId(BaiduMap.Start_navigation)
Judge.passIf(self, UIChecker.checkByText('同意'), "百度地图导航使用提示页面")
Action.clickByText('同意')
# basemap.click_agree_buttom()
basemap.close_navi()
# sleep(5)
# Judge.passIf(self, UIChecker.checkByTextWait("开始导航"), "跳转到路线规划界面")
# basemap.click_agree_buttom()
# basemap.close_navi()
def test_119(self):
"""连续点击比例尺放大,缩小按钮,再点击定位按钮
"""
basemap.enter_map()
Action.clickByResourceId(BaiduMap.Traffic_btn_id)
for i in range(10):
Action.clickByResourceId(BaiduMap.Zoom_out_id)
for i in range(10):
Action.clickByResourceId(BaiduMap.Zoom_in_id)
sleep(2)
Action.clickByResourceId(BaiduMap.First_location_id)
sleep(2)
Judge.passIf(self, UIChecker.checkByResourceId(BaiduMap.Search_around_id), "点击定位按钮")
def test_120(self):
"""进入导航设置,设置播报模式静音
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByText("播报模式")
sleep(2)
Action.clickByText("静音")
def test_121(self):
"""进入导航设置,设置播报模式简洁
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByText("播报模式")
sleep(2)
Action.clickByText("简洁")
def test_122(self):
"""进入导航设置,设置播报模式详细
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByText("播报模式")
sleep(2)
Action.clickByText("详细")
def test_123(self):
"""进入导航设置,设置在线算路优先关闭
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByScrollText("在线算路优先")
# sleep(2)
Action.clickResourceIdChildClassAndIndex('com.baidu.naviauto:id/bt_routplan_mode',
'android.widget.RadioButton',
1)
# Action.clickByText("关闭")
def test_124(self):
"""进入导航设置,设置自动切换巡航模式关闭
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByScrollText("自动切换巡航")
# sleep(2)
Action.clickResourceIdChildClassAndIndex('com.baidu.naviauto:id/bt_auto_cruiser',
'android.widget.RadioButton',
1)
Action.clickByText("关闭")
def test_125(self):
"""进入导航设置,设置隐私模式开启
"""
basemap.enter_map()
basemap.enter_settings()
basemap.enter_navi_settings()
Action.clickByScrollText("隐私模式")
# sleep(2)
Action.clickResourceIdChildClassAndIndex('com.baidu.naviauto:id/bt_privacy_mode',
'android.widget.RadioButton',
1)
# Action.clickByText("开启")
class sendEmail:
def sendemail(self):
# msg = email.mime.multipart.MIMEMultipart()
# msg[‘from’] = ‘shixinfa@baidu.com’
# msg[‘to’] = ‘shixinfa@baidu.com’
msg = MIMEMultipart()
tolist = [‘v_wangjiwei01@baidu.com’, ‘shixinfa@baidu.com’, ‘jinghenan@baidu.com’]
msg[‘from’] = ‘v_wangjiwei01@baidu.com’
msg[‘to’] = ‘,’.join(tolist)
msg[‘subject’] = “测试邮件”
content = “测试邮件内容”
txt = email.mime.text.MIMEText(content, ‘plain’, ‘utf-8’)
msg.attach(txt)
# 添加附件地址
part = MIMEApplication(open(r’/Users/v_wangjiwei01/Desktop/report.html’, ‘rb’).read())
part.add_header(‘Content-Disposition’, ‘attachment’, filename=“UI自动化测试结果111.html”) # 发送文件名称
msg.attach(part)
smtp = smtplib.SMTP()
smtp.connect('proxy-in.baidu.com', '25')
smtp.sendmail(msg['from'], tolist, str(msg))
print("发送成功!")
if name == ‘main’:
suite = unittest.TestSuite()
# #####suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestStringMethods))
suite.addTest(TestStringMethods('test_onlineCalculation_searchPages'))
suite.addTest(TestStringMethods('test_offlineCalculation_searchPages'))
suite.addTest(TestStringMethods('test_goHome_goCompany'))
suite.addTest(TestStringMethods('test_search_cityName'))
suite.addTest(TestStringMethods('test_city_calculateRoad'))
suite.addTest(TestStringMethods('test_no_high_speed'))
suite.addTest(TestStringMethods('test_high_speed_priority'))
suite.addTest(TestStringMethods('test_avoid_congestion'))
suite.addTest(TestStringMethods('test_priority_time'))
suite.addTest(TestStringMethods('test_intelligent_recommendation'))
suite.addTest(TestStringMethods('test_selectionPage_detailsPage_information'))
suite.addTest(TestStringMethods('test_openClose_naviSound'))
suite.addTest(TestStringMethods('test_route_preference'))
suite.addTest(TestStringMethods('test_incident_reporting'))
suite.addTest(TestStringMethods('test_searchAlong_theWay'))
suite.addTest(TestStringMethods('test_global_mode_switch'))
suite.addTest(TestStringMethods('test_page_display'))
suite.addTest(TestStringMethods('test_clickAgree_disclaimerPage'))
suite.addTest(TestStringMethods('test_clickNoAgree_disclaimerPage'))
suite.addTest(TestStringMethods('test_set_home_address'))
suite.addTest(TestStringMethods('test_set_company_address'))
suite.addTest(TestStringMethods('test_switch_browse_mode'))
suite.addTest(TestStringMethods('test_input_keywords'))
suite.addTest(TestStringMethods('test_keyword_search'))
suite.addTest(TestStringMethods('test_click_sug_search'))
suite.addTest(TestStringMethods('test_passing_point_icon'))
suite.addTest(TestStringMethods('test_routePoint_inputDestination'))
suite.addTest(TestStringMethods('test_team_management'))
suite.addTest(TestStringMethods('test_team_name_modification'))
suite.addTest(TestStringMethods('test_favorites_set_company_address'))
suite.addTest(TestStringMethods('test_favorites_set_home_address'))
suite.addTest(TestStringMethods('test_favorites_del_home_address'))
suite.addTest(TestStringMethods('test_favorites_del_company_address'))
suite.addTest(TestStringMethods('test_del_favorites_address'))
suite.addTest(TestStringMethods('test_i_want_report'))
suite.addTest(TestStringMethods('test_i_want_report5'))
suite.addTest(TestStringMethods('test_i_want_report1'))
suite.addTest(TestStringMethods('test_i_want_report2'))
suite.addTest(TestStringMethods('test_i_want_report3'))
suite.addTest(TestStringMethods('test_i_want_report4'))
suite.addTest(TestStringMethods('test_i_want_report6'))
suite.addTest(TestStringMethods('test_i_want_report7'))
suite.addTest(TestStringMethods('test_i_want_report8'))
suite.addTest(TestStringMethods('test_i_want_report9'))
suite.addTest(TestStringMethods('test_i_want_report10'))
suite.addTest(TestStringMethods('test_i_want_report11'))
suite.addTest(TestStringMethods('test_i_want_report12'))
suite.addTest(TestStringMethods('test_i_want_report13'))
suite.addTest(TestStringMethods('test_i_want_report14'))
suite.addTest(TestStringMethods('test_i_want_report15'))
suite.addTest(TestStringMethods('test_i_want_report17'))
suite.addTest(TestStringMethods('test_i_want_report18'))
suite.addTest(TestStringMethods('test_i_want_report19'))
suite.addTest(TestStringMethods('test_i_want_report20'))
suite.addTest(TestStringMethods('test_i_want_report21'))
suite.addTest(TestStringMethods('test_i_want_report22'))
suite.addTest(TestStringMethods('test_i_want_report23'))
suite.addTest(TestStringMethods('test_i_want_report24'))
suite.addTest(TestStringMethods('test_i_want_report25'))
suite.addTest(TestStringMethods('test_i_want_report26'))
suite.addTest(TestStringMethods('test_i_want_report27'))
suite.addTest(TestStringMethods('test_delete_voice_package'))
suite.addTest(TestStringMethods('test_download_voice_package'))
suite.addTest(TestStringMethods('test_download_status_display'))
suite.addTest(TestStringMethods('test_preference_message_notification'))
suite.addTest(TestStringMethods('test_searchAlongTheWay_gasStation'))
suite.addTest(TestStringMethods('test_searchAlongTheWay_atm'))
suite.addTest(TestStringMethods('test_searchAlongTheWay_chargingStation'))
suite.addTest(TestStringMethods('test_searchAlongTheWay_frontBackSwitch'))
suite.addTest(TestStringMethods('test_auto_day_nightMode'))
suite.addTest(TestStringMethods('test_voic_avoidCongestion'))
suite.addTest(TestStringMethods('test_voic_noHighSpeedRoute'))
suite.addTest(TestStringMethods('test_voic_chargeLess'))
suite.addTest(TestStringMethods('test_voic_highSpeedPriority'))
suite.addTest(TestStringMethods('test_openRoad'))
suite.addTest(TestStringMethods('test_closeRoad'))
suite.addTest((TestStringMethods('test_switchFollowMode')))
suite.addTest(TestStringMethods('test_switchDueNorthMode'))
suite.addTest(TestStringMethods('test_switch2DMode'))
suite.addTest(TestStringMethods('test_switch3DMode'))
suite.addTest(TestStringMethods('test_switchDayMode'))
suite.addTest(TestStringMethods('test_switchNightMode'))
suite.addTest(TestStringMethods('test_zoomInMap'))
suite.addTest(TestStringMethods('test_zoomOutMap'))
suite.addTest(TestStringMethods('test_HomeUIDisplay'))
suite.addTest(TestStringMethods('test_morePanels_UIDisplay'))
suite.addTest(TestStringMethods('test_packUp_morePanels'))
suite.addTest(TestStringMethods('test_morePanels_clickSearch'))
suite.addTest(TestStringMethods('test_favorites_page'))
suite.addTest(TestStringMethods('test_search_record_display'))
suite.addTest(TestStringMethods('test_click_clearHistory'))
suite.addTest(TestStringMethods('test_clear_cache_page_display'))
suite.addTest(TestStringMethods('test_clear_cache'))
suite.addTest(TestStringMethods('test_clear_cache_field_display'))
suite.addTest(TestStringMethods('test_cacheDataIs0_click_clear_cache'))
#suite.addTest(unittest.makeSuite(test_mapauto.MyTest))
# with open(r'/Users/v_wangjiwei01/Desktop/report01.html', 'wb') as fp:
# runner = TestRunner(fp, title='Phase4UITest', description='Phase4UITestDetail', verbosity=2)
# runner.run(suite)
# emais = sendEmail()
# emais.sendemail()