Example #1
0
def run_test(record, playback_only, save_diff, new_screenshots, file, config,
             testname):
    print '[' + testname + '] Running test:', testname
    test_config = dict(config.items(testname))
    url = config.get(testname, 'url')
    default_filename = os.path.join(os.path.dirname(file),
                                    testname + '.huxley')
    filename = test_config.get('filename', default_filename)
    sleepfactor = float(test_config.get('sleepfactor', 1.0))
    postdata = test_config.get('postdata')
    screensize = test_config.get('screensize', '1024x768')
    if record:
        r = huxleymain(testname,
                       url,
                       filename,
                       postdata,
                       local=LOCAL_WEBDRIVER_URL,
                       remote=REMOTE_WEBDRIVER_URL,
                       record=True,
                       screensize=screensize)
    else:
        r = huxleymain(testname,
                       url,
                       filename,
                       postdata,
                       remote=REMOTE_WEBDRIVER_URL,
                       sleepfactor=sleepfactor,
                       autorerecord=not playback_only,
                       save_diff=save_diff,
                       screensize=screensize)
    print
    if r != 0:
        new_screenshots.set_value(True)
Example #2
0
def run_test(record, playback_only, save_diff, new_screenshots, file, config, testname):
    print "[" + testname + "] Running test:", testname
    test_config = dict(config.items(testname))
    url = config.get(testname, "url")
    default_filename = os.path.join(os.path.dirname(file), testname + ".huxley")
    filename = test_config.get("filename", default_filename)
    sleepfactor = float(test_config.get("sleepfactor", 1.0))
    postdata = test_config.get("postdata")
    screensize = test_config.get("screensize", "1024x768")
    if record:
        r = huxleymain(
            testname,
            url,
            filename,
            postdata,
            local=LOCAL_WEBDRIVER_URL,
            remote=REMOTE_WEBDRIVER_URL,
            record=True,
            screensize=screensize,
        )
    else:
        r = huxleymain(
            testname,
            url,
            filename,
            postdata,
            remote=REMOTE_WEBDRIVER_URL,
            sleepfactor=sleepfactor,
            autorerecord=not playback_only,
            save_diff=save_diff,
            screensize=screensize,
        )
    print
    if r != 0:
        new_screenshots.set_value(True)
Example #3
0
def run_test(record, playback_only, save_diff, new_screenshots, file, config, testname):
    print '[' + testname + '] Running test:', testname
    test_config = dict(config.items(testname))
    url = config.get(testname, 'url')
    default_filename = os.path.join(
        os.path.dirname(file),
        testname + '.huxley'
    )
    filename = test_config.get(
        'filename',
        default_filename
    )
    sleepfactor = float(test_config.get(
        'sleepfactor',
        1.0
    ))
    postdata = test_config.get(
        'postdata'
    )
    screensize = test_config.get(
        'screensize',
        '1024x768'
    )
    if record:
        r = huxleymain(
            testname,
            url,
            filename,
            postdata,
            local=LOCAL_WEBDRIVER_URL,
            remote=REMOTE_WEBDRIVER_URL,
            record=True,
            screensize=screensize
        )
    else:
        r = huxleymain(
            testname,
            url,
            filename,
            postdata,
            remote=REMOTE_WEBDRIVER_URL,
            sleepfactor=sleepfactor,
            autorerecord=not playback_only,
            save_diff=save_diff,
            screensize=screensize
        )
    print
    if r != 0:
        new_screenshots.set_value(True)
Example #4
0
def _main(
    names=None,
    testfile='Huxleyfile',
    record=False,
    playback_only=False,
    save_diff=False,
    version=False
):
    if version:
        print 'Huxley ' + __version__
        return ExitCodes.OK

    testfiles = glob.glob(testfile)
    if len(testfiles) == 0:
        print 'no Huxleyfile found'
        return ExitCodes.ERROR

    new_screenshots = False

    for file in testfiles:
        msg = 'Running Huxley file: ' + file
        print '-' * len(msg)
        print msg
        print '-' * len(msg)

        config = ConfigParser.SafeConfigParser(
            defaults=DEFAULTS,
            allow_no_value=True
        )
        config.read([file])
        for testname in config.sections():
            if names and (testname not in names):
                continue
            print 'Running test:', testname
            test_config = dict(config.items(testname))
            url = config.get(testname, 'url')
            default_filename = os.path.join(
                os.path.dirname(file),
                testname + '.huxley'
            )
            filename = test_config.get(
                'filename',
                default_filename
            )
            sleepfactor = float(test_config.get(
                'sleepfactor',
                1.0
            ))
            postdata = test_config.get(
                'postdata'
            )
            screensize = test_config.get(
                'screensize',
                '1024x768'
            )
            browser = test_config.get(
                'browser',
                'firefox'
            )
            if record:
                r = huxleymain(
                    url,
                    filename,
                    postdata,
                    local=LOCAL_WEBDRIVER_URL,
                    remote=REMOTE_WEBDRIVER_URL,
                    record=True,
                    screensize=screensize,
                    browser=browser
                )
            else:
                r = huxleymain(
                    url,
                    filename,
                    postdata,
                    remote=REMOTE_WEBDRIVER_URL,
                    sleepfactor=sleepfactor,
                    autorerecord=not playback_only,
                    save_diff=save_diff,
                    screensize=screensize,
                    browser=browser
                )
            new_screenshots = new_screenshots or (r != 0)
            print

    if new_screenshots:
        print '** New screenshots were written; please verify that they are correct. **'
        return ExitCodes.NEW_SCREENSHOTS
    else:
        return ExitCodes.OK
