def test_shape_attr1(self): logging.info('==========test_shape_attr1==========') cv = CreateView(self.driver) cv.create_file('ss', 0) gv = GeneralView(self.driver) gv.group_button_click('插入') type = 'ss' gv.insert_shape('ss', 1) time.sleep(1) gv.tap(700, 767, 4) # 双击进入编辑 for i in range(100): self.driver.press_keycode(random.randint(7, 16)) gv.group_button_click('编辑') gv.shape_option(type, 5, width=5, height=5) gv.shape_option(type, 6, top=0.5, bottom=0.5, left=0.5, right=0.5) ele1 = '//*[@resource-id="com.yozo.office:id/yozo_ui_ss_option_id_shape_quick_function"]' ele2 = '//*[@text="轮廓"]' ele3 = '//*[@text="效果"]' gv.swipe_ele(ele2, ele1) gv.swipe_ele(ele3, ele2) gv.shape_content_align(type, '右对齐', '下对齐') gv.shape_content_align(type) gv.shape_content_align(type, '水平居中', '垂直居中') time.sleep(3)
def test_ss_filter1(self): logging.info('==========test_ss_filter1==========') gv = GeneralView(self.driver) ss = SSView(self.driver) cv = CreateView(self.driver) cv.create_file(self.file_type) gv.group_button_click(' View ') self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_filter').click() tip = self.driver.find_element(By.ID, 'com.yozo.office.en:id/text_content') self.assertTrue(tip != None) self.driver.find_element(By.ID, 'com.yozo.office.en:id/btn_right').click() ss.cell_edit() x, y, width, height = ss.cell_location() self.driver.press_keycode(15) self.driver.press_keycode(7) self.driver.press_keycode(7) self.driver.press_keycode(7) gv.tap(x + width / 2, y - height / 2) gv.group_button_click(' View ') self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_filter').click() state = self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_option_group_checkbox_switch').text self.assertTrue(state == 'ON') print(x, y) gv.tap(x + width - 10, y + height)
def test_ppt_insert_new(self): logging.info('==========test_ppt_insert_new==========') cv = CreateView(self.driver) cv.create_file('pg') logging.info('==========insert new ppt==========') pv = PGView(self.driver) pv.insert_new_ppt() gv = GeneralView(self.driver) gv.fold_expand() logging.info('==========validate insert success==========') thumbnails_list = self.driver.find_elements(By.CLASS_NAME, 'android.view.View') thumbnails_list[0].click() pv.screenshot_edit_ppt(SEREEN_SHOTS + 'new_first.png') thumbnails_list[1].click() pv.screenshot_edit_ppt(SEREEN_SHOTS + 'new_second.png') result1 = gv.compare_pic('first.png', 'new_first.png') result2 = gv.compare_pic('new_second.png', 'new_ppt.png') self.assertEqual(result1, 0.0) self.assertEqual(result2, 0.0) logging.info('==========delete pngs==========') os.remove(SEREEN_SHOTS + 'first.png') os.remove(SEREEN_SHOTS + 'new_first.png') os.remove(SEREEN_SHOTS + 'new_second.png')
def test_wp_shape_pop_menu_all(self, type1='wp'): cv = CreateView(self.driver) cv.create_file(type1) wp = WPView(self.driver) time.sleep(1) wp.pinch() wp.group_button_click(' Insert ') wp.insert_shape(type1, index=3) wp.fold_expand() touch(wp.template_object('rotate_free.png')) touch(wp.template_object('editText.png')) # 编辑文字 touch(wp.template_object('rotate_free.png')) touch(wp.template_object('copy.png')) # 复制 touch(wp.template_object('rotate_free.png')) touch(wp.template_object('cut.png')) # 剪切 touch(wp.template_object('point.png')) touch(wp.template_object('paste.png')) # 粘贴 touch(wp.template_object('rotate_free.png')) swipe(wp.template_object('editText.png'), wp.template_object('copy.png')) touch(wp.template_object('rotate_90.png')) touch(wp.template_object('rotate_free.png')) touch(wp.template_object('delete.png')) # 删除 time.sleep(10)
def test_ss_cell_select(self): logging.info('==========test_ss_cell_select==========') cv = CreateView(self.driver) ss = SSView(self.driver) cv.create_file('ss') ss.cell_edit() self.driver.press_keycode(45) self.driver.press_keycode(45) self.driver.press_keycode(45) self.driver.press_keycode(45) self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click() gv = GeneralView(self.driver) gv.group_button_click(' Edit ') gv.font_name(self.file_type) gv.font_size(23) gv.font_style(self.file_type, '加粗') gv.font_style(self.file_type, '倾斜') gv.font_style(self.file_type, '删除线') gv.font_style(self.file_type, '下划线') gv.font_color(self.file_type) ele = '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ss.swipe_options(ele, 'up') ss.cell_color() ss.cell_align('水平居中', '下对齐')
def test_shape_attr(self, type): logging.info('==========test_shape_attr==========') cv = CreateView(self.driver) cv.create_file(type) gv = GeneralView(self.driver) gv.group_button_click('插入') gv.insert_shape(type, 6, 30) gv.shape_insert(type, 6, 31) gv.shape_insert(type, 6, 32) gv.shape_insert(type, 6, 33) gv.shape_option(type, 2) gv.shape_fill_color(type, 6, 24) gv.shape_fill_color_transparency(5) ele1 = '//*[@resource-id="com.yozo.office:id/yozo_ui_%s_option_id_shape_quick_function"]' % type ele2 = '//*[@text="轮廓"]' gv.swipe_ele(ele2, ele1) gv.shape_border_color(type, 6, 5) gv.shape_border_type(type, 6, 3) gv.shape_border_width(type, 6, 20) ele3 = '//*[@text="效果"]' gv.swipe_ele(ele3, ele2) gv.shape_effect_type(type, 6, 4, 5) gv.shape_layer('下移一层') gv.shape_layer('置于底层') gv.shape_layer('上移一层') gv.shape_layer('置于顶层') time.sleep(3)
def test_share_editFile(self, share_info): """ 编辑文档分享 :param share_info: 分享相关信息,'wp_wx', 'wp_qq', 'wp_ding', 'wp_mail'.. :return: None """ logging.info('==========test_share_newFile==========') file_type = share_info.split('_')[0] share_type = share_info.split('_')[1] logging.info('==========edit and save File==========') ov = OpenView(self.driver) ov.open_random_file(SEARCH_DICT[file_type]) gv = GeneralView(self.driver) self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_toolbar_button_mode').click() gv.group_button_click(' Insert ') gv.insert_shape(file_type, 1) cv = CreateView(self.driver) cv.save_file() self.assertTrue(cv.get_toast_message('Saved to local')) logging.info('==========share new File==========') gv = GeneralView(self.driver) gv.share_file(file_type, share_type)
def test_wp_shape_text_attr(self): # 自选图形文本属性,仅WP和PG logging.info('==========test_wp_shape_text_attr==========') cv = CreateView(self.driver) cv.create_file(self.file_type) gv = GeneralView(self.driver) gv.group_button_click(' Insert ') gv.insert_shape(self.file_type, 1) gv.tap(680, 750) gv.pop_menu_click('editText') time.sleep(1) gv.group_button_click(' Edit ') gv.font_name(self.file_type, 'AndroidClock') gv.font_size(15) gv.font_style(self.file_type, '倾斜') gv.font_color(self.file_type, 6, 29) gv.swipe_ele('//*[@text=" Font Color "]', '//*[@text=" Edit "]') time.sleep(1) for i in range(20): self.driver.press_keycode(random.randint(29, 54)) time.sleep(1) gv.swipe_ele('//*[@text=" Highlight Color "]', '//*[@text=" Edit "]') gv.drag_coordinate(680, 750, 680, 600) gv.high_light_color(self.file_type, 6, random.randint(1, 15)) gv.bullets_numbers(self.file_type, 6, 10) gv.text_align(self.file_type, '分散对齐') gv.text_align(self.file_type, '右对齐') gv.text_line_space(self.file_type, 1.5) gv.text_line_space(self.file_type, 3) gv.text_indent(self.file_type, '右缩进') gv.text_indent(self.file_type, '右缩进') gv.text_indent(self.file_type, '左缩进') time.sleep(3)
def wp_insert_one_table(self): logging.info('==========wp_insert_one_table==========') cv = CreateView(self.driver) cv.create_file('wp') wp = WPView(self.driver) wp.group_button_click(' Insert ') wp.insert_example_table()
def test_ppt_play_to_last(self, play_type): logging.info('==========test_ppt_play_to_last==========') cv = CreateView(self.driver) cv.create_file('pg') pg = PGView(self.driver) pg.add_new() pg.add_new() logging.info('==========play to the last page==========') pg = PGView(self.driver) pg.group_button_click(' Play ') pg.play_mode(play_type) if play_type == 'first': index = 1 else: index = 3 pg.play_to_last(index, 3) logging.info('==========validate toast==========') try: toast = self.driver.find_element( By.XPATH, '//*[@text="It has been the last slide."]') except NoSuchElementException: self.assertTrue(False, '未出现弹窗') else: self.assertEqual(toast.text, 'It has been the last slide.', '验证弹窗信息为已是简报尾页')
def test_wp_font_attr(self): logging.info('==========test_wp_font_attr===========') cv = CreateView(self.driver) cv.create_file(self.file_type) time.sleep(1) wp = WPView(self.driver) wp.group_button_click(' Edit ') wp.font_size(16) wp.font_style(self.file_type, '倾斜') wp.font_color(self.file_type, 3) ele1 = '//*[@text=" Edit "]' ele2 = '//*[@text=" Font Color "]' ele3 = '//*[@text=" Highlight Color "]' ele4 = '//*[@text=" Columns "]' wp.swipe_ele(ele2, ele1) time.sleep(1) wp.tap(450, 450) for i in range(100): self.driver.press_keycode(random.randint(29, 54)) wp.group_button_click(' Edit ') wp.drag_coordinate(450, 500, 200, 500) wp.high_light_color(self.file_type, 3) wp.bullets_numbers(self.file_type, 6, 14) wp.text_align(self.file_type, '右对齐') wp.swipe_ele(ele3, ele1) wp.text_line_space(self.file_type, 2.5) wp.text_indent(self.file_type, '右缩进') wp.swipe_ele(ele4, ele1) wp.text_columns(4) wp.text_columns(3) wp.text_columns(2) time.sleep(3)
def test_shape_text_attr_pg(self): # 自选图形文本属性,仅WP和PG logging.info('==========test_shape_text_attr_pg==========') cv = CreateView(self.driver) cv.create_file(self.file_type) gv = GeneralView(self.driver) gv.group_button_click(' Insert ') gv.insert_shape(self.file_type, 1) gv.group_button_click(' Edit ') gv.font_name(self.file_type, 'AndroidClock') gv.font_size(15) gv.font_style(self.file_type, '倾斜') gv.font_color(self.file_type, 6, 29) gv.swipe_ele('//*[@text=" Font Color "]', '//*[@text=" Edit "]') gv.fold_expand() time.sleep(1) x, y = gv.find_pic_position('drag_all') gv.tap(x, y) # 进入 Edit gv.pop_menu_click('editText') for i in range(20): self.driver.press_keycode(random.randint(29, 54)) time.sleep(1) gv.group_button_click(' Edit ') gv.bullets_numbers('pg', 6, 10) gv.text_align(self.file_type, '分散对齐') gv.text_align(self.file_type, '右对齐') gv.text_line_space(self.file_type, 1.5) gv.text_line_space(self.file_type, 3) gv.text_indent(self.file_type, '右缩进') gv.text_indent(self.file_type, '右缩进') gv.text_indent(self.file_type, '左缩进') time.sleep(3)
def test_ppt_autoplay_to_last(self): logging.info('==========test_ppt_autoplay_to_last==========') cv = CreateView(self.driver) cv.create_file('pg') pg = PGView(self.driver) pg.add_new() pg.add_new() logging.info('==========autoplay to the last page==========') pg = PGView(self.driver) pg.group_button_click(' Play ') pg.play_mode('autoplay') logging.info('==========validate toast==========') try: WebDriverWait(self.driver, 120).until( ec.visibility_of_element_located( (By.XPATH, '//*[@text="It has been the last slide."]'))) except TimeoutException: self.assertTrue(False, '等待自动 Play 两分钟,未找到弹窗') else: toast = self.driver.find_element( By.XPATH, '//*[@text="It has been the last slide."]') self.assertEqual(toast.text, 'It has been the last slide.', '验证弹窗信息为已是简报尾页')
def test_read_mode(self, file_type): # 阅读模式 logging.info('==========test_read_mode==========') cv = CreateView(self.driver) cv.create_file(file_type) gv = GeneralView(self.driver) gv.switch_write_read() self.assertTrue(gv.check_write_read())
def test_search_replace(self, file_type): # 查找替换 logging.info('==========test_search_replace==========') cv = CreateView(self.driver) gv = GeneralView(self.driver) cv.create_file(file_type) if file_type == 'ss': self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_edit_container').click() elif file_type == 'pg': pg = PGView(self.driver) x, y = pg.get_size() pg.tap(x * 0.5, y * 0.4) pg.tap(x * 0.5, y * 0.4) elif file_type == 'wp': gv.tap(700, 700) self.driver.press_keycode(53) self.driver.press_keycode(43) self.driver.press_keycode(54) self.driver.press_keycode(43) if file_type in WS: if file_type == 'ss': self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click() gv.group_button_click(' View ') gv.search_content(file_type, 'yozo') gv.replace_content('YOZO') time.sleep(3) gv.replace_content('yozo', 'all')
def test_shape_text_attr_pg(self): # 自选图形文本属性,仅WP和PG logging.info('==========test_shape_text_attr_pg==========') type = 'pg' cv = CreateView(self.driver) cv.create_file(type) gv = GeneralView(self.driver) gv.group_button_click('插入') gv.insert_shape(type, 1) gv.group_button_click('编辑') gv.font_name(type, 'AndroidClock') gv.font_size(15) gv.font_style(type, '倾斜') gv.font_color(type, 6, 29) gv.swipe_ele('//*[@text="字体颜色"]', '//*[@text="编辑"]') time.sleep(1) gv.tap(550, 450) time.sleep(1) gv.tap(550, 450, 6) time.sleep(1) for i in range(20): self.driver.press_keycode(random.randint(29, 54)) time.sleep(1) gv.group_button_click('编辑') # gv.high_light_color(type,6,6) gv.bullets_numbers(type, 6, 10) gv.text_align(type, '分散对齐') gv.text_align(type, '右对齐') gv.text_line_space(type, 1.5) gv.text_line_space(type, 3) gv.text_indent(type, '右缩进') gv.text_indent(type, '右缩进') gv.text_indent(type, '左缩进') time.sleep(3)
def test_ppt_slide(self): # 幻灯片复制、剪切、粘贴 logging.info('==========test_ppt_slide==========') cv = CreateView(self.driver) cv.create_file(self.file_type) gv = GeneralView(self.driver) self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[1]').click() time.sleep(1) gv.pop_menu_click('copy') self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[1]').click() time.sleep(1) gv.pop_menu_click('paste') self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[2]').click() time.sleep(1) gv.pop_menu_click('cut') self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[1]').click() time.sleep(1) gv.pop_menu_click('paste') self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[2]').click() time.sleep(1) gv.pop_menu_click('create') self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[3]').click() time.sleep(1) gv.pop_menu_click('delete') self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[2]').click() time.sleep(1) x1, y1 = gv.find_pic_position('copy') x2, y2 = gv.find_pic_position('delete') gv.swipe(x2, y2, x1, y1) gv.pop_menu_click('hide') self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[2]').click() time.sleep(1) gv.pop_menu_click('hide_cancel') self.driver.find_element( By.XPATH, '//android.widget.HorizontalScrollView' '/android.widget.LinearLayout/android.view.View[2]').click() time.sleep(1) gv.pop_menu_click('comment') time.sleep(3)
def test_wp_save_as_existFile(self): # 已有文件另存为 logging.info('==========test_save_as_existFile==========') ov = OpenView(self.driver) cv = CreateView(self.driver) ov.open_file('欢迎使用永中Office.docx') file_name = 'save_as_existFile ' + time.strftime("%H%M%S") cv.save_file_option(file_name, 'local', 1, 'save_as') self.assertTrue(cv.check_save_file())
def insert_one_shape(self, type): # 将矩形 Insert wp中 cv = CreateView(self.driver) cv.create_file(type) wp = WPView(self.driver) wp.group_button_click(' Insert ') wp.get_element( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_%s_option_id_insert_shape"]' '/android.widget.FrameLayout[3]' % type).click()
def test_insert_shape(self): logging.info('==========test_insert_shape==========') cv = CreateView(self.driver) cv.create_file('ss', 0) gv = GeneralView(self.driver) ss = SSView(self.driver) ss.insert_chart() gv.insert_shape('ss')
def test_ppt_format(self): logging.info('==========test_ppt_format==========') cv = CreateView(self.driver) cv.create_file('pg') pg = PGView(self.driver) pg.group_button_click(' Edit ') for i in FORMAT: pg.edit_format(i) time.sleep(3)
def test_ppt_template(self): logging.info('==========test_ppt_template==========') cv = CreateView(self.driver) cv.create_file('pg') pg = PGView(self.driver) pg.group_button_click('编辑') for i in range(11): pg.edit_template(i) time.sleep(3)
def test_shape_attr1(self, file_type): # 文本框字符属性 logging.info('==========test_shape_attr1==========') cv = CreateView(self.driver) cv.create_file(file_type) gv = GeneralView(self.driver) x1, y1 = 0, 0 if file_type == 'ss': ss = SSView(self.driver) x1, y1, w, h = ss.cell_location() self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click() gv.group_button_click(' Insert ') gv.insert_shape(file_type) time.sleep(1) x, y = gv.find_pic_position('drag_all') gv.tap(x, y) # 进入编辑 gv.pop_menu_click('editText') if file_type == 'ss': gv.fold_expand() gv.fold_expand() x, y = gv.find_pic_position('drag_all') gv.tap(x, y) # 进入编辑 gv.pop_menu_click('editText') for i in range(50): self.driver.press_keycode(random.randint(7, 16)) if file_type == 'pg': gv.tap(250, 250) gv.tap(550, 850) elif file_type == 'ss': gv.tap(x1, y1) gv.tap(x, y) else: gv.tap(250, 450) time.sleep(1) gv.fold_expand() gv.tap(x, y) time.sleep(1) gv.fold_expand() gv.shape_option(file_type, 5, width=5, height=5) gv.shape_option(file_type, 6, top=0.5, bottom=0.5, left=0.5, right=0.5) ele1 = '//*[@text=" Shape "]' ele2 = '//*[@text=" Outline "]' ele3 = '//*[@text=" Effect "]' if file_type == 'pg': ele0 = '//*[@text=" Insert "]' gv.swipe_ele(ele0, ele1) gv.swipe_ele(ele2, ele1) gv.swipe_ele(ele3, ele1) gv.shape_content_align(file_type, '右对齐', '下对齐') gv.shape_content_align(file_type) gv.shape_content_align(file_type, '水平居中', '垂直居中') time.sleep(3)
def test_save_existFile(self): # 已有文件改动保存 logging.info('==========test_save_existFile==========') ov = OpenView(self.driver) cv = CreateView(self.driver) gv = GeneralView(self.driver) ov.open_file('save1.doc') gv.switch_write_read() self.driver.press_keycode(48) cv.save_file_icon() self.assertTrue(cv.check_save_file())
def test_create(self): logging.info('==========test_create==========') cv = CreateView(self.driver) types = ['wp', 'ss', 'pg'] for i in types: for ii in range(6): rm_file(i + str(ii)) cv.create_file(i + str(ii), i, ii) self.assertTrue(cv.check_create_file())
def test_cell_border(self): # 遍历边框所有功能 logging.info('==========test_cell_border==========') cv = CreateView(self.driver) cv.create_file('ss') ss = SSView(self.driver) ss.group_button_click('编辑') time.sleep(1) self.driver.swipe(200, 1856, 200, 1150, 2000) ss.cell_border()
def test_formula1(self): # 其他类型公式 logging.info('==========test_formula1==========') cv = CreateView(self.driver) ss = SSView(self.driver) cv.create_file('ss') time.sleep(1) x, y, width, height = ss.cell_location() # cell B8 for i in range(6): ss.tap(x + width * 1.5, y + height * (1.5 + i)) ss.tap(x + width * 0.5, y + height * (1.5 + i)) ss.cell_edit() self.driver.press_keycode(random.randint(7, 16)) formula_dic = { ' Recently Used ': 'MAX', ' Math and Trig ': 'GCD', ' Financial ': 'DOLLARDE', ' Logical ': 'AND', ' Text ': 'CONCATENATE', ' Date and Time ': 'DATE', ' Lookup and Reference ': 'CHOOSE', ' Statistical ': 'AVERAGE', ' Engineering ': 'IMPRODUCT', ' Database ': 'GETPIVOTDATA', ' Information ': 'ISBLANK', ' ALL ': 'MAX' } keys_list = [ ' Recently Used ', ' Math and Trig ', ' Financial ', ' Logical ', ' Text ', ' Date and Time ', ' Lookup and Reference ', ' Statistical ', ' Engineering ', ' Database ', ' Information ', ' All ' ] for i in keys_list: if keys_list.index(i) > 5: ss.tap(x + width * 2.5, y + height * (1.5 + keys_list.index(i) - 5)) else: ss.tap(x + width * 1.5, y + height * (1.5 + keys_list.index(i))) ss.formula_all(i, formula_dic.get(i)) print(i, formula_dic.get(i)) # cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) if i == ' Database ' or i == ' Date and Time ': m = 3 elif i == ' Information ': m = 1 else: m = 6 for n in range(m): ss.tap(x + width * 0.5, y + height * (1.5 + n)) self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click()
def test_sheet_operation1(self): # sheet相关功能 logging.info('==========test_sheet_operation1==========') cv = CreateView(self.driver) cv.create_file('ss') ss = SSView(self.driver) ss.show_sheet() ss.operate_sheet(0, 'insert') ss.operate_sheet(0, 'copy') ss.operate_sheet(0, 'remove') ss.operate_sheet(0, 'hide') ss.unhide_sheet(0, 0)
def test_sheet_operation(self): # sheet相关功能 logging.info('==========test_sheet_operation==========') cv = CreateView(self.driver) cv.create_file('ss') ss = SSView(self.driver) ss.show_sheet() ss.hide_sheet() ss.show_sheet() ss.add_sheet() ss.rename_sheet(0, 'test') self.assertTrue(ss.check_rename_sheet(0, 'test'))
def test_wp_insert_watermark(self): logging.info('==========test_wp_insert_watermark==========') cv = CreateView(self.driver) cv.create_file('wp') wp = WPView(self.driver) wp.group_button_click(' Insert ') wp.insert_watermark('YOZO') time.sleep(1) wp.group_button_click(' Insert ') wp.insert_watermark('yozo', delete='delete') time.sleep(3)