Example #1
0
    def execute(self, run):
        print '  Taking screenshot', self.index
        original = self.get_path(run)
        new = os.path.join(run.path, 'last.png')

        with SCREENSHOT_LOCK:
            # Steal focus for a consistent screenshot
            run.d.switch_to_window(run.d.window_handles[0])
            if run.mode == TestRunModes.RERECORD:
                run.d.save_screenshot(original)
            else:
                run.d.save_screenshot(new)
                try:
                    if not images_identical(original, new):
                        if run.save_diff:
                            diffpath = os.path.join(run.path, 'diff.png')
                            diff = image_diff(original, new, diffpath, run.diffcolor)
                            raise TestError(
                                ('Screenshot %s was different; compare %s with %s. See %s ' +
                                 'for the comparison. diff=%r') % (
                                    self.index, original, new, diffpath, diff
                                )
                            )
                        else:
                            raise TestError('Screenshot %s was different.' % self.index)
                finally:
                    if not run.save_diff:
                        os.unlink(new)
Example #2
0
 def execute(self, run):
     print '  Taking screenshot', self.index
     original = self.get_path(run)
     new = os.path.join(run.path, 'last.png')
     if run.mode == TestRunModes.RERECORD:
         run.d.save_screenshot(original)
     else:
         run.d.save_screenshot(new)
         try:
             if not images_identical(original, new):
                 if run.save_diff:
                     diffpath = os.path.join(run.path, 'diff.png')
                     diff = image_diff(original, new, diffpath, run.diffcolor)
                     raise TestError(
                         ('Screenshot %s was different; compare %s with %s. See %s ' +
                          'for the comparison. diff=%r') % (
                             self.index, original, new, diffpath, diff
                         )
                     )
                 else:
                     raise TestError('Screenshot %s was different.' % self.index)
         except (TestError, ValueError) as e:
           print ' ', e
           pass
         finally:
             if not run.save_diff:
                 os.unlink(new)
Example #3
0
    def execute(self, run):
        print '  Taking screenshot', self.index
        original = self.get_path(run)
        new = os.path.join(run.path, 'last.png')

        with SCREENSHOT_LOCK:
            # Steal focus for a consistent screenshot
            run.d.switch_to_window(run.d.window_handles[0])

            # iOS insertion points are visible in screenshots
            if run.d.name == 'Safari':
                active = run.d.execute_script('a = document.activeElement; a.blur(); return a;')

            if run.mode == TestRunModes.RERECORD:
                run.d.save_screenshot(original)
            else:
                run.d.save_screenshot(new)
                try:
                    if not images_identical(original, new, run.test.mask):
                        if run.save_diff:
                            diffpath = os.path.join(run.path, 'diff.png')
                            diff = image_diff(original, new, diffpath, run.diffcolor, run.test.mask)
                            raise TestError(
                                ('Screenshot %s was different; compare %s with %s. See %s ' +
                                 'for the comparison. diff=%r') % (
                                    self.index, original, new, diffpath, diff
                                )
                            )
                        else:
                            raise TestError('Screenshot %s was different.' % self.index)
                finally:
                    if not run.save_diff:
                        os.unlink(new)
Example #4
0
    def execute(self, run):
        print '  Taking screenshot', self.index
        original = self.get_path(run)
        new = os.path.join(run.path, 'last.png')

        with SCREENSHOT_LOCK:
            # Steal focus for a consistent screenshot
            run.d.switch_to_window(run.d.window_handles[0])
            if run.mode == TestRunModes.RERECORD:
                run.d.save_screenshot(original)
            else:
                run.d.save_screenshot(new)
                try:
                    if not images_identical(original, new):
                        if run.save_diff:
                            diffpath = os.path.join(run.path, 'diff.png')
                            diff = image_diff(original, new, diffpath,
                                              run.diffcolor)
                            raise TestError((
                                'Screenshot %s was different; compare %s with %s. See %s '
                                + 'for the comparison. diff=%r') %
                                            (self.index, original, new,
                                             diffpath, diff))
                        else:
                            raise TestError('Screenshot %s was different.' %
                                            self.index)
                finally:
                    if not run.save_diff:
                        os.unlink(new)
Example #5
0
    def execute(self, run):
        print '  Taking screenshot', self.index
        original = self.get_path(run)
        new = os.path.join(run.path, 'last.png')

        with SCREENSHOT_LOCK:
            # Steal focus for a consistent screenshot
            run.d.switch_to_window(run.d.window_handles[0])

            # iOS insertion points are visible in screenshots
            if run.d.name == 'Safari':
                active = run.d.execute_script('a = document.activeElement; a.blur(); return a;')

            if run.mode == TestRunModes.RERECORD:
                run.d.save_screenshot(original)
            else:
                run.d.save_screenshot(new)
                try:
                    if not images_identical(original, new, run.test.mask):
                        if run.save_diff:
                            diffpath = os.path.join(run.path, 'diff.png')
                            diff = image_diff(original, new, diffpath, run.diffcolor, run.test.mask)
                            raise TestError(
                                ('Screenshot %s was different; compare %s with %s. See %s ' +
                                 'for the comparison. diff=%r') % (
                                    self.index, original, new, diffpath, diff
                                )
                            )
                        else:
                            raise TestError('Screenshot %s was different.' % self.index)
                finally:
                    if not run.save_diff:
                        os.unlink(new)
Example #6
0
    def execute(self, run):
        print '  Taking screenshot', self.index
        if run.mode & TestRunModes.HISRECORD:
            run_start_time = TestRunStartTime().get_start_time()
            original = self.get_latest_path(run, run_start_time)
            if not original:
                original = os.path.join(
                    self.create_run_path(run, run_start_time),
                    'screenshot' + str(self.index) + '.png')
                new = original
            else:
                new = os.path.join(self.create_run_path(run, run_start_time),
                                   'screenshot' + str(self.index) + '.png')
        else:
            original = self.get_path(run)
            new = os.path.join(run.path, 'last.png')

        if run.mode & TestRunModes.RERECORD:
            run.d.save_screenshot(original)
        else:
            run.d.save_screenshot(new)
            try:
                if not images_identical(original, new):
                    if run.save_diff:
                        diffpath = new.replace('.png', '') + '_diff.png'
                        diff = image_diff(original, new, diffpath,
                                          run.diffcolor)
                        raise TestError((
                            'Screenshot %s was different; compare %s with %s. See %s '
                            + 'for the comparison. diff=%r') %
                                        (self.index, original, new, diffpath,
                                         diff))
                    else:
                        raise TestError('Screenshot %s was different.' %
                                        self.index)
            finally:
                if (not run.save_diff) and not (run.mode
                                                & TestRunModes.HISRECORD):
                    os.unlink(new)