How to use grabfocus method in pyatom

Best Python code snippet using pyatom_python

toolstripmenuitem-regression.py

Source:toolstripmenuitem-regression.py Github

copy

Full Screen

1#!/usr/bin/env python2##############################################################################3# Written by: Cachen Chen <cachen@novell.com>4# Date: 10/31/20085# Description: Test accessibility of toolstripmenuitem widget 6# Use the toolstripmenuitemframe.py wrapper script7# Test the samples/winforms/toolstripmenuitem.py script8##############################################################################9# The docstring below is used in the generated log file10"""11Test accessibility of toolstripmenuitem widget12"""13# imports14import sys15import os16from strongwind import *17from toolstripmenuitem import *18from helpers import *19from states import *20from sys import argv21from os import path22app_path = None 23try:24 app_path = argv[1]25except IndexError:26 pass #expected27# open the toolstripmenuitem sample application28try:29 app = launchToolStripMenuItem(app_path)30except IOError, msg:31 print "ERROR: %s" % msg32 exit(2)33sleep(config.SHORT_DELAY)34# make sure we got the app back35if app is None:36 exit(4)37# just an alias to make things shorter38tsmiFrame = app.toolStripMenuItemFrame39# check actions40actionsCheck(tsmiFrame.view_menu, "Menu")41actionsCheck(tsmiFrame.help_menu, "Menu")42actionsCheck(tsmiFrame.file_menu, "Menu")43actionsCheck(tsmiFrame.edit_menu, "Menu")44actionsCheck(tsmiFrame.create_menu_item, "MenuItem")45actionsCheck(tsmiFrame.write_menu_item, "MenuItem")46actionsCheck(tsmiFrame.financial_menu_item, "MenuItem")47actionsCheck(tsmiFrame.medical_menu_item, "MenuItem")48actionsCheck(tsmiFrame.new_menu_item, "MenuItem")49actionsCheck(tsmiFrame.open_menu_item, "MenuItem")50actionsCheck(tsmiFrame.copy_this_menu_item, "MenuItem")51actionsCheck(tsmiFrame.paste_that_menu_item, "MenuItem")52# check states53# We are unsure about whether these should have "focusable" states or not54# The resolution of BUG485515 might clear this up55#statesCheck(tsmiFrame.view_menu, "Menu")56#statesCheck(tsmiFrame.help_menu, "Menu")57statesCheck(tsmiFrame.file_menu, "Menu")58statesCheck(tsmiFrame.edit_menu, "Menu")59# BUG486335: MenuItem, ToolStripMenuItem: extraneous "showing" state of 60# menu item when it is not showing61#statesCheck(tsmiFrame.create_menu_item, "MenuItem", invalid_states=["showing"])62#statesCheck(tsmiFrame.write_menu_item, "MenuItem", invalid_states=["showing"])63#statesCheck(tsmiFrame.financial_menu_item, "MenuItem", invalid_states=["showing"])64#statesCheck(tsmiFrame.medical_menu_item, "MenuItem", invalid_states=["showing"])65#statesCheck(tsmiFrame.new_menu_item, "MenuItem", invalid_states=["showing"])66#statesCheck(tsmiFrame.open_menu_item, "MenuItem", invalid_states=["showing"])67#statesCheck(tsmiFrame.copy_this_menu_item, "MenuItem", invalid_states=["showing"])68#statesCheck(tsmiFrame.paste_that_menu_item, "MenuItem", invalid_states=["showing"])69# use the action interface to open the "view" menu and click on "create"70tsmiFrame.view_menu.click(log=True)71sleep(config.SHORT_DELAY)72tsmiFrame.create_menu_item.click(log=True)73sleep(config.SHORT_DELAY)74tsmiFrame.assertMessageBoxAppeared("Create Clicked")75# press enter to close the dialog76tsmiFrame.keyCombo("Enter", grabFocus=False)77# make sure the text area is blank like we expect78tsmiFrame.assertText("")79# use accelerator to access menu80tsmiFrame.keyCombo("<Alt>V", grabFocus=False)81sleep(config.SHORT_DELAY)82tsmiFrame.keyCombo("Enter", grabFocus=False)83sleep(config.SHORT_DELAY)84tsmiFrame.assertMessageBoxAppeared("Create Clicked")85# press enter to close the dialog86tsmiFrame.keyCombo("Enter", grabFocus=False)87# make sure the text area is blank like we expect88tsmiFrame.assertText("")89tsmiFrame.keyCombo("<Alt>V", grabFocus=False)90sleep(config.SHORT_DELAY)91tsmiFrame.keyCombo("Down", grabFocus=False)92sleep(config.SHORT_DELAY)93tsmiFrame.keyCombo("Enter", grabFocus=False)94sleep(config.SHORT_DELAY)95tsmiFrame.assertText("Write Clicked\n")96sleep(config.SHORT_DELAY)97tsmiFrame.clearTextArea()98sleep(config.SHORT_DELAY)99tsmiFrame.help_menu.click(log=True)100sleep(config.SHORT_DELAY)101tsmiFrame.financial_menu_item.click(log=True)102sleep(config.SHORT_DELAY)103tsmiFrame.assertText("Have some money\n")104sleep(config.SHORT_DELAY)105tsmiFrame.clearTextArea()106sleep(config.SHORT_DELAY)107tsmiFrame.keyCombo("<Alt>H", grabFocus=False)108sleep(config.SHORT_DELAY)109tsmiFrame.keyCombo("Down", grabFocus=False)110sleep(config.SHORT_DELAY)111tsmiFrame.keyCombo("Enter", grabFocus=False)112sleep(config.SHORT_DELAY)113tsmiFrame.assertText("Here is a bandage\n")114sleep(config.SHORT_DELAY)115tsmiFrame.clearTextArea()116sleep(config.SHORT_DELAY)117# click on the "Copy This" menu item without opening its parent menu118tsmiFrame.copy_this_menu_item.click(log=True)119# Bug 501074 - Cannot perform action on accessible that is not visible120# tsmiFrame.assertText("Copy Clicked\n")121# clear out the text area by using the keyboard to navigate to "New"122tsmiFrame.keyCombo("<Alt>F", grabFocus=False)123sleep(config.SHORT_DELAY)124# BUG503725 - Menu item loses "focusable" state when that item becomes focused125#statesCheck(tsmiFrame.new_menu_item,126# "MenuItem",127# add_states=[FOCUSED, SELECTED])128tsmiFrame.keyCombo("Enter", grabFocus=False)129sleep(config.SHORT_DELAY)130# BUG503735 Selected state of a menu item persists when the menu item is131# clicked. This bug causes the following statesCheck to have an extraneous132# "selected" state133#statesCheck(tsmiFrame.new_menu_item, "MenuItem")134#tsmiFrame.assertText("")135# select the File -> Open menu item and check the states along the way136tsmiFrame.keyCombo("<Alt>F", grabFocus=False)137sleep(config.SHORT_DELAY)138# BUG503725 - Menu item loses "focusable" state when that item becomes focused139#statesCheck(tsmiFrame.new_menu_item,140# "MenuItem",141# add_states=[FOCUSED, SELECTED])142tsmiFrame.keyCombo("Down", grabFocus=False)143sleep(config.SHORT_DELAY)144# BUG503735 Selected state of a menu item persists when the menu item is145# clicked. Enter was pressed for the "New" menu item above, so it still has146# the selected state here.147# statesCheck(tsmiFrame.new_menu_item, "MenuItem")148# BUG503725 Menu item loses "focusable" state when that item becomes focused149#statesCheck(tsmiFrame.open_menu_item,150# "MenuItem",151# add_states=[FOCUSED, SELECTED])152tsmiFrame.keyCombo("Enter", grabFocus=False)153sleep(config.SHORT_DELAY)154# BUG503735 Selected state of a menu item persists when the menu item is155# clicked. This bug causes the following statesCheck to have an extraneous156# "selected" state157#statesCheck(tsmiFrame.open_menu_item, "MenuItem")158# close the winow that opens159tsmiFrame.keyCombo("Enter", grabFocus=False)160# use mouseClicks to click on "Paste That", then check the text area text161# BUG503973 pyatspi.generateMouseEvent does not open menu when application162# window is active163#tsmiFrame.edit_menu.mouseClick()164#sleep(config.SHORT_DELAY)165#tsmiFrame.paste_that_menu_item.mouseClick()166#sleep(config.SHORT_DELAY)167# BUG486335 MenuItem, ToolStripMenuItem: extraneous "showing" state of168# menu item when it is not showing. This means that calling assertEditMenuOpen169# will always succeed while this bug is open170#tsmiFrame.assertEditMenuOpen()171# BUG503973 172#tsmiFrame.assertText("Paste Clicked\n")173sleep(config.SHORT_DELAY)174tsmiFrame.clearTextArea()175tsmiFrame.keyCombo("<Alt>E", grabFocus=False)176sleep(config.SHORT_DELAY)177# use the keyboard to navigate to "Paste That" and then press Enter, then178# check the text area text179# BUG503725 - Menu item loses "focusable" state when that item becomes focused180#statesCheck(tsmiFrame.copy_this_menu_item,181# "MenuItem",182# add_states=[FOCUSED, SELECTED])183tsmiFrame.keyCombo("Down", grabFocus=False)184sleep(config.SHORT_DELAY)185# the copy menu should go back to the default states186statesCheck(tsmiFrame.copy_this_menu_item, "MenuItem")187# BUG503725 - Menu item loses "focusable" state when that item becomes focused188#statesCheck(tsmiFrame.paste_this_menu_item,189# "MenuItem",190# add_states=[FOCUSED, SELECTED])191tsmiFrame.keyCombo("Enter", grabFocus=False)192sleep(config.SHORT_DELAY)193# BUG503735 Selected state of a menu item persists when the menu item is194# clicked. This bug causes the following statesCheck to have an extraneous195# "selected" state196#statesCheck(tsmiFrame.paste_that_menu_item, "MenuItem")197tsmiFrame.assertText("Paste Clicked\n")198tsmiFrame.keyCombo("<Alt>V", grabFocus=False)199sleep(config.SHORT_DELAY)200statesCheck(tsmiFrame.create_menu_item, "MenuItem", add_states=['selected', 'focused'])201tsmiFrame.keyCombo("Down", grabFocus=False)202sleep(config.SHORT_DELAY)203statesCheck(tsmiFrame.write_menu_item, "MenuItem", add_states=['selected', 'focused'])204statesCheck(tsmiFrame.create_menu_item, "MenuItem")205tsmiFrame.keyCombo("<Alt>H", grabFocus=False)206sleep(config.SHORT_DELAY)207statesCheck(tsmiFrame.financial_menu_item, "MenuItem", add_states=['selected', 'focused'])208tsmiFrame.keyCombo("Down", grabFocus=False)209sleep(config.SHORT_DELAY)210statesCheck(tsmiFrame.medical_menu_item, "MenuItem", add_states=['selected', 'focused'])211statesCheck(tsmiFrame.financial_menu_item, "MenuItem")212#close main window...