Example #5
0
def _main(names=None,
          testfile='Huxleyfile',
          record=False,
          playback_only=False,
          save_diff=False,
          version=False):
    if version:
        print 'Huxley ' + __version__
        return ExitCodes.OK

    testfiles = glob.glob(testfile)
    if len(testfiles) == 0:
        print 'no Huxleyfile found'
        return ExitCodes.ERROR

    new_screenshots = False

    for file in testfiles:
        msg = 'Running Huxley file: ' + file
        print '-' * len(msg)
        print msg
        print '-' * len(msg)

        config = ConfigParser.SafeConfigParser(defaults=DEFAULTS,
                                               allow_no_value=True)
        config.read([file])
        for testname in config.sections():
            if names and (testname not in names):
                continue
            print 'Running test:', testname
            test_config = dict(config.items(testname))
            url = config.get(testname, 'url')
            default_filename = os.path.join(os.path.dirname(file),
                                            testname + '.huxley')
            filename = test_config.get('filename', default_filename)
            sleepfactor = float(test_config.get('sleepfactor', 1.0))
            postdata = test_config.get('postdata')
            screensize = test_config.get('screensize', '1024x768')
            if record:
                r = huxleymain(url,
                               filename,
                               postdata,
                               local=LOCAL_WEBDRIVER_URL,
                               remote=REMOTE_WEBDRIVER_URL,
                               record=True,
                               screensize=screensize)
            else:
                r = huxleymain(url,
                               filename,
                               postdata,
                               remote=REMOTE_WEBDRIVER_URL,
                               sleepfactor=sleepfactor,
                               autorerecord=not playback_only,
                               save_diff=save_diff,
                               screensize=screensize)
            new_screenshots = new_screenshots or (r != 0)
            print

    if new_screenshots:
        print '** New screenshots were written; please verify that they are correct. **'
        return ExitCodes.NEW_SCREENSHOTS
    else:
        return ExitCodes.OK
Example #6
0
    def test_huxley_base(self):
        test_error_list = []
        i_dir = os.path.dirname(sys.modules[self.__class__.__module__].__file__)
        msg = """
               # Okkkkkkkkkkkkkkkkk,Let'party------------------------
               #
               #                 _   /|          Running Huxley test:%s
               #                 β”‚
               #                 \'o.O'
               #                 β”‚In [3]:
               #                 =(___)=
               # β”‚---------------------------------------------------
                                   U
              """ % os.path.basename(i_dir)
        print '\n'.join([line.strip() for line in msg.splitlines()])

        #foreach all dirs, run each test
        huxley_configs = glob.glob(os.path.join(i_dir, '*.conf'))
        if len(huxley_configs) > 1:
            raise ValueError('only support one conf file, current dir:%s has %d files'
                    % (i_dir, len(huxley_configs)))
        if len(huxley_configs) < 1:
            raise ValueError('None conf file, current dir:%s has %d files' % (i_dir, len(huxley_configs)))
        config = HuxleyConfig(os.path.join(os.path.realpath(i_dir), os.path.basename(huxley_configs[0])))

        try:
            huxleymain(
                    url=config.url,
                    filename=config.run_dir,
                    postdata=config.postdata,
                    sleepfactor=config.sleepfactor,
                    screensize=config.screensize,
                    remote=self.remote_webdriver_url,
                    save_diff=True,
                    his_mode=True
                )
        except TestError, e:
            for ierror in e.errorlist:
                timestamp = ierror['timestamp'].strftime('%Y%m%d%H%M%S')
                errmsg = """
                           ------------------------------------------------------------------------------------------------
                             _____ ____  ____   ___  ____
                            | ____|  _ \|  _ \ / _ \|  _
                            |  _| | |_) | |_) | | | | |_) |
                            | |___|  _ <|  _ <| |_| |  _ <
                            |_____|_| \_\_| \_ ___/|_| \_

                            Test_URL:%s
                            Errmsg:%s
                            Step:%s
                            Confirm URL:%s
                           ------------------------------------------------------------------------------------------------

                         """  % (config.url, ierror['error'], ierror['step'],
                                 urlparse.urljoin(self.test_confirm_url,
                                                  os.path.join(os.path.relpath(i_dir, os.getcwd()),
                                                               os.path.basename(i_dir).lstrip('test_') +'.huxley',
                                                               timestamp, timestamp)
                                                  )
                                )
                print '\n'.join([line.strip() for line in errmsg.splitlines()])
                test_error_list.append(ierror)