def test_merge_wrap(self): logging.info('==========test_merge_wrap==========') cv = CreateView(self.driver) cv.create_file('ss') time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) # 双击进入编辑 cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) for i in range(20): self.driver.press_keycode(45) self.driver.find_element(By.ID, 'com.yozo.office:id/formulabar_ok').click() cv.drag_coordinate(110 + 263 * 2, 295 + 55 * 2, 110 + 263 * 3, 295 + 55 * 2) ss = SSView(self.driver) ss.group_button_click('编辑') ele1 = '//*[@text="编辑"]' ele2 = '//*[@text="字体颜色"]' ele3 = '//*[@text="单元格填充"]' ele4 = '//*[@text="数字格式"]' ss.swipe_ele(ele2, ele1) ss.swipe_ele(ele3, ele1) ss.swipe_ele(ele4, ele1) ss.cell_merge_split() ss.cell_merge_split() ss.cell_auto_wrap() ss.cell_auto_wrap() time.sleep(3)
def test_ss_merge_wrap(self): logging.info('==========test_ss_merge_wrap==========') gv = GeneralView(self.driver) cv = CreateView(self.driver) cv.create_file('ss') ss = SSView(self.driver) ss.cell_edit() x, y, width, height = ss.cell_location() for i in range(20): self.driver.press_keycode(45) self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click() ss.tap(x + width * 1.5, y + height * 2.5) x1, y1 = gv.find_pic_position("drag_point1") cv.drag_coordinate(x1, y1, x, y) ss.group_button_click(' Edit ') ele = '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ss.swipe_options(ele, 'up') ss.swipe_options(ele, 'up') ss.swipe_options(ele, 'up') ss.cell_merge_split() ss.cell_merge_split() ss.cell_auto_wrap() ss.cell_auto_wrap() time.sleep(1)
def test_ss_filter_by_num_shortcut(self): logging.info('==========test_ss_filter_by_num_shortcut==========') ss = SSView(self.driver) ov = OpenView(self.driver) ov.open_file('screen.xls') ss.switch_write_read() ss.cell_edit() x, y, width, height = ss.cell_location() ss.tap(x + width / 2, y - height / 2) ss.group_button_click(' View ') self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_filter').click() x1 = x - 18 y1 = y - height * 3 - 27 ss.tap(x1, y1) self.driver.find_element(By.XPATH, '//*[@text="自定义"]').click() self.driver.find_element(By.XPATH, '//*[@text="前十项"]').click() self.driver.find_element(By.ID, 'com.yozo.office.en:id/tv_ok').click() ss.tap(x1, y1, 2) # 非初次需要点两次 self.driver.find_element(By.XPATH, '//*[@text="自定义"]').click() self.driver.find_element(By.XPATH, '//*[@text="高于平均值"]').click() ss.tap(x1, y1, 2) self.driver.find_element(By.XPATH, '//*[@text="自定义"]').click() self.driver.find_element(By.XPATH, '//*[@text="低于平均值"]').click()
def test_ss_filter_cd1_none(self): logging.info('==========test_ss_filter_cd1_none==========') ss = SSView(self.driver) ov = OpenView(self.driver) ov.open_file('screen.xls') ss.switch_write_read() ss.cell_edit() x, y, width, height = ss.cell_location() ss.tap(x + width / 2, y - height / 2) ss.group_button_click(' View ') self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_filter').click() for i in range(3): x1 = x - width * (1 - i) - 18 y1 = y - height * 3 - 27 ss.tap(x1, y1) self.driver.find_element(By.XPATH, '//*[@text="自定义"]').click() self.driver.find_element( By.ID, 'com.yozo.office.en:id/tv_filter_condition1').click() self.driver.find_element( By.XPATH, '//android.widget.ListView/android.widget.LinearLayout[1]' ).click() self.driver.find_element( By.ID, 'com.yozo.office.en:id/tv_ss_filter_ok').click() self.assertTrue(ss.get_toast_message('第一个条件不能为空')) self.driver.find_element( By.ID, 'com.yozo.office.en:id/iv_ss_customize_back').click()
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_ss_cell_border(self): # 遍历边框所有功能 logging.info('==========test_ss_cell_border==========') cv = CreateView(self.driver) cv.create_file('ss') ss = SSView(self.driver) ss.group_button_click(' Edit ') ele = '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ss.swipe_options(ele, 'up') ss.swipe_options(ele, 'up') ss.cell_border()
def test_ss_cell_options(self): # 插入删除行宽列高清除 logging.info('==========test_ss_cell_options==========') cv = CreateView(self.driver) cv.create_file('ss') ss = SSView(self.driver) ss.cell_edit() # x, y, width, height = ss.cell_location() # ss.tap(x - width * 2, y - height * 4) # ss.cell_edit() for i in range(20): self.driver.press_keycode(45) self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click() ss.group_button_click(' Edit ') gv = GeneralView(self.driver) gv.font_style(self.file_type, '删除线') ele = '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ss.swipe_options(ele, 'up') ss.swipe_options(ele, 'up') ss.swipe_options(ele, 'up') ss.swipe_options(ele, 'up') ss.cell_insert('右移') ss.cell_insert('下移') ss.cell_insert('插入整行') ss.cell_insert('插入整列') ss.cell_delete('删除整列') ss.cell_delete('删除整行') ss.cell_delete('上移') ss.cell_delete('左移') ss.cell_clear('清除格式') gv.undo_option() ss.cell_clear('清除内容') gv.undo_option() ss.cell_clear('清除所有') gv.undo_option() ss.swipe_options(ele, 'up') ss.cell_set_size(5, 5) ss.group_button_click(' Edit ') ss.swipe_options(ele, 'down') ss.cell_fit_height() ss.cell_fit_width() time.sleep(1)
def test_cell_insert_delete_fit(self): # 插入删除行宽列高清除 logging.info('==========test_cell_inser_delete_fit==========') cv = CreateView(self.driver) type = 'ss' cv.create_file('ss') time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) # 双击进入编辑 cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) for i in range(20): self.driver.press_keycode(45) self.driver.find_element(By.ID, 'com.yozo.office:id/formulabar_ok').click() ss = SSView(self.driver) ss.group_button_click('编辑') gv = GeneralView(self.driver) gv.font_style(type, '删除线') ele1 = '//*[@text="编辑"]' ele2 = '//*[@text="字体颜色"]' ele3 = '//*[@text="单元格填充"]' ele4 = '//*[@text="数字格式"]' ele5 = '//*[@text="插入单元格"]' ele6 = '//*[@text="删除单元格"]' ele7 = '//*[@text="设置行高列宽"]' ss.swipe_ele(ele2, ele1) ss.swipe_ele(ele3, ele1) ss.swipe_ele(ele4, ele1) ss.cell_insert('右移') ss.cell_insert('下移') ss.cell_insert('插入整行') ss.cell_insert('插入整列') ss.cell_delete('删除整列') ss.cell_delete('删除整行') ss.cell_delete('上移') ss.cell_delete('左移') ss.swipe_ele(ele5, ele1) ss.cell_set_size(5, 5) ss.group_button_click('编辑') ss.cell_clear('清除格式') gv.undo_option() ss.cell_clear('清除内容') gv.undo_option() ss.cell_clear('清除所有') gv.undo_option() ss.swipe_ele(ele6, ele7) ss.cell_fit_height() ss.cell_fit_width() time.sleep(3)
def test_ss_filter_by_text(self): logging.info('==========test_ss_filter_by_text==========') ss = SSView(self.driver) ov = OpenView(self.driver) ov.open_file('screen.xls') ss.switch_write_read() ss.cell_edit() x, y, width, height = ss.cell_location() ss.tap(x + width / 2, y - height / 2) ss.group_button_click(' View ') self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_filter').click() x1 = x + width - 18 y1 = y - height * 3 - 27 ss.filter_data(x1, y1, '自定义', TEXT_FILTER[random.randint(1, 12)], TEXT_FILTER[random.randint(1, 12)])
def test_ss_chart_pop(self): # 图表相关操作 logging.info('==========test_ss_chart_pop==========') cv = CreateView(self.driver) cv.create_file(self.file_type) ss = SSView(self.driver) gv = GeneralView(self.driver) time.sleep(2) x, y, width, height = ss.object_position('drag_point1', 'drag_point2') ss.tap(x, y) time.sleep(2) ss.pop_menu_click('edit') self.driver.press_keycode(12) ss.tap(x, y + height) time.sleep(1) ss.tap(x, y + height) time.sleep(2) ss.pop_menu_click('edit') self.driver.press_keycode(15) self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click() # ss.tap(x, y) x, y = ss.find_pic_position('drag_point1') ss.swipe(x, y, x, y - height) time.sleep(1) ss.group_button_click(' Insert ') gv.insert_chart_insert(' Column Chart ', 2) x, y, width, height = ss.object_position('chart_all1', 'chart_all4') ss.tap(x, y) time.sleep(2) ss.pop_menu_click('cut') ss.tap(x, y) time.sleep(2) ss.tap(x, y) ss.pop_menu_click('paste') ss.tap(x, y) time.sleep(2) ss.pop_menu_click('copy') ss.tap(x, y) time.sleep(2) ss.pop_menu_click('paste') ss.swipe(x, y, x - 100, y + 100) x, y = ss.find_pic_position('chart_all1') ss.swipe(x, y, x - 100, y - 100)
def test_ss_num_format(self): logging.info('==========test_num_style==========') cv = CreateView(self.driver) cv.create_file('ss') ss = SSView(self.driver) ss.cell_edit() self.driver.press_keycode(15) self.driver.press_keycode(7) self.driver.press_keycode(7) self.driver.press_keycode(7) self.driver.find_element( By.ID, 'com.yozo.office.en:id/formulabar_ok').click() ss.group_button_click(' Edit ') ele = '//*[@resource-id="com.yozo.office.en:id/yozo_ui_option_content_container"]' ss.swipe_options(ele, 'up') ss.swipe_options(ele, 'up') ss.cell_num_format()
def test_cell_attr(self): logging.info('==========test_cell_attr==========') cv = CreateView(self.driver) cv.create_file('ss') time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) # 双击进入编辑 cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) 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:id/formulabar_ok').click() ss = SSView(self.driver) ss.group_button_click('编辑') time.sleep(1) self.driver.swipe(200, 1856, 200, 1150, 2000) ss.cell_align('水平居中', '下对齐')
def test_table_style(self): # 表格样式 logging.info('==========test_table_style==========') cv = CreateView(self.driver) cv.create_file('ss') time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) cv.drag_coordinate(110 + 263 * 2, 295 + 55 * 2, 110 + 263 * 3, 295 + 55 * 4) ss = SSView(self.driver) ss.group_button_click('编辑') ele1 = '//*[@text="编辑"]' ele2 = '//*[@text="字体颜色"]' ele3 = '//*[@text="单元格填充"]' ele4 = '//*[@text="数字格式"]' ele5 = '//*[@text="插入单元格"]' ss.swipe_ele(ele2, ele1) ss.swipe_ele(ele3, ele1) ss.swipe_ele(ele4, ele1) ss.swipe_ele(ele5, ele1) ss.table_style()
def test_table_style(self): # 表格样式 logging.info('==========test_table_style==========') cv = CreateView(self.driver) cv.create_file('ss') time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) cv.drag_coordinate(110 + 263 * 2, 295 + 55 * 2, 110 + 263 * 3, 295 + 55 * 4) ss = SSView(self.driver) ss.group_button_click(' Edit ') ele1 = '//*[@text=" Edit "]' ele2 = '//*[@text=" Font Color "]' ele3 = '//*[@text=" Cell Fill "]' ele4 = '//*[@text=" Number Format "]' ele5 = '//*[@text=" Insert Cell "]' ss.swipe_ele(ele2, ele1) ss.swipe_ele(ele3, ele1) ss.swipe_ele(ele4, ele1) ss.swipe_ele(ele5, ele1) ss.table_style()
def test_table_style(self): # 表格样式 logging.info('==========test_table_style==========') cv = CreateView(self.driver) cv.create_file('ss', 0) time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) cv.drag_coordinate(110 + 263 * 2, 295 + 55 * 2, 110 + 263 * 3, 295 + 55 * 4) ss = SSView(self.driver) ss.group_button_click('编辑') ele1 = '//*[@resource-id="com.yozo.office:id/yozo_ui_ss_option_id_font_name"]' ele2 = '//*[@text="单元格填充"]' ele3 = '//*[@text="数字格式"]' ele4 = '//*[@text="插入单元格"]' ele5 = '//*[@text="设置行高列宽"]' ss.swipe_ele(ele2, ele1) ss.swipe_ele(ele3, ele2) ss.swipe_ele(ele4, ele3) ss.swipe_ele(ele5, ele4) ss.table_style()
def test_ss_filter_by_color(self): logging.info('==========test_ss_filter_cd1_none==========') ss = SSView(self.driver) ov = OpenView(self.driver) ov.open_file('screen.xls') ss.switch_write_read() ss.cell_edit() x, y, width, height = ss.cell_location() ss.tap(x + width / 2, y - height / 2) ss.group_button_click(' View ') self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_filter').click() x1 = x - width - 18 y1 = y - height * 3 - 27 ss.tap(x1, y1) self.driver.find_element(By.XPATH, '//*[@text="自定义"]').click() self.driver.find_element( By.ID, 'com.yozo.office.en:id/tv_filter_color_type').click() time.sleep(1) self.driver.find_element(By.XPATH, '//*[@text="字体颜色"]').click() eles = self.driver.find_elements( By.XPATH, '//android.support.v7.widget.RecyclerView/android.widget.RelativeLayout' ) eles[random.randint(0, len(eles) - 1)].click() self.driver.find_element( By.ID, 'com.yozo.office.en:id/tv_ss_filter_ok').click() ss.tap(x1, y1, 2) self.driver.find_element(By.XPATH, '//*[@text="自定义"]').click() self.driver.find_element( By.ID, 'com.yozo.office.en:id/tv_filter_color_type').click() time.sleep(1) self.driver.find_element(By.XPATH, '//*[@text="单元格颜色"]').click() eles = self.driver.find_elements( By.XPATH, '//android.support.v7.widget.RecyclerView/android.widget.RelativeLayout' ) eles[random.randint(0, len(eles) - 1)].click() self.driver.find_element( By.ID, 'com.yozo.office.en:id/tv_ss_filter_ok').click()
def test_num_style(self): logging.info('==========test_num_style==========') cv = CreateView(self.driver) cv.create_file('ss') time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) # 双击进入编辑 cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) self.driver.press_keycode(15) self.driver.press_keycode(7) self.driver.press_keycode(7) self.driver.press_keycode(7) self.driver.find_element(By.ID, 'com.yozo.office:id/formulabar_ok').click() ss = SSView(self.driver) ss.group_button_click('编辑') ele1 = '//*[@text="编辑"]' ele2 = '//*[@text="字体颜色"]' ele3 = '//*[@text="单元格填充"]' ss.swipe_ele(ele2, ele1) ss.swipe_ele(ele3, ele1) ss.cell_num_style()
def test_ss_filter2(self): logging.info('==========test_ss_filter2==========') ss = SSView(self.driver) ov = OpenView(self.driver) ov.open_file('screen.xls') ss.switch_write_read() ss.cell_edit() x, y, width, height = ss.cell_location() ss.tap(x + width / 2, y - height / 2) ss.group_button_click(' View ') self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_filter').click() x1 = x - width - 18 y1 = y - height * 3 - 27 ss.tap(x1, y1) self.driver.find_element_by_id( 'com.yozo.office.en:id/ll_ss_filter_asc').click() ss.tap(x1, y1) self.driver.find_element_by_id( 'com.yozo.office.en:id/ll_ss_filter_desc').click() ss.tap(x1, y1) self.driver.find_element_by_id( 'com.yozo.office.en:id/ll_ss_filter_clean').click() self.driver.find_element_by_id( 'com.yozo.office.en:id/tv_ss_filter_complete').click() ss.tap(x1, y1) self.driver.find_element_by_id( 'com.yozo.office.en:id/tv_ss_filter_cancel').click() ss.tap(x1, y1) self.driver.find_element_by_id( 'com.yozo.office.en:id/tv_ss_filter_select_all').click() self.driver.find_element_by_id( 'com.yozo.office.en:id/iv_ss_filter_select').click() self.driver.find_element_by_id( 'com.yozo.office.en:id/tv_ss_filter_select_all').click() self.driver.find_element_by_id( 'com.yozo.office.en:id/ll_ss_filter_customize').click() self.driver.find_element_by_id( 'com.yozo.office.en:id/iv_ss_customize_back').click()
def test_ss_data_table(self): # 数据排序,工作表格式 logging.info('==========test_ss_data_table==========') cv = CreateView(self.driver) cv.create_file('ss') ss = SSView(self.driver) ss.cell_edit() x, y, width, height = ss.cell_location() for i in range(8): ss.tap(x + width * 0.5, y + height * (1.5 + i)) ss.tap(x + width * 1.5, y + height * (1.5 + i)) ss.cell_edit() self.driver.press_keycode(random.randint(7, 16)) ss.group_button_click(' View ') ss.data_sort(' Sort Z to A ') ss.data_sort(' Sort A to Z ') ss.sheet_style(' Hide formula bar ') ss.sheet_style(' Hide formula bar ') ele = '//android.widget.ScrollView' ss.swipe_options(ele, 'up') ss.sheet_style(' Hide row and column headers ') ss.sheet_style(' Hide row and column headers ') ss.sheet_style(' Hide gridlines ') ss.sheet_style(' Hide gridlines ') ss.sheet_style(' Freeze Window ') self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_freeze_current').click( ) self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_freeze_row').click() self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_ss_option_id_freeze_column').click( ) self.driver.find_element( By.ID, 'com.yozo.office.en:id/yozo_ui_option_back_button').click() ss.sheet_style(' Unfreeze ') ss.sheet_style('100%')
def test_num_style(self): logging.info('==========test_cell_border==========') cv = CreateView(self.driver) cv.create_file('ss', 0) time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) # 双击进入编辑 cv.tap(110 + 263 * 1.5, 295 + 55 * 1.5) self.driver.press_keycode(15) self.driver.press_keycode(7) self.driver.press_keycode(7) self.driver.press_keycode(7) self.driver.find_element(By.ID, 'com.yozo.office:id/formulabar_ok').click() ss = SSView(self.driver) ss.group_button_click('编辑') ele1 = '//*[@resource-id="com.yozo.office:id/yozo_ui_ss_option_id_font_name"]' ele2 = '//*[@text="单元格填充"]' ele3 = '//*[@text="数字格式"]' ss.swipe_ele(ele2, ele1) ss.swipe_ele(ele3, ele2) ss.cell_num_style()
def test_data_table(self): # 数据排序,工作表格式 logging.info('==========test_data_table==========') cv = CreateView(self.driver) cv.create_file('ss') time.sleep(1) for i in range(10): time.sleep(1) cv.tap(110 + 263 * 1.5, 295 + 55 * (1.5 + i)) # 双击进入编辑 cv.tap(110 + 263 * 1.5, 295 + 55 * (1.5 + i)) self.driver.press_keycode(random.randint(7, 16)) ss = SSView(self.driver) ss.group_button_click('查看') time.sleep(1) ss.data_sort('降序') ss.data_sort('升序') ss.sheet_style('隐藏编辑栏') ss.sheet_style('隐藏编辑栏') ss.sheet_style('隐藏表头') ss.sheet_style('隐藏表头') ss.sheet_style('隐藏网格线') # ss.sheet_style('冻结窗口') 功能未完成 # ss.sheet_style('取消冻结') ss.sheet_style('100%') time.sleep(3)