diff --git a/cases/smoke/basic/screenshot32/new_script/conftest.py b/cases/smoke/basic/screenshot32/new_script/conftest.py index f15260d0..5a57933b 100644 --- a/cases/smoke/basic/screenshot32/new_script/conftest.py +++ b/cases/smoke/basic/screenshot32/new_script/conftest.py @@ -23,7 +23,7 @@ def setup_teardown(request, device): logging.info('前置操作') current_case = os.path.basename(request.path)[:-3] # 日志截图等保存路径 - device.report_path = os.path.realpath(os.path.join(os.path.dirname(request.config.option.htmlpath), current_case)) + device.report_path = os.path.realpath(os.path.dirname(request.config.option.htmlpath)) logging.info('设置当前用例的报告路径为{}'.format(device.report_path)) device.resource_path = os.path.join(os.path.dirname(__file__), 'resource') os.makedirs(device.report_path, exist_ok=True) diff --git a/cases/smoke/basic/screenshot32/new_script/main.py b/cases/smoke/basic/screenshot32/new_script/main.py index a31a0d43..d2fbbb74 100644 --- a/cases/smoke/basic/screenshot32/new_script/main.py +++ b/cases/smoke/basic/screenshot32/new_script/main.py @@ -2,8 +2,6 @@ import argparse import json import os.path import re -import shutil -import socket import traceback import pytest @@ -11,18 +9,6 @@ import pytest BASE_DIR = os.path.dirname(__file__) -def report_content(sn, pr): - hostname = socket.gethostname() - ipaddress = socket.gethostbyname(hostname) - return [ - '--report=_{}_reports.html'.format(sn), - '--title=门禁冒烟测试报告', - '--tester={}'.format(ipaddress), - '--desc={}'.format(pr), - '--template=1' - ] - - def distribute_testcase(test_num): with open(os.path.join(BASE_DIR, 'testcases.json'), 'r', encoding='utf-8') as f: test_cases_list = [case.get('case_file') for case in json.load(f)] diff --git a/cases/smoke/basic/screenshot32/new_script/resource/contacts.jpeg b/cases/smoke/basic/screenshot32/new_script/resource/contacts.jpeg index a0f8a12d..b9deb3e0 100644 Binary files a/cases/smoke/basic/screenshot32/new_script/resource/contacts.jpeg and b/cases/smoke/basic/screenshot32/new_script/resource/contacts.jpeg differ diff --git a/cases/smoke/basic/screenshot32/new_script/resource/controller_center.jpeg b/cases/smoke/basic/screenshot32/new_script/resource/controller_center.jpeg index 5ce9e1d3..e024aa9c 100644 Binary files a/cases/smoke/basic/screenshot32/new_script/resource/controller_center.jpeg and b/cases/smoke/basic/screenshot32/new_script/resource/controller_center.jpeg differ diff --git a/cases/smoke/basic/screenshot32/new_script/resource/launcher.jpeg b/cases/smoke/basic/screenshot32/new_script/resource/launcher.jpeg index 1ca87a86..9c7019a8 100644 Binary files a/cases/smoke/basic/screenshot32/new_script/resource/launcher.jpeg and b/cases/smoke/basic/screenshot32/new_script/resource/launcher.jpeg differ diff --git a/cases/smoke/basic/screenshot32/new_script/resource/mms.jpeg b/cases/smoke/basic/screenshot32/new_script/resource/mms.jpeg index 09efe6ae..86b809ec 100644 Binary files a/cases/smoke/basic/screenshot32/new_script/resource/mms.jpeg and b/cases/smoke/basic/screenshot32/new_script/resource/mms.jpeg differ diff --git a/cases/smoke/basic/screenshot32/new_script/resource/note.jpeg b/cases/smoke/basic/screenshot32/new_script/resource/note.jpeg index d410238b..9dbfe98d 100644 Binary files a/cases/smoke/basic/screenshot32/new_script/resource/note.jpeg and b/cases/smoke/basic/screenshot32/new_script/resource/note.jpeg differ diff --git a/cases/smoke/basic/screenshot32/new_script/resource/photos.jpeg b/cases/smoke/basic/screenshot32/new_script/resource/photos.jpeg index 352a42af..2bf2a7cf 100644 Binary files a/cases/smoke/basic/screenshot32/new_script/resource/photos.jpeg and b/cases/smoke/basic/screenshot32/new_script/resource/photos.jpeg differ diff --git a/cases/smoke/basic/screenshot32/new_script/resource/settings.jpeg b/cases/smoke/basic/screenshot32/new_script/resource/settings.jpeg index 4defd7da..58195f73 100644 Binary files a/cases/smoke/basic/screenshot32/new_script/resource/settings.jpeg and b/cases/smoke/basic/screenshot32/new_script/resource/settings.jpeg differ diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_contacts.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_contacts.py index 49f8dd48..59de74b9 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases/test_contacts.py +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_contacts.py @@ -17,18 +17,18 @@ class Test: logging.info('联系人界面截图对比') standard_pic = os.path.join(device.resource_path, 'contacts.jpeg') - contacts_page_pic = device.save_snapshot_to_local('contacts.jpeg') + contacts_page_pic = device.save_snapshot_to_local('{}_contacts.jpeg'.format(device.sn)) crop_picture(contacts_page_pic) similarity = compare_image_similarity(contacts_page_pic, standard_pic) assert similarity > 0.5, '截图对比失败' - logging.info('联系人界面控件检查') - device.refresh_layout() - device.assert_text_exist('电话') - device.assert_text_exist('联系人') - device.assert_text_exist('收藏') - device.assert_text_exist('1') - device.assert_text_exist('3') - device.assert_text_exist('5') - device.assert_text_exist('7') - device.assert_text_exist('9') + # logging.info('联系人界面控件检查') + # device.refresh_layout() + # device.assert_text_exist('电话') + # device.assert_text_exist('联系人') + # device.assert_text_exist('收藏') + # device.assert_text_exist('1') + # device.assert_text_exist('3') + # device.assert_text_exist('5') + # device.assert_text_exist('7') + # device.assert_text_exist('9') diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_controller_center.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_controller_center.py index 0500c03e..503f1644 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases/test_controller_center.py +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_controller_center.py @@ -16,7 +16,7 @@ class Test: logging.info('控制中心界面截图对比') standard_pic = os.path.join(device.resource_path, 'controller_center.jpeg') - controller_page_pic = device.save_snapshot_to_local('controller_center.jpeg') + controller_page_pic = device.save_snapshot_to_local('{}_controller_center.jpeg'.format(device.sn)) crop_picture(controller_page_pic) similarity = compare_image_similarity(controller_page_pic, standard_pic) diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_distributed_musicplayer.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_distributed_musicplayer.py index 7cd940d2..82166020 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases/test_distributed_musicplayer.py +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_distributed_musicplayer.py @@ -18,14 +18,14 @@ class Test: device.stop_permission() logging.info('音乐界面截图对比') standard_pic = os.path.join(device.resource_path, 'distributedmusicplayer.jpeg') - music_page_pic = device.save_snapshot_to_local('distributedmusicplayer.jpeg') + music_page_pic = device.save_snapshot_to_local('{}_distributedmusicplayer.jpeg'.format(device.sn)) crop_picture(music_page_pic) similarity = compare_image_similarity(music_page_pic, standard_pic) assert similarity > 0.5, '截图对比失败' - logging.info('音乐界面控件检查') - device.refresh_layout() - device.assert_key_exist('image1') - device.assert_key_exist('image2') - device.assert_key_exist('image3') - device.assert_key_exist('image4') + # logging.info('音乐界面控件检查') + # device.refresh_layout() + # device.assert_key_exist('image1') + # device.assert_key_exist('image2') + # device.assert_key_exist('image3') + # device.assert_key_exist('image4') diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_launcher.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_launcher.py index 9e20e4e5..82f45d20 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases/test_launcher.py +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_launcher.py @@ -13,13 +13,11 @@ class Test: logging.info('桌面截图对比') # usb弹窗 device.click(360, 715) - device.dirc_fling(1) - device.dirc_fling(1) standard_pic = os.path.join(device.resource_path, 'launcher.jpeg') - launcher_pic = device.save_snapshot_to_local('launcher.jpeg') + launcher_pic = device.save_snapshot_to_local('{}_launcher.jpeg'.format(device.sn)) similarity = compare_image_similarity(launcher_pic, standard_pic) assert similarity > 0.5, '截图对比失败' - logging.info('检查桌面图标控件是否存在') - device.refresh_layout() - device.assert_type_exist('Badge') + # logging.info('检查桌面图标控件是否存在') + # device.refresh_layout() + # device.assert_type_exist('Badge') diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_mms.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_mms.py index 9efc1d3a..eaf7b4f0 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases/test_mms.py +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_mms.py @@ -17,11 +17,11 @@ class Test: logging.info('信息界面截图对比') standard_pic = os.path.join(device.resource_path, 'mms.jpeg') - mms_page_pic = device.save_snapshot_to_local('mms.jpeg') + mms_page_pic = device.save_snapshot_to_local('{}_mms.jpeg'.format(device.sn)) crop_picture(mms_page_pic) similarity = compare_image_similarity(mms_page_pic, standard_pic) assert similarity > 0.5, '截图对比失败' - logging.info('信息界面控件检查') - device.refresh_layout() - device.assert_text_exist('信息') + # logging.info('信息界面控件检查') + # device.refresh_layout() + # device.assert_text_exist('信息') diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_note.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_note.py index ed65b357..a876d51a 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases/test_note.py +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_note.py @@ -16,22 +16,22 @@ class Test: device.start_ability(self.bundle_name, self.ability_name) logging.info('点击数据公式') - device.refresh_layout() - - article = device.get_element_by_text('数学公式') - device.click_element(article) - time.sleep(0.5) + # device.refresh_layout() + # article = device.get_element_by_text('数学公式') + # device.click_element(article) + device.click(464, 313) + time.sleep(1) logging.info('点击笔记内容区域') - device.click(360, 300) + device.click(360, 325) time.sleep(3) standard_pic = os.path.join(device.resource_path, 'note.jpeg') - note_pic = device.save_snapshot_to_local('note.jpeg') + note_pic = device.save_snapshot_to_local('{}_note.jpeg'.format(device.sn)) crop_picture(note_pic) similarity = compare_image_similarity(note_pic, standard_pic) assert similarity > 0.5, '截图对比失败' - logging.info('导出笔记界面布局') - device.refresh_layout() - logging.info('控件检查') - device.assert_text_exist('好好学习,天天向上') - device.assert_text_exist('space') + # logging.info('导出笔记界面布局') + # device.refresh_layout() + # logging.info('控件检查') + # device.assert_text_exist('好好学习,天天向上') + # device.assert_text_exist('space') diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_photos.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_photos.py index 74927652..00b5d489 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases/test_photos.py +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_photos.py @@ -17,15 +17,15 @@ class Test: logging.info('图库界面截图对比') standard_pic = os.path.join(device.resource_path, 'photos.jpeg') - photos_page_pic = device.save_snapshot_to_local('photos.jpeg') + photos_page_pic = device.save_snapshot_to_local('{}_photos.jpeg'.format(device.sn)) crop_picture(photos_page_pic) similarity = compare_image_similarity(photos_page_pic, standard_pic) assert similarity > 0.5, '截图对比失败' - logging.info('图库界面控件检查') - device.refresh_layout() - device.assert_text_exist('照片') - device.assert_text_exist('相册') + # logging.info('图库界面控件检查') + # device.refresh_layout() + # device.assert_text_exist('照片') + # device.assert_text_exist('相册') logging.info('medialibrarydata进程检查') process = 'com.ohos.medialibrary.medialibrarydata' @@ -34,5 +34,5 @@ class Test: logging.info('sandbox path检查') pid = device.get_pid(process) - sanboxf = device.hdc_shell('echo "ls /storage/media/local/"|nsenter -t {} -m sh'.format(pid)) + sanboxf = device.hdc_shell('echo \"ls /storage/media/local/\"|nsenter -t {} -m sh'.format(pid)) assert 'files' in sanboxf, '{}中未检测到files'.format(sanboxf) diff --git a/cases/smoke/basic/screenshot32/new_script/testcases/test_settings_wifi.py b/cases/smoke/basic/screenshot32/new_script/testcases/test_settings_wifi.py index fffe9fd9..bb96e921 100644 --- a/cases/smoke/basic/screenshot32/new_script/testcases/test_settings_wifi.py +++ b/cases/smoke/basic/screenshot32/new_script/testcases/test_settings_wifi.py @@ -18,26 +18,28 @@ class Test: logging.info('设置界面截图对比') standard_pic = os.path.join(device.resource_path, 'settings.jpeg') - settings_page_pic = device.save_snapshot_to_local('settings.jpeg') + settings_page_pic = device.save_snapshot_to_local('{}_settings.jpeg'.format(device.sn)) crop_picture(settings_page_pic) similarity = compare_image_similarity(settings_page_pic, standard_pic) assert similarity > 0.5, '截图对比失败' - logging.info('设置界面控件检查') - device.refresh_layout() - device.assert_text_exist('设置') - device.assert_text_exist('WLAN') + # logging.info('设置界面控件检查') + # device.refresh_layout() + # device.assert_text_exist('设置') + # device.assert_text_exist('WLAN') logging.info('进入wlan页面') - wlan_element = device.get_element_by_text('WLAN') - device.click_element(wlan_element) - time.sleep(2) - device.refresh_layout() - wlan_switch = device.get_element_by_type('Toggle') + # wlan_element = device.get_element_by_text('WLAN') + # device.click_element(wlan_element) + device.click(160, 306) + time.sleep(1) + # device.refresh_layout() + # wlan_switch = device.get_element_by_type('Toggle') before_click = device.get_wifi_status().get('active') logging.info('打开/关闭 wlan开关') - device.click_element(wlan_switch) + # device.click_element(wlan_switch) + device.click(646, 210) time.sleep(5) after_click = device.get_wifi_status().get('active') logging.info('wlan开关状态变化:{} => {}'.format(before_click, after_click)) diff --git a/cases/smoke/basic/screenshot32/new_script/utils/device.py b/cases/smoke/basic/screenshot32/new_script/utils/device.py index e41bea67..e75dbf22 100644 --- a/cases/smoke/basic/screenshot32/new_script/utils/device.py +++ b/cases/smoke/basic/screenshot32/new_script/utils/device.py @@ -36,7 +36,7 @@ class Device: def hdc_shell(self, cmd): out = '' for i in range(3): - shell_cmd = f'hdc -t {self.sn} shell "{cmd}"' + shell_cmd = f'hdc -l0 -t {self.sn} shell "{cmd}"' out = self._execute_cmd(shell_cmd) if '[Fail]Device not founded or connected' in out: self.restart_hdc_process() @@ -46,7 +46,7 @@ class Device: return out def hdc(self, cmd): - return self._execute_cmd(f'hdc -t {self.sn} {cmd}') + return self._execute_cmd(f'hdc -l0 -t {self.sn} {cmd}') def hdc_version(self): return self._execute_cmd('hdc -v')