def create_table_in_design_mode(context, name, dbname): select_menuitem(context, "Insert -> Table Design...") window_is_displayed( context, dbname + ".odb : " + "Table1" + " - LibreOffice Base: Table Design") # fill out values for table create_table_window = context.app.get_current_window() master_table = create_table_window.findChildren( lambda x: x.roleName == 'table' and x.name == 'Table')[0] # this part is kind of magic - it uses TAB for moving in table and grabFocus # and typeText because original type text on object of table is not implemented in current version of dogtail master_table[1].grabFocus() typeText(TABLE_FIELDS[0]['name']) pressKey('\t') pressKey('\t') typeText(TABLE_FIELDS[0]['description']) pressKey('\t') typeText(TABLE_FIELDS[1]['name']) pressKey('\t') pressKey('\t') typeText(TABLE_FIELDS[1]['description']) pressKey('\t') typeText(TABLE_FIELDS[2]['name']) pressKey('\t') pressKey('\t') typeText(TABLE_FIELDS[2]['description']) # click na save as create_table_window.findChildren( lambda x: x.roleName == 'push button' and x.name == 'Save' and x. showing)[0].click() dialog = context.app.get_current_window() sleep(2) assert dialog.name == 'Save As', "probably bad dialog because name of dialog should be Save as, but was '%s'" % ( dialog.name) dialog.textentry('Table Name').typeText(name) dialog.button('OK').click() if context.app.get_current_window().name == 'LibreOffice Base': context.app.get_current_window().button('Yes').click() # close edit table window keyCombo('<Control>w')
def create_table_in_design_mode(context, name, dbname): select_menuitem(context, "Insert -> Table Design...") window_is_displayed(context, dbname + ".odb : " + "Table1" + " - LibreOffice Base: Table Design") # fill out values for table create_table_window = context.app.get_current_window() master_table = create_table_window.findChildren(lambda x: x.roleName == 'table' and x.name == 'Table')[0] # this part is kind of magic - it uses TAB for moving in table and grabFocus # and typeText because original type text on object of table is not implemented in current version of dogtail master_table[1].grabFocus() typeText(TABLE_FIELDS[0]['name']) pressKey('\t') pressKey('\t') typeText(TABLE_FIELDS[0]['description']) pressKey('\t') typeText(TABLE_FIELDS[1]['name']) pressKey('\t') pressKey('\t') typeText(TABLE_FIELDS[1]['description']) pressKey('\t') typeText(TABLE_FIELDS[2]['name']) pressKey('\t') pressKey('\t') typeText(TABLE_FIELDS[2]['description']) # click na save as create_table_window.findChildren(lambda x: x.roleName == 'push button' and x.name == 'Save' and x.showing)[ 0].click() dialog = context.app.get_current_window() sleep(2) assert dialog.name == 'Save As', "probably bad dialog because name of dialog should be Save as, but was '%s'" % ( dialog.name) dialog.textentry('Table Name').typeText(name) dialog.button('OK').click() if context.app.get_current_window().name == 'LibreOffice Base': context.app.get_current_window().button('Yes').click() # close edit table window keyCombo('<Control>w')
def make_sheet_protected(context): select_menuitem(context, "Tools -> Protect Document -> Sheet...") dialog_frame_window_is_displayed(context, "Protect Sheet") dialog = context.app.get_current_window() # fill password text_fields = dialog.findChildren(lambda x: x.roleName == 'password text') text_fields[0].grabFocus() typeText("red hat") text_fields[1].grabFocus() typeText("red hat") selector1 = dialog.child(roleName='check box', name='Select protected cells') selector2 = dialog.child(roleName='check box', name='Select unprotected cells') if not selector2.checked: selector1.doAction('click') if not selector2.checked: selector1.doAction('click') # confirm dialog.child(name='OK').click() dialog_frame_window_is_displayed(context, "Untitled 1 - LibreOffice Calc")