Esempio n. 1
0
class A11yTest1(unittest.TestCase):
    def setUp(self):
        self.runner = MatsRunner(
            config_file="../winconfig.ini", url="file://" + os.path.join(os.getcwd(), "pages", "test1.html")
        )
        self.runner.start()

    def test_msaa_at(self):
        self.assertEqual(True, self.runner.instantiate_a11y())
        tree = self.runner.controller.getAccessibleTree()

        FileButton = tree.xpath('//*[@name="File" and @keyboard-shortcut="Alt+F" and @role="menuitem"]')

        self.assertEqual(len(FileButton), 1)
        FileButton = FileButton[0]

        self.assertEqual(len(FileButton), 1)  # it should have a single child now

        FilePopup = FileButton[0]
        self.assertEqual(len(FilePopup), 0)  # that has no children

        FilePopup = None  # removing old
        # until is clicked.

        FileButton.do_default_action()
        FileButton.update()

        self.assertGreater(len(FileButton), 1)  # check for newcomer

        FilePopup2 = FileButton[1]  # get him

        self.assertGreater(FilePopup2.get("height"), 0)  # he should be visible.

        #        print 'fb len : ' + str(len(FileButton))
        #        for child in FileButton:
        #            print str(child.items())
        #            for sub in child:
        #                print 'sub:' + str(sub.items())

        ExitButton = FilePopup2.xpath('accessible[@name="Exit" and @role="menuitem"]')
        self.assertEqual(len(ExitButton), 1)
        ExitButton = ExitButton[0]

        self.assertTrue(ExitButton.do_default_action())

        self.runner.wait_for_stop()

    def tearDown(self):
        pass
Esempio n. 2
0
class A11yTest1(unittest.TestCase):
    def setUp(self):
        self.runner = MatsRunner(config_file = '../winconfig.ini', url = 'file://' + os.path.join(os.getcwd(), 'pages', 'test1.html'))
        self.runner.start()
        
    def test_if_firefox_stops_on_clicking_close_button(self):
        
        self.assertEqual(True, self.runner.instantiate_a11y())

        tree = self.runner.controller.getAccessibleTree()
        
#        this points to something else. No clue what. The MSAA is as intuitive as quantum mechanics
#        menu_buttons = tree.xpath('accessible[@name="System" and @role="2"]/accessible[@name="System" and @role="12"]/accessible[@name="System" and @role="11"]/*')
#        #/accessible[@name="System"]/accessible[@name="System"]/accessible[@default-action="Execute" and @keyboard-shortcut="c"]')
#        
#        print menu_buttons
#        
#        for button in menu_buttons:
#            if "Close" in (button.get("name") or ""):
#                close_button = button
#                break
#        
#        self.assertEqual(close_button.get('default-action'), 'Execute')
#        pyshell.runShellHere({'runner' : self.runner, 'but' : close_button})
        
        
        close_button = tree.xpath('accessible[@value="MSAA test1 - Nightly"]/accessible[@name="Close" and @role="pushbutton"]')
        self.assertEqual(len(close_button), 1)
        close_button = close_button[0]
        self.assertEqual(close_button.get('default-action'), 'Press') 
        self.assertTrue(close_button.do_default_action())
        self.runner.wait_for_stop()
        pass
            
    def tearDown(self):
        #self.runner.stop() #not in this test!
        pass
Esempio n. 3
0
File: run.py Progetto: askalski/mats
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

#this file is a temporary wrap-up for dev purposes

from sys import argv, stdout
from optparse import OptionParser
from mats_runner import MatsRunner
from mats_runner.pyshell import falle

parser = OptionParser()
parser.add_option('-c', '--config',
                  dest='config',
                  help="alternative config file location",
                  metavar="FILE",
                  default="config.ini")

args = parser.parse_args()
print 'Using config file: ' + args[0].config

runner = MatsRunner(args[0].config)
try:
    runner.start()
    runner.wait_for_stop()
    print 'bye!'
#except KeyboardInterrupt:
#    runner.stop()
except Exception as e:
    falle(e, {'runner' : runner})