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_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 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_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_insert_pic(self, file_type='ss'): logging.info('==========test_insert_pic==========') cv = CreateView(self.driver) gv = GeneralView(self.driver) cv.create_file(file_type) cv.group_button_click(' Insert ') gv.insert_pic() gv.pic_option(file_type, 5, 4, 4) gv.pic_option(file_type, 1) ele1 = '//*[@text=" Picture "]' ele2 = '//*[@text=" Outline "]' # ele3 = '//*[@text="文字环绕"]' # ele4 = '//*[@text="叠放次序"]' gv.swipe_ele(ele2, ele1) if file_type == 'wp': gv.text_wrap() x, y = gv.find_pic_position('rotate_free') gv.swipe(x, y, x + 100, y + 100) x, y = gv.find_pic_position('drag_all') gv.tap(x, y) gv.pop_menu_click('copy') gv.tap(x, y) gv.pop_menu_click('paste') gv.tap(x, y) gv.pop_menu_click('paste') gv.shape_layer(' Send Backward ') gv.shape_layer(' Send to Back ') gv.shape_layer(' Bring Forward ') gv.shape_layer(' Bring to Front ')
def test_pop_menu_cell_text(self): logging.info('==========test_pop_menu_cell_text==========') cv = CreateView(self.driver) cv.create_file(self.file_type) gv = GeneralView(self.driver) ss = SSView(self.driver) time.sleep(1) x, y, width, height = ss.cell_location() # 新建默认B8 cv.tap(x + width * 0.5, y - height * 5.5) # 点击B2 ss.cell_edit() # 进入 Edit for i in range(15): self.driver.press_keycode(random.randint(29, 54)) # time.sleep(1) gv.drag_coordinate(x + 200, y - height * 5.5, x + 50, y - height * 5.5) gv.pop_menu_click('copy') gv.tap(x + width * 0.5, y - height * 5.5) gv.pop_menu_click('paste') gv.drag_coordinate(x + 200, y - height * 5.5, x + 50, y - height * 5.5) gv.pop_menu_click('cut') gv.tap(x + width * 0.5, y - height * 5.5) gv.pop_menu_click('paste') gv.tap(x + width * 0.5, y - height * 5.5) gv.pop_menu_click('newline') self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click() gv.tap(x + width * 0.5, y - height * 5.5) gv.pop_menu_click('fill_data') x1, y1 = gv.find_pic_position('fill_down') gv.drag_coordinate(x1, y1, x1, y1 + height * 2) gv.tap(x + width * 0.5, y - height * 5.5) time.sleep(1) x2, y2 = gv.find_pic_position('fill_data') gv.swipe(x2, y2, x2 - width * 2, y2) gv.pop_menu_click('clear_content')
def test_insert_pic1(self, file_type='ss'): logging.info('==========test_insert_pic==========') suffix = SEARCH_DICT[file_type] ov = OpenView(self.driver) ov.open_random_file(suffix) gv = GeneralView(self.driver) gv.switch_write_read() gv.group_button_click(' Insert ') gv.insert_pic() gv.pic_option(file_type, 5, 4, 4) ele1 = '//*[@text=" Picture "]' ele2 = '//*[@text=" Outline "]' # ele3 = '//*[@text="文字环绕"]' # ele4 = '//*[@text="叠放次序"]' gv.swipe_ele(ele2, ele1) if file_type == 'wp': gv.text_wrap(' Square ') gv.text_wrap(' In Line with Text ') gv.text_wrap(' Tight ') gv.text_wrap(' Behind Text ') gv.text_wrap(' In Front of Text ') x, y = gv.find_pic_position('drag_pic') gv.tap(x, y) gv.pop_menu_click('cut') if file_type == 'wp': gv.long_press(x, y) else: gv.tap(x + 100, y) gv.tap(x + 100, y) gv.pop_menu_click('paste') x, y = gv.find_pic_position('drag_pic') gv.tap(x, y) x, y = gv.find_pic_position('rotate_90') gv.swipe(x, y, x - 50, y) gv.pop_menu_click('save_to_album') gv.pop_menu_click('delete')
def test_wp_pop_menu_text(self): logging.info('==========test_wp_pop_menu_text==========') cv = CreateView(self.driver) cv.create_file(self.file_type) gv = GeneralView(self.driver) time.sleep(1) gv.tap(700, 700) for i in range(100): self.driver.press_keycode(random.randint(29, 54)) gv.drag_coordinate(300, 540, 300, 200) gv.pop_menu_click('copy') gv.tap(700, 700) time.sleep(1) gv.long_press(700, 700) gv.pop_menu_click('paste') gv.drag_coordinate(300, 540, 300, 200) gv.pop_menu_click('cut') gv.tap(700, 700) time.sleep(1) gv.long_press(700, 700) gv.pop_menu_click('paste')
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_pop_menu_shape(self, file_type='wp'): logging.info('==========test_pop_menu_shape==========') cv = CreateView(self.driver) cv.create_file(file_type) gv = GeneralView(self.driver) gv.group_button_click(' Insert ') gv.insert_shape(file_type) time.sleep(1) if file_type == 'pg': gv.tap(550, 450) gv.pop_menu_click('editText') else: gv.tap(700, 700, 2) gv.tap(700, 700, 3) for i in range(50): self.driver.press_keycode(random.randint(29, 54)) if file_type == 'pg': gv.drag_coordinate(550, 830, 500, 800) gv.pop_menu_click('copy') gv.tap(550, 830) time.sleep(1) gv.long_press(550, 830) gv.pop_menu_click('paste') gv.drag_coordinate(550, 830, 500, 800) gv.pop_menu_click('cut') gv.tap(550, 830) time.sleep(1) gv.long_press(550, 830) gv.pop_menu_click('paste') gv.drag_coordinate(550, 830, 500, 800) gv.pop_menu_click('delete') else: gv.drag_coordinate(700, 700, 550, 550) gv.pop_menu_click('copy') gv.tap(700, 700) time.sleep(1) gv.long_press(700, 700) gv.pop_menu_click('paste') gv.drag_coordinate(700, 700, 550, 550) gv.pop_menu_click('cut') gv.tap(700, 700) time.sleep(1) gv.long_press(700, 700) gv.pop_menu_click('paste') gv.drag_coordinate(700, 700, 550, 550) gv.pop_menu_click('delete')