# coding: utf-8

import mss
from PIL import Image

from base.config.config import Config
from base.tools.sm_tools import SmallTools


class Screenshot:
    scenario = ""

    def __init__(self, scenario, test):
        self.scenario = scenario
        self.test = test
        self.cancelled = False
        self.config = Config()
        self.reports_folder = SmallTools.get_reports_folder(self.scenario)

    def capture(self, browser, suffix=''):
        if suffix != '':
            suffix = '-' + suffix
        filename = SmallTools.sanitize_filename('%s%s.png' % (self.test, suffix))

        if self.config.get_capture_size() == 'Full':
            self.capture_screen(filename)
        else:
            self.capture_browser(browser, filename)

    def capture_screen(self, filename):
        with mss.mss() as sct:
            sct_img = sct.grab(sct.monitors[1])
            img = Image.frombytes('RGBA', sct_img.size, bytes(sct_img.raw), 'raw', 'BGRA')
            img = img.convert('RGB')
            output = self.reports_folder + filename
            img.save(output)

    def capture_browser(self, browser, filename):
        reports_folder = SmallTools.get_reports_folder(self.scenario)
        browser.get_screenshot_as_file(reports_folder + filename)

@@ -10,16 +10,95 @@
  utf-8%0A%0A
+%22%22%22%0AModule screenshot: take a screenshot of the full scren or the browser%0A%22%22%22%0A%0A
 import m
@@ -232,62 +232,287 @@
     
-scenario = %22%22%0A%0A    def __init__(self, scenario, test):
+%22%22%22%0A    Class used to take screenshot of the full screen or the browser only%0A    %22%22%22%0A    scenario = %22%22%0A%0A    def __init__(self, scenario, test):%0A        %22%22%22%0A        Initializing the Screenshot class%0A        :param scenario: Scenario name%0A        :param test: Test name%0A        %22%22%22
 %0A   
@@ -747,16 +747,181 @@
 ix=''):%0A
+        %22%22%22%0A        Capture the current test%0A        :param browser: Selenium instance%0A        :param suffix: Suffix to put to filename%0A        :return:%0A        %22%22%22%0A
         
@@ -1248,32 +1248,164 @@
 elf, filename):%0A
+        %22%22%22%0A        Capture the current screen (full capture)%0A        :param filename: Filename to use%0A        :return:%0A        %22%22%22%0A
         with mss
@@ -1719,32 +1719,200 @@
 ser, filename):%0A
+        %22%22%22%0A        Capture the test inside the brpwser%0A        :param browser: Selenium instance%0A        :param filename: Filename to use%0A        :return:%0A        %22%22%22%0A
         reports_

Revert "Github page css"