def test_1_sousuo(self): u"""搜索功能""" driver = self.driver sleep(2) try: driver.find_element_by_id( "com.edog.car:id/player_play_pause").click() #暂停 sleep(0.5) driver.find_element_by_id( "com.edog.car:id/navigation_search_radioButton").click() #点击搜索 sleep(0.5) driver.find_element_by_id( "com.edog.car:id/search_editText").send_keys("放生") sleep(0.5) driver.find_element_by_id( "com.edog.car:id/search_action_text_View").click() #搜索 sleep(0.5) driver.find_element_by_id( "com.edog.car:id/search_result_item_layout").click() #点击第一个 sleep(0.5) driver.find_element_by_id( "com.edog.car:id/player_prev").click() #上一曲 driver.find_element_by_id( "com.edog.car:id/player_next").click() #下一曲 driver.find_element_by_id( "com.edog.car:id/player_play_pause").click() driver.find_element_by_id( "com.edog.car:id/player_play_pause").click() # driver.find_element_by_id("com.edog.car:id/player_recommended_img").click() #好听推荐 # sleep(2) os.popen("adb shell input keyevent 3") #按home键退至后台播放 except Exception as e: screenshot(driver)
def test_restart(self): print("""重启压测脚本""") driver = self.driver sleep(2) count = 1 while (count < 100): print("重启次数为", count) screenshot(driver) os.popen("adb reboot") sleep(30) screenshot(driver) count = count + 1
def test_screen(self): u"""熄屏亮屏压测""" driver = self.driver sleep(2) count = 1 while (count < 50): print("熄屏操作") os.popen("adb shell input keyevent 26") sleep(2) print("亮屏操作") os.popen("adb shell input keyevent 26") screenshot(driver) sleep(3) count = count+1
def test_copart_search_nissan_find_models(self): filter_name = 'Model' car_make = "nissan" car_models = ["altima", "maxima", "skyline", "fail_this"] shooter = screenshot(self.driver) for car_model in car_models: # Search for car make hsearch = header_search(self.driver) self.assertTrue(hsearch.search_for(car_make)) # Search car models using filters test_name = inspect.stack()[1][3] + '_' + car_make + '_' + car_model fl = filt(self.driver, filter_name) try: self.assertTrue(fl.enter_and_verify_filter_search(car_model)) except NoSuchElementException as e: print(e) print("Looking for listings for {} {}".format(car_make, car_model)) shooter.take_screenshot(test_name) except IndexError as e: print(e) print("Looking for listings for {} {}".format(car_make, car_model)) shooter.take_screenshot(test_name) except Exception as e: print(e) print("Looking for listings for {} {}".format(car_make, car_model)) shooter.take_screenshot(test_name)
def test_challenge6(self): hs = headerSearch(self.driver) hs.serachFor("nissan") f = filters() f.clickFilter("Model") s = screenshot() s.takescreenshot("Skyline") sr = searchResults() sr.changeDropDown("100")
def test_wifi(self): print("wifi") driver = self.driver for i in range(10): count = i try: driver.find_element_by_id( "cn.yunovo.car.settings:id/wlan").click() sleep(3) wifiSwitch = driver.find_element_by_id( "cn.yunovo.car.settings:id/thumb") wifiSwitch.click() wifiSwitch.click() #sleep(1) count = count + 1 print("开关压力测试次数为:", count) except Exception as e: screenshot(driver) continue
def test_pair(self): u"""蓝牙电话:蓝牙配对""" driver = self.driver sleep(3) driver.find_element_by_id('cn.yunovo.nxos.bt:id/btn_pairs').click() sleep(1) for i in range(10): count = i try: pairSwitch = driver.find_element_by_id( "cn.yunovo.nxos.bt:id/pair_bt_switch") for i in range(2): pairSwitch.click() #sleep(1) count = count + 1 print("开关压力测试次数为:", count) except Exception as e: screenshot(driver) continue
def test_kw_kl_st(self): print("打开酷我音乐") driver = self.driver count = 1 while (count < 100): print("切换次数为", count) try: os.popen("adb shell am start -n cn.kuwo.kwmusiccar/cn.kuwo.kwmusiccar.WelcomeActivity") # 打开酷我 #os.popen("adb shell input keyevent 3") #切换至后台 sleep(4) os.popen("adb shell am start -n com.edog.car/com.kaolafm.auto.home.MainActivity") # 打开考拉电台 sleep(1) os.popen("adb shell am start -n cn.yunovo.car.settings/cn.yunovo.car.settings.SettingsListActivity") # 打开设置 sleep(1) os.popen("adb shell am start -n cn.yunovo.nxos.bt/cn.yunovo.nxos.bt.activitys.BluetoothActivity") # 打开蓝牙电话 sleep(1) os.popen("adb shell am start -n com.aispeech.aios/.MainActivity") #打开语音助手 sleep(1) driver.back() sleep(2) count = count + 1 except Exception as e: screenshot(driver) continue
def test_kaiqdaohang(self): """开启导航模式""" count = 1 while (count < 3): driver = self.driver print("测试次数为:", count) source = open( "C:\\Users\\admin\\Desktop\\appautoTest\\common\\dizhicanshuhua.txt", "r") values = source.readlines() source.close() try: for dizhi in values: pass_1 = False print("""模拟导航""") try: driver.find_element_by_class_name( "android.widget.TextView[@text='高德地图使用提示']").click( ) # 判断是否第一次使用地图时的使用提示界面 sleep(3) driver.find_element_by_class_name( "android.widget.TextView[@text='不在提示']").click( ) # 勾选不在提示 sleep(3) driver.find_element_by_class_name( "android.widget.TextView[@text='同意']").click( ) # 点击同意 except: pass_1 = True sleep(5) driver.find_element_by_id( "com.autonavi.amapauto:id/siv_arrow").click( ) # 点击三角导航图标 # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_home").click() #回家 # sleep(1) # driver.back() # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_company").click() #去公司 # sleep(1) # driver.back() # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_collected").click() #收藏点 # sleep(1) # driver.back() # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_bathroom").click() #卫生间 # sleep(5) # driver.back() # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_gas_station").click() #加油站 # sleep(5) # driver.back() # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_parking").click() #停车场 # sleep(5) # driver.back() # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_cleancar").click() #洗车 # sleep(5) # driver.back() # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_maintenance").click() #汽车维修 # sleep(5) # driver.back() # sleep(1) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_more").click() #更多 # sleep(0.5) # driver.find_element_by_id("com.autonavi.amapauto:id/cl_auto_search_more_group_view").click() # sleep(2) # print("""向上滑动""") # scrollXpath = '//*[@resource-id="com.autonavi.amapauto:id/elv_search_category_listview"]' # scrollView = driver.find_element_by_xpath(scrollXpath) # scrollViewSize = scrollView.size # scrollViewSize1 = scrollView.location # scrollViewSize2 = scrollView.rect # print(scrollViewSize) # print(scrollViewSize1) # print(scrollViewSize2) # x1 = scrollViewSize['width'] * 0.5 # y1 = scrollViewSize['height'] * 0.75 # y2 = scrollViewSize['height'] * 0.25 # # print(x1, y1, y2) # for i in range(1): # driver.swipe(x1, y1, x1, y2, 1000) # sleep(2) # driver.back() sleep(3) driver.find_element_by_id( "com.autonavi.amapauto:id/stv_text_title_hint").click( ) sleep(2) driver.find_element_by_id( "com.autonavi.amapauto:id/set_search_around" ).send_keys(dizhi) sleep(3) driver.find_element_by_id( "com.autonavi.amapauto:id/cl_auto_search_history_listview_item" ).click() # 选择目的地 sleep(4) driver.find_element_by_id( "com.autonavi.amapauto:id/cl_search_result_btn").click( ) # 点击去这里按钮 sleep(8) driver.find_element_by_id( "com.autonavi.amapauto:id/stv_auto_panel_content_title_des" ).click() sleep(2) driver.find_element_by_id( "com.autonavi.amapauto:id/stv_text_startnavi").click( ) # 模拟导航 sleep(2) driver.back() sleep(3) driver.find_element_by_id( "com.autonavi.amapauto:id/stv_text_go").click( ) # 点击开始导航 sleep(3) driver.back() # 返回键 sleep(1) driver.find_element_by_id( "com.autonavi.amapauto:id/cbm_left_btn_bg").click( ) # 点击确定按钮 count = count + 1 except Exception as e: screenshot(driver) continue