Full Screen

Full Screen

textbox-regression.py

Source:textbox-regression.py Github

copy

Full Screen

1#!/usr/bin/env python2##############################################################################3# Written by: Cachen Chen <cachen@novell.com>4# Date: 11/03/20095# Description: Test accessibility of textbox widget6# Use the textboxframe.py wrapper script7# Test the Moonlight textbox sample8##############################################################################9# The docstring below is used in the generated log file10"""11Test accessibility of textbox widget12"""13# imports14from strongwind import *15from textbox import *16from helpers import *17from sys import argv18from os import path19app_path = None20try:21 app_path = argv[1]22except IndexError:23 pass #expected24# open the textbox sample application25try:26 app = launchTextBox(app_path)27except IOError, msg:28 print "ERROR: %s" % msg29 exit(2)30# make sure we got the app back31if app is None:32 exit(4)33# just an alias to make things shorter34tbFrame = app.textBoxFrame35##############36# Check States37##############38# check the states of the text boxes39# XXX Bug556832 won't be fixed, so the implement won't support 40# multi-line or single-line states41statesCheck(tbFrame.textbox1, "TextBox")42statesCheck(tbFrame.textbox2, "TextBox", invalid_states=["editable"])43statesCheck(tbFrame.textbox3, "TextBox")44# mouse click frame to focus on textbox145tbFrame.mouseClick()46sleep(config.SHORT_DELAY)47statesCheck(tbFrame.textbox1, "TextBox", add_states=["focused"])48statesCheck(tbFrame.textbox2, "TextBox", invalid_states=["editable"])49statesCheck(tbFrame.textbox3, "TextBox")50# switch focus to textbox251tbFrame.keyCombo("Tab", grabFocus=False)52sleep(config.SHORT_DELAY)53statesCheck(tbFrame.textbox1, "TextBox")54statesCheck(tbFrame.textbox2, "TextBox", add_states=["focused"],55 invalid_states=["editable"])56statesCheck(tbFrame.textbox3, "TextBox")57# switch focus to textbox358tbFrame.keyCombo("Tab", grabFocus=False)59sleep(config.SHORT_DELAY)60statesCheck(tbFrame.textbox1, "TextBox")61statesCheck(tbFrame.textbox2, "TextBox", invalid_states=["editable"])62statesCheck(tbFrame.textbox3, "TextBox", add_states=["focused"])63##############################64# Test Read and Write TextBox65##############################66# Delete texts67tbFrame.textbox1.deleteText()68sleep(config.SHORT_DELAY)69# Insert texts from 0 offset70tbFrame.textbox1.insertText("single line", 0)71sleep(config.SHORT_DELAY)72tbFrame.assertEditableText(tbFrame.textbox1, "single line")73# textbox2's text is updated to the textbox1's text74assertText(tbFrame.textbox2, "single line")75# append text at the end76text_len = len(tbFrame.textbox1.text)77tbFrame.textbox1.insertText(" test", text_len)78sleep(config.SHORT_DELAY)79tbFrame.assertEditableText(tbFrame.textbox1, "single line test")80# textbox2's text is updated to the insert text81assertText(tbFrame.textbox2, "single line test")82# delete text from end (delete "test")83text_len = len(tbFrame.textbox1.text)84tbFrame.textbox1.deleteText(text_len - 5)85sleep(config.SHORT_DELAY)86tbFrame.assertEditableText(tbFrame.textbox1, "single line")87assertText(tbFrame.textbox2, "single line")88# delete text from front (delete "single")89tbFrame.textbox1.deleteText(0, 7)90sleep(config.SHORT_DELAY)91tbFrame.assertEditableText(tbFrame.textbox1, "line")92assertText(tbFrame.textbox2, "line")93# enter texts94tbFrame.textbox1.enterText("new test line")95sleep(config.SHORT_DELAY)96tbFrame.assertEditableText(tbFrame.textbox1, "new test line")97assertText(tbFrame.textbox2, "new test line")98####################99# Test Read TextBox100####################101# Insert texts from 0 offset102tbFrame.textbox2.insertText("single line ", 0)103sleep(config.SHORT_DELAY)104# textbox2 is not editable105tbFrame.assertEditableText(tbFrame.textbox2, "new test line")106# delete text from front (delete "single")107tbFrame.textbox2.deleteText(0, 7)108sleep(config.SHORT_DELAY)109# it's not deleteable110tbFrame.assertEditableText(tbFrame.textbox2, "new test line")111######################112# Test Search TextBox113######################114# mouse click textbox3 to remove text "Search"115tbFrame.mouseClick()116sleep(config.SHORT_DELAY)117tbFrame.keyCombo('Tab', grabFocus=False)118sleep(config.SHORT_DELAY)119tbFrame.keyCombo('Tab', grabFocus=False)120sleep(config.SHORT_DELAY)121tbFrame.keyCombo('Tab', grabFocus=False)122sleep(config.SHORT_DELAY)123tbFrame.assertEditableText(tbFrame.textbox3, "")124# mouse click other textbox to reset text "Search"125tbFrame.mouseClick()126sleep(config.SHORT_DELAY)127tbFrame.keyCombo('Tab', grabFocus=False)128sleep(config.SHORT_DELAY)129tbFrame.keyCombo('Tab', grabFocus=False)130sleep(config.SHORT_DELAY)131tbFrame.assertEditableText(tbFrame.textbox3, "Search")132# type texts133tbFrame.mouseClick()134sleep(config.SHORT_DELAY)135tbFrame.keyCombo('Tab', grabFocus=False)136sleep(config.SHORT_DELAY)137tbFrame.keyCombo('Tab', grabFocus=False)138sleep(config.SHORT_DELAY)139tbFrame.keyCombo('Tab', grabFocus=False)140sleep(config.SHORT_DELAY)141#tbFrame.textbox3.typeText("Search TextBox")142tbFrame.textbox3.enterText("Search TextBox")143sleep(config.SHORT_DELAY)144tbFrame.assertEditableText(tbFrame.textbox3, "Search TextBox")145# move focus doesn't change text146tbFrame.mouseClick()147sleep(config.SHORT_DELAY)148tbFrame.assertEditableText(tbFrame.textbox3, "Search TextBox")149# grab focus to textbox3 to remove text150tbFrame.keyCombo("Tab", grabFocus=False)151sleep(config.SHORT_DELAY)152tbFrame.assertEditableText(tbFrame.textbox3, "")153# move focus again will change text to "Search"154tbFrame.mouseClick()155sleep(config.SHORT_DELAY)156tbFrame.keyCombo('Tab', grabFocus=False)157sleep(config.SHORT_DELAY)158tbFrame.keyCombo('Tab', grabFocus=False)159sleep(config.SHORT_DELAY)160tbFrame.assertEditableText(tbFrame.textbox3, "Search")161###############162# Close Firefox163###############...

