def test_wp_pic_outline_color(self, type1='wp'): self.insert_one_pic(type1) wp = WPView(self.driver) cc = "com.yozo.office.en:id/yozo_ui_%s_option_id_picture_edit" % type1 wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[5]' % cc).click() # 属性调整大小 wp.shape_option_5() if not wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ): wp.fold_expand() cc = "com.yozo.office.en:id/yozo_ui_wp_option_id_picture_broad" s = wp.swipe_option('up') while not wp.exist('//*[@resource-id="%s"]' % cc): wp.swipe(s[0], s[1], s[2], s[3]) for i in range(1, 7): wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[%s]' % (cc, i)).click() cc = 'com.yozo.office.en:id/yozo_ui_option_id_color_all' list( map( lambda i: wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[%s]' % (cc, i)).click(), range(1, 43)))
def test_wp_shape_fixed_rotate(self, type1='wp'): # 形状四种固定旋转角度 self.insert_one_shape(type1) wp = WPView(self.driver) for i in range(1, 5): wp.get_element( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_%s_option_id_shape_quick_function"]' '/android.widget.FrameLayout[%s]' % (type1, i)).click()
def test_wp_pic_shadow(self, type1='wp'): # type1 = 'wp' self.insert_one_pic(type1) wp = WPView(self.driver) cc = "com.yozo.office.en:id/yozo_ui_%s_option_id_picture_edit" % type1 wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[5]' % cc).click() # 属性调整大小 wp.shape_option_5() if not wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ): wp.fold_expand() cc = "com.yozo.office.en:id/yozo_ui_%s_option_id_picture_effect" % type1 for i in range(1, 7): wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[%s]' % (cc, i)).click() cc = 'com.yozo.office.en:id/yozo_ui_option_id_object_effect_shadow' for i in range(1, 6): wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[%s]' % (cc, i)).click()
def test_wp_table_pop_menu(self): self.wp_insert_one_table() wp = WPView(self.driver) touch(wp.template_object('table_select.png')) touch(wp.template_object('copy.png')) touch(wp.template_object('table_select.png')) touch(wp.template_object('delete_table.png')) time.sleep(2) if wp.exist('//*[@text=" Font Color "]'): wp.fold_expand() text("YOZOYOZOYOZO") text("YOZOYOZOYOZO") if not exists(wp.template_object('point.png')): wp.get_element( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_app_frame_office_view_container"]' ).click() touch(wp.template_object('point.png')) touch(wp.template_object('selectAll.png')) touch(wp.template_object('cut.png')) wp.group_button_click(' Insert ') wp.insert_example_table() touch(wp.template_object('table_select.png')) touch(wp.template_object('paste.png')) touch(wp.template_object('table_select.png')) touch(wp.template_object('clear.png')) touch(wp.template_object('table_select.png')) touch(wp.template_object('cut.png'))
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_wp_pic_outline_border_px(self, type1='wp'): # type1 = 'wp' self.insert_one_pic(type1) wp = WPView(self.driver) cc = "com.yozo.office.en:id/yozo_ui_%s_option_id_picture_edit" % type1 wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[5]' % cc).click() # 属性调整大小 wp.shape_option_5() if not wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ): wp.fold_expand() # if type1 == 'pg': # cc = "com.yozo.office.en:id/yozo_ui_pg_option_id_picture_border_width" # elif type1 == 'wp': cc = "com.yozo.office.en:id/yozo_ui_wp_option_id_picture_border_width" # elif type1 == 'ss': # cc = "com.yozo.office.en:id/yozo_ui_ss_option_id_picture_border_width" s = wp.swipe_option('up') while not wp.exist('//*[@resource-id="%s"]' % cc): wp.swipe(s[0], s[1], s[2], s[3]) for i in range(1, 7): wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[%s]' % (cc, i)).click() # cc = 'com.yozo.office.en:id/yozo_ui_option_id_objec_border_width_select' for i in range(30): wp.get_element( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_number_picker_arrow_right"]' ).click()
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_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_wp_pic_pop_menu_all(self, type1='wp'): self.insert_one_pic(type1) wp = WPView(self.driver) s = wp.swipe_option('up') while not wp.exist('//*[@text=" Text Wrapping "]'): wp.swipe(s[0], s[1], s[2], s[3]) wp.text_wrap(' Square ') # 属性调整大小 cc = "com.yozo.office.en:id/yozo_ui_%s_option_id_picture_edit" % type1 while not wp.exist('//*[@resource-id="%s"]' % cc): wp.swipe(s[2], s[3], s[0], s[1]) wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[5]' % cc).click() wp.shape_option_5() if wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ): wp.fold_expand() touch(wp.template_object('chart_all1.png')) touch(wp.template_object('copy.png')) # 复制 touch(wp.template_object('chart_all1.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('save_to_album.png')) # 存至相册 touch(wp.template_object('rotate_free.png')) touch(wp.template_object('edit_pic.png')) # 裁剪 touch(wp.template_object('delete.png')) # 删除
def test_wp_jump(self): # 跳转页 logging.info('==========test_wp_bookmark==========') ov = OpenView(self.driver) ov.open_file('欢迎使用永中Office.docx') wp = WPView(self.driver) wp.group_button_click('查看') wp.page_jump(7) time.sleep(2)
def test_wp_pic_fixed_rotate(self, type1='wp'): # 图片四种固定旋转角度 self.insert_one_pic(type1) wp = WPView(self.driver) cc = "com.yozo.office.en:id/yozo_ui_%s_option_id_picture_edit" % type1 for i in range(1, 5): wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[%s]' % (cc, i)).click()
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_wp_read_self_adaption(self): # wp阅读自适应 logging.info('==========test_wp_read_self_adaption==========') ov = OpenView(self.driver) ov.open_file('欢迎使用永中Office.docx') wp = WPView(self.driver) wp.read_self_adaption() time.sleep(1) self.assertFalse(wp.get_element_result('//*[@resource-id="com.yozo.office:id/yozo_ui_toolbar_button_close"]'), 'read self adaption set fail!')
def test_wp_text_select(self): # 文本选取 logging.info('==========test_wp_text_select==========') ov = OpenView(self.driver) ov.open_file('欢迎使用永中Office.docx') wp = WPView(self.driver) wp.switch_write_read() x, y = wp.get_size() wp.drag_coordinate(x * 0.5, y * 0.4, x * 0.6, y * 0.5) time.sleep(3)
def test_wp_table_left_rows(self): self.wp_insert_one_table() wp = WPView(self.driver) ele = '//*[@resource-id="com.yozo.office.en:id/yozo_ui_app_frame_office_view_container"]' e7 = wp.get_element_xy(ele, x_y=7) e9 = wp.get_element_xy(ele, x_y=9) # Insert 行 while not exists(wp.template_object('table_select.png')): wp.swipe(e7[0], e7[1], e9[0], e9[1]) touch(wp.template_object('table_cols_rows.png'))
def test_wp_table_merge_split(self): logging.info('==========%s==========' % self.__str__().split(' ')[0]) self.wp_insert_one_table() wp = WPView(self.driver) touch(wp.template_object('table_select.png')) if not wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ): wp.fold_expand() wp.table_merge_split() time.sleep(10)
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)
def test_wp_table_attr_5_delete_table(self): self.wp_insert_one_table() wp = WPView(self.driver) s = wp.swipe_option('up') while not wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_wp_table_option_id_delete_table"]' ): wp.swipe(s[0], s[1], s[2], s[3]) wp.table_delete_row_col_all(del0='row') wp.table_delete_row_col_all(del0='col') wp.table_delete_row_col_all(del0='all')
def test_wp_print_long_pic(self): ov = OpenView(self.driver) ov.open_random_file('docx') wp = WPView(self.driver) wp.wait_loading() # time.sleep(2) ov.group_button_click(' File ') wp.print_long_pic() self.assertTrue(wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_export_longpic_share_buttons"]' ), msg='未弹出分享栏')
def test_wp_pic_text_round(self): # 仅wp存在文字环绕功能 self.insert_one_pic('wp') wp = WPView(self.driver) s = wp.swipe_option('up') while not wp.exist('//*[@text=" Text Wrapping "]'): wp.swipe(s[0], s[1], s[2], s[3]) wp.text_wrap(' Square ') wp.text_wrap(' In Line with Text ') wp.text_wrap(' Tight ') wp.text_wrap(' Behind Text ') wp.text_wrap()
def test_wp_table_size(self): self.wp_insert_one_table() wp = WPView(self.driver) ele = '//*[@resource-id="com.yozo.office.en:id/yozo_ui_app_frame_office_view_container"]' e7 = wp.get_element_xy(ele, x_y=7) e9 = wp.get_element_xy(ele, x_y=9) # 改变表格大小 while not exists(wp.template_object('table_size.png')): wp.swipe(e9[0], e9[1], e7[0], e7[1]) swipe(wp.template_object('table_size.png'), wp.get_element_xy(ele, x_y=4)) time.sleep(5)
def test_wp_table_attr_4_insert_row_col(self): self.wp_insert_one_table() wp = WPView(self.driver) s = wp.swipe_option('up') while not wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_wp_table_option_id_insert_table"]' ): wp.swipe(s[0], s[1], s[2], s[3]) wp.table_insert_row_col(direction='up') wp.table_insert_row_col(direction='down') wp.table_insert_row_col(direction='left') wp.table_insert_row_col(direction='light')
def test_wp_bookmark(self): logging.info('==========test_wp_bookmark==========') ov = OpenView(self.driver) ov.open_file('欢迎使用永中Office.docx') wp = WPView(self.driver) wp.group_button_click('查看') wp.add_bookmark('test') self.assertTrue(wp.check_add_bookmark(), '书签插入失败!') wp.swipeUp() wp.swipeUp() wp.group_button_click('查看') wp.list_bookmark('test')
def test_wp_shape_text_round(self): # 仅wp存在文字环绕功能 self.insert_one_shape('wp') wp = WPView(self.driver) s = wp.swipe_option('up') while not wp.exist('//*[@text=" Text Wrapping "]'): wp.swipe(s[0], s[1], s[2], s[3]) list_wrap = [ ' Square ', ' In Line with Text ', ' Tight ', ' Behind Text ', ' In Front of Text ' ] for i in list_wrap: wp.text_wrap(i)
def test_wp_insert_chart_list(self, chart_type): cv = CreateView(self.driver) cv.create_file('wp') wp = WPView(self.driver) wp.group_button_click(' Insert ') s = wp.swipe_option('up') while not wp.exist('//*[@text=" Chart "]'): wp.swipe(s[0], s[1], s[2], s[3]) wp.get_element('//*[@text=" Chart "]').click() while not wp.exist('//*[@text="%s"]' % chart_type): wp.swipe(s[0], s[1], s[2], s[3]) wp.get_element('//*[@text="%s"]' % chart_type).click() wp.chart_insert_list('%s' % chart_type)
def test_wp_text_select(self): # 文本选取 logging.info('==========test_wp_text_select==========') gv = GeneralView(self.driver) gv.jump_to_index('alldoc') gv.select_file_type('wp') gv.sort_files('size', 'down') eles = self.driver.find_elements(By.ID, 'com.yozo.office.en:id/file_item') eles[0].click() wp = WPView(self.driver) wp.switch_write_read() x, y = wp.get_size() wp.drag_coordinate(x * 0.5, y * 0.4, x * 0.6, y * 0.5) time.sleep(3)
def test_wp_pic_width_to_height(self, type1='wp'): self.insert_one_pic(type1) wp = WPView(self.driver) if type1 == 'wp': s = wp.swipe_option('up') while not wp.exist('//*[@text=" Text Wrapping "]'): wp.swipe(s[0], s[1], s[2], s[3]) wp.text_wrap(' Square ') ele1 = '//*[@resource-id="com.yozo.office.en:id/yozo_ui_wp_option_id_picture_broad"]' ele2 = '//*[@text=" Text Wrapping "]' wp.swipe_ele(ele1, ele2) cc = "com.yozo.office.en:id/yozo_ui_%s_option_id_picture_edit" % type1 wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[5]' % cc).click() # 属性调整大小 wp.shape_option_5()
def test_wp_jump(self): # 跳转页 logging.info('==========test_wp_bookmark==========') gv = GeneralView(self.driver) gv.jump_to_index('alldoc') gv.select_file_type('wp') gv.sort_files('size', 'down') eles = self.driver.find_elements(By.ID, 'com.yozo.office.en:id/file_item') eles[0].click() wp = WPView(self.driver) wp.group_button_click(' File ') total_pages = self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_id_print_wp_page_count').text str_list = total_pages.split(' ') total_pages = int(str_list[1]) wp.group_button_click(' View ') wp.page_jump(total_pages) time.sleep(2)
def test_wp_pic_free_rotate(self, type1='wp'): self.insert_one_pic(type1) wp = WPView(self.driver) s = wp.swipe_option('up') while not wp.exist('//*[@text=" Text Wrapping "]'): wp.swipe(s[0], s[1], s[2], s[3]) wp.text_wrap(' Square ') # 属性调整大小 cc = "com.yozo.office.en:id/yozo_ui_%s_option_id_picture_edit" % type1 while not wp.exist('//*[@resource-id="%s"]' % cc): wp.swipe(s[2], s[3], s[0], s[1]) wp.get_element('//*[@resource-id="%s"]' '/android.widget.FrameLayout[5]' % cc).click() wp.shape_option_5() if wp.exist( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ): wp.fold_expand() ele5 = wp.get_element_xy( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_app_frame_office_view_container"]' ) ele9 = wp.get_element_xy( '//*[@resource-id="com.yozo.office.en:id/yozo_ui_app_frame_office_view_container"]', x_y=9) while not exists(wp.template_object('rotate_free.png')): wp.swipe(ele5[0], ele5[1], ele9[0], ele9[1]) # 向右移动图片 rotate_free = loop_find(wp.template_object('rotate_free.png')) wp.swipe(rotate_free[0], rotate_free[1] + 200, rotate_free[0] + 200, rotate_free[1] + 200) # 取消选中图片 wp.tap(ele9[0], ele9[1]) time.sleep(1) self.assertTrue(wp.exist('//*[@text="编辑"]'), msg='取消选中图片异常') # 选中图片 wp.tap(rotate_free[0] + 200, rotate_free[1] + 200) time.sleep(1) self.assertTrue(wp.exist('//*[@text="图片"]'), msg='选中图片异常') # 自由旋转 rotate_free = loop_find(wp.template_object('rotate_free.png')) wp.swipe(rotate_free[0], rotate_free[1], ele9[0], ele9[1]) rotate_free2 = loop_find(wp.template_object('rotate_free.png')) self.assertEqual(rotate_free, rotate_free2, msg='图片自由旋转失败')
def test_wp_bookmark(self): logging.info('==========test_wp_bookmark==========') ov = OpenView(self.driver) ov.open_random_file('doc') wp = WPView(self.driver) wp.group_button_click(' View ') wp.add_bookmark('test') self.assertTrue(wp.check_add_bookmark(), '书签 Insert 失败!') # 收起键盘 self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_option_expand_button').click() self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_option_expand_button').click() wp.swipeUp() wp.swipeUp() wp.group_button_click(' View ') wp.list_bookmark('test')