Full Screen

Full Screen

errorprovider-regression.py

Source:errorprovider-regression.py Github

copy

Full Screen

1#!/usr/bin/env python2# vim: set tabstop=4 shiftwidth=4 expandtab3##############################################################################4# Written by: Brian G. Merrell <bgmerrell@novell.com>5# Date: 12/03/20086# Description: Test accessibility of ErrorProvider widget 7# Use the errorproviderframe.py wrapper script8# Test the samples/winforms/errorprovider.py script9##############################################################################10# The docstring below is used in the generated log file11"""12Test accessibility of ErrorProvider widget13"""14# imports15from errorprovider import *16from helpers import *17from states import *18from actions import *19from sys import argv20import sys21app_path = None 22try:23 app_path = argv[1]24except IndexError:25 pass #expected26# open the treeview sample application27try:28 app = launchErrorProvider(app_path)29except IOError, msg:30 print "ERROR: %s" % msg31 exit(2)32# make sure we got the app back33if app is None:34 exit(4)35# just an alias to make things shorter36epFrame = app.errorProviderFrame37# tab to the second text box, which should raise an error provider icon38epFrame.keyCombo("Tab", grabFocus=False)39sleep(config.SHORT_DELAY)40# assert that the error appeared41epFrame.assertSingleErrorAppeared(0, "Name required")42# keep tabbing through the other text boxes43epFrame.keyCombo("Tab", grabFocus=False)44sleep(config.SHORT_DELAY)45# assert that the error appeared46epFrame.assertSingleErrorAppeared(1, "Age required")47epFrame.keyCombo("Tab", grabFocus=False)48sleep(config.SHORT_DELAY)49# assert that the error appeared50epFrame.assertSingleErrorAppeared(2, "Weight required")51epFrame.keyCombo("Tab", grabFocus=False)52sleep(config.SHORT_DELAY)53# assert that the error appeared54epFrame.assertSingleErrorAppeared(3, "Height required")55epFrame.keyCombo("Tab", grabFocus=False)56sleep(config.SHORT_DELAY)57# assert that the error appeared58epFrame.assertSingleErrorAppeared(4, "Depth required")59# since all of the panels are up, let's check their states60epFrame.checkErrorProviderStates(5)61# now type some text and make sure the error providers go away62# we are at the first text box at this point63# type some text, issue a tab keystroke, and make sure the 0th error provider64# goes away65epFrame.typeText("Julio")66epFrame.keyCombo("Tab", grabFocus=False)67sleep(config.SHORT_DELAY)68# now the 0th panel should be the 1st panel from before (i.e., age)69# assert that the error appeared70epFrame.assertSingleErrorAppeared(0, "Age required")71# and so on...72epFrame.typeText("21")73epFrame.keyCombo("Tab", grabFocus=False)74sleep(config.SHORT_DELAY)75epFrame.assertSingleErrorAppeared(0, "Weight required")76epFrame.typeText("200")77epFrame.keyCombo("Tab", grabFocus=False)78sleep(config.SHORT_DELAY)79epFrame.assertSingleErrorAppeared(0, "Height required")80epFrame.typeText("6 foot 2 inches")81epFrame.keyCombo("Tab", grabFocus=False)82sleep(config.SHORT_DELAY)83epFrame.assertSingleErrorAppeared(0, "Depth required")84epFrame.typeText("4")85epFrame.keyCombo("Tab", grabFocus=False)86sleep(config.SHORT_DELAY)87# there shouldn't be any panels left88epFrame.assertNoPanels()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful