def check_eyes_region(self, element, width, height, name, includeEyesLog=False, httpDebugLog=False):
        """
        Takes a snapshot of the given region from the browser using the web driver to locate an xpath element
        with a certain width and height and matches it with the expected output.
        The width and the height cannot be greater than the width and the height specified in the open_eyes_session keyword.

        Arguments:
                |  Element (string)                 | This needs to be passed in as an xpath e.g. //*[@id="navbar"]/div/div                          |
                |  Width (int)                      | The width of the region that is tested e.g. 500                                                |
                |  Height (int)                     | The height of the region that is tested e.g. 120                                               |
                |  Name (string)                    | Name that will be given to region in Eyes.                                                     |
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.       |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable. |
        Example:

        | *Keywords*         |  *Parameters*                                                                                                        |
        | Open Browser       |  http://www.navinet.net/     | gc                |                             |                    |        |       |
        | Open Eyes Session  |  http://www.navinet.net/     | RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test  |  YourApplitoolsKey |  1024  |  768  |
        | Check Eyes Region  |  //*[@id="navbar"]/div/div   | 500               |  120                        |  NaviNet Navbar    |        |       |
        | Close Eyes Session |  False                       |                   |                             |                    |        |       |
        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        intwidth = int(width)
        intheight = int(height)

        searchElement = driver.find_element_by_xpath(element)
        location = searchElement.location
        region = Region(location["x"], location["y"], intwidth, intheight)
        eyes.check_region(region, name)
Exemplo n.º 2
0
    def close_eyes_session(self, includeEyesLog=False, httpDebugLog=False):
        """
        Closes a session and returns the results of the session.
        If a test is running, aborts it. Otherwise, does nothing.

        The RobotAppEyesTest.txt test will fail after the first run, this is because a baseline is being created and will be accepted automatically by Applitools Eyes.
        A second test run will show a successful comparison between screens and the test will pass.

        Arguments:
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.        |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.  |

        Example:

        | *Keywords*                    |  *Parameters*                                                                                                         |
        | Open Browser                  |  http://www.navinet.net/  |  gc                    |                            |                    |        |       |
        | Open Eyes Session             |  http://www.navinet.net/  |  RobotAppEyes_Test     |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey |  1024  |  768  |
        | Check Eyes Region By Selector |  LINK TEXT                |  RESOURCES             |  NaviNetLinkTextElement    |                    |        |       |
        | Close Eyes Session            |                           |                        |                            |                    |        |       |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        eyes.close()
        eyes.abort_if_not_closed()
Exemplo n.º 3
0
    def check_eyes_window(self,
                          name,
                          force_full_page_screenshot=False,
                          includeEyesLog=False,
                          httpDebugLog=False):
        """
        Takes a snapshot from the browser using the web driver and matches it with
        the expected output.

        Arguments:
                |  Name (string)                                | Name that will be given to region in Eyes.                                                      |
                |  Force Full Page Screenshot (default=False)   | Will force the browser to take a screenshot of whole page.                                      |
                |  Include Eyes Log (default=False)             | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.        |
                |  HTTP Debug Log (default=False)               | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.  |

        Example:

        | *Keywords*         |  *Parameters*                                                                                                    |
        | Open Browser       |  http://www.navinet.net/ | gc                |                            |                     |        |       |
        | Open Eyes Session  |  http://www.navinet.net/ | RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey  |  1024  |  768  |
        | Check Eyes Window  |  NaviNet Home            | True              |                            |                     |        |       |
        | Close Eyes Session |  False                   |                   |                            |                     |        |       |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        eyes.force_full_page_screenshot = force_full_page_screenshot
        eyes.check_window(name)
Exemplo n.º 4
0
    def close_eyes_session(self, includeEyesLog=False, httpDebugLog=False):
        """
        Closes a session and returns the results of the session.
        If a test is running, aborts it. Otherwise, does nothing.

        The RobotAppEyesTest.txt test will fail after the first run, this is because a baseline is being created and will be accepted automatically by Applitools Eyes.
        A second test run will show a successful comparison between screens and the test will pass.

        Arguments:
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.        |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.  |

        Example:

        | *Keywords*                    |  *Parameters*                                                                                                         |
        | Open Browser                  |  http://www.navinet.net/  |  gc                    |                            |                    |        |       |
        | Open Eyes Session             |  http://www.navinet.net/  |  RobotAppEyes_Test     |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey |  1024  |  768  |
        | Check Eyes Region By Selector |  LINK TEXT                |  RESOURCES             |  NaviNetLinkTextElement    |                    |        |       |
        | Close Eyes Session            |                           |                        |                            |                    |        |       |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        eyes.close()
        eyes.abort_if_not_closed()
Exemplo n.º 5
0
    def check_eyes_window(self, name, force_full_page_screenshot=False,
                          includeEyesLog=False, httpDebugLog=False):
        """
        Takes a snapshot from the browser using the web driver and matches it with
        the expected output.

        Arguments:
                |  Name (string)                                | Name that will be given to region in Eyes.                                                      |
                |  Force Full Page Screenshot (default=False)   | Will force the browser to take a screenshot of whole page.                                      |
                |  Include Eyes Log (default=False)             | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.        |
                |  HTTP Debug Log (default=False)               | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.  |

        Example:

        | *Keywords*         |  *Parameters*                                                                                                    |
        | Open Browser       |  http://www.navinet.net/ | gc                |                            |                     |        |       |
        | Open Eyes Session  |  http://www.navinet.net/ | RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey  |  1024  |  768  |
        | Check Eyes Window  |  NaviNet Home            | True              |                            |                     |        |       |
        | Close Eyes Session |  False                   |                   |                            |                     |        |       |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        eyes.force_full_page_screenshot = force_full_page_screenshot
        eyes.check_window(name)
Exemplo n.º 6
0
    def check_eyes_region(self, element, width, height, name, includeEyesLog=False, httpDebugLog=False):
        """
        Takes a snapshot of the given region from the browser using the web driver to locate an xpath element
        with a certain width and height and matches it with the expected output.
        The width and the height cannot be greater than the width and the height specified in the open_eyes_session keyword.

        Arguments:
                |  Element (string)                 | This needs to be passed in as an xpath e.g. //*[@id="navbar"]/div/div                          |
                |  Width (int)                      | The width of the region that is tested e.g. 500                                                |
                |  Height (int)                     | The height of the region that is tested e.g. 120                                               |
                |  Name (string)                    | Name that will be given to region in Eyes.                                                     |
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.       |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable. |
        Example:

        | *Keywords*         |  *Parameters*                                                                                                        |
        | Open Browser       |  http://www.navinet.net/     | gc                |                             |                    |        |       |
        | Open Eyes Session  |  http://www.navinet.net/     | RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test  |  YourApplitoolsKey |  1024  |  768  |
        | Check Eyes Region  |  //*[@id="navbar"]/div/div   | 500               |  120                        |  NaviNet Navbar    |        |       |
        | Close Eyes Session |  False                       |                   |                             |                    |        |       |
        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        intwidth = int(width)
        intheight = int(height)

        searchElement = driver.find_element_by_xpath(element)
        location = searchElement.location
        region = Region(location["x"], location["y"], intwidth, intheight)
        eyes.check_region(region, name)
Exemplo n.º 7
0
    def check_eyes_region_by_selector(self,
                                      selector,
                                      value,
                                      name,
                                      includeEyesLog=False,
                                      httpDebugLog=False,
                                      force_full_page_screenshot=True):
        """
        Takes a snapshot of the region of the element found by calling find_element(by, value) from the browser using the web driver
        and matches it with the expected output. With a choice from eight selectors, listed below to check by.
        Arguments:
                |  Selector (string)                            | This will decide what element will be located. Supported selectors: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME.    |
                |  Value (string)                               | The specific value of the selector. e.g. a CSS SELECTOR value .first.expanded.dropdown                                                                    |
                |  Name (string)                                | Name that will be given to region in Eyes.                                                                                                                |
                |  Include Eyes Log (default=False)             | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                                                                  |
                |  Force Full Page Screenshot (default=True)    | Will force the browser to check the whole page for the value, rather than only search the viewable viewport.                                              |
        Example:
        | *Keywords*                    |  *Parameters*                                                                                                            |
        | Open Browser                  |  http://www.navinet.net/  |  gc                       |                            |                    |        |       |
        | Open Eyes Session             |  http://www.navinet.net/  |  RobotAppEyes_Test        |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey |  1024  |  768  |
        | Check Eyes Region By Selector |  CSS SELECTOR             |  .first.expanded.dropdown |  NaviNetCssElement         |                    |        |       |
        | Close Eyes Session            |  False                    |                           |                            |                    |        |       |
        
        NOTE: Breaks when attempting to find region to screenshot
        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            http.client.HTTPConnection.debuglevel = 1

        eyes.force_full_page_screenshot = force_full_page_screenshot

        searchElement = None

        searchByDict = {
            'CSS SELECTOR': By.CSS_SELECTOR,
            'XPATH': By.XPATH,
            'ID': By.ID,
            'LINK TEXT': By.LINK_TEXT,
            'PARTIAL LINK TEXT': By.PARTIAL_LINK_TEXT,
            'NAME': By.NAME,
            'TAG NAME': By.TAG_NAME,
            'CLASS NAME': By.CLASS_NAME
        }

        selector = selector.upper()

        if selector in searchByDict:
            searchElement = searchByDict[selector]
        else:
            raise InvalidElementStateException(
                'Please select a valid selector: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME'
            )

        eyes.check_region_by_selector(searchElement, value, name)
Exemplo n.º 8
0
    def check_eyes_region_by_selector(self,
                                      selector,
                                      value,
                                      name,
                                      includeEyesLog=False,
                                      httpDebugLog=False):
        """
        Takes a snapshot of the region of the element found by calling find_element(by, value) from the browser using the web driver
        and matches it with the expected output. With a choice from eight selectors, listed below to check by.

        Arguments:
                |  Selector (string)                | This will decide what element will be located. The supported selectors include: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME.    |
                |  Value (string)                   | The specific value of the selector. e.g. a CSS SELECTOR value .first.expanded.dropdown                                                                                |
                |  Name (string)                    | Name that will be given to region in Eyes.                                                                                                                            |
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                                                                              |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.                                                                        |
        Example:

        | *Keywords*                    |  *Parameters*                                                                                                            |
        | Open Browser                  |  http://www.navinet.net/  |  gc                       |                            |                    |        |       |
        | Open Eyes Session             |  http://www.navinet.net/  |  RobotAppEyes_Test        |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey |  1024  |  768  |
        | Check Eyes Region By Selector |  CSS SELECTOR             |  .first.expanded.dropdown |  NaviNetCssElement         |                    |        |       |
        | Close Eyes Session            |  False                    |                           |                            |                    |        |       |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        searchElement = None

        if selector.upper() == 'CSS SELECTOR':
            searchElement = By.CSS_SELECTOR
        elif selector.upper() == 'XPATH':
            searchElement = By.XPATH
        elif selector.upper() == 'ID':
            searchElement = By.ID
        elif selector.upper() == 'LINK TEXT':
            searchElement = By.LINK_TEXT
        elif selector.upper() == 'PARTIAL LINK TEXT':
            searchElement = By.PARTIAL_LINK_TEXT
        elif selector.upper() == 'NAME':
            searchElement = By.NAME
        elif selector.upper() == 'TAG NAME':
            searchElement = By.TAG_NAME
        elif selector.upper() == 'CLASS NAME':
            searchElement = By.CLASS_NAME
        else:
            raise InvalidElementStateException(
                'Please select a valid selector: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME'
            )

        eyes.check_region_by_selector(searchElement, value, name)
Exemplo n.º 9
0
    def compare_image(self,
                      path,
                      imagename=None,
                      target=None,
                      ignore_mismatch=False,
                      includeEyesLog=False,
                      httpDebugLog=False):
        """
        Select an image and send it to Eyes for comparison. A name can be used in place of the image's file name.
        Arguments:
                |  Path                             | Path of the image to send to eyes for visual comparison.                                                                   |
                |  imagename (default=None)         | Can manually set the name desired for the image passed in. If no name is passed in it will default file name of the image. |
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                                   |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.                             |
        Example:
        | *Keywords*         |  *Parameters*                                                                                                         |
        | Open Browser       |  http://www.navinet.net/   |  gc                   |                            |                    |        |       |
        | Open Eyes Session  |  http://www.navinet.net/   |  RobotAppEyes_Test    |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey |  1024  |  768  |
        | Compare Image      |  selenium-screenshot-1.png |  Image Name Example   |                            |                    |        |       |
        | Close Eyes Session |                            |                       |                            |                    |        |       |
        """
        if imagename is None:
            tag = os.path.basename(path)
        else:
            tag = imagename

        eyes._ensure_running_session()

        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            http.client.HTTPConnection.debuglevel = 1

        with open(path, 'rb') as image_file:
            screenshot64 = image_file.read().encode('base64')
            screenshot = image_utils.image_from_bytes(
                base64.b64decode(screenshot64))
            screenshotBytes = EyesWebDriverScreenshot.create_from_image(
                screenshot, eyes._driver)
        title = eyes._title
        app_output = {'title': title, 'screenshot64': None}
        user_inputs = []

        #TODO: Research this aspect
        if target is None:
            target = Target()

        prepare_match_data = eyes._match_window_task._create_match_data_bytes(
            app_output, user_inputs, tag, ignore_mismatch, screenshotBytes,
            eyes.default_match_settings, target)
        eyes._match_window_task._agent_connector.match_window(
            eyes._match_window_task._running_session, prepare_match_data)
    def check_eyes_window_with_ignore_region_by_selector(self, name, selector, selector_value, includeEyesLog=False, httpDebugLog=False):


        """
        Takes a snapshot from the browser using the web driver and matches it with
        the expected output.

        Arguments:
                |  Name (string)                                | Name that will be given to region in Eyes.                                                      |
                |  Include Eyes Log (default=False)             | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.        |
                |  HTTP Debug Log (default=False)               | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.  |

        Example:

        | *Keywords*         |  *Parameters*                                                                                                    |
        | Open Browser       |  http://www.navinet.net/ | gc                |                            |                     |        |       |
        | Open Eyes Session  |  http://www.navinet.net/ | RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey  |  1024  |  768  |
        | Check Eyes Window  |  NaviNet Home            | True              |                            |                     |        |       |
        | Close Eyes Session |  False                   |                   |                            |                     |        |       |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        eyes.check_window(name)
        searchElement = None

        if selector.upper() == 'CSS_SELECTOR':
            searchElement = By.CSS_SELECTOR
        elif selector.upper() == 'XPATH':
            searchElement = By.XPATH
        elif selector.upper() == 'ID':
            searchElement = By.ID
        elif selector.upper() == 'LINK TEXT':
            searchElement = By.LINK_TEXT
        elif selector.upper() == 'PARTIAL LINK TEXT':
            searchElement = By.PARTIAL_LINK_TEXT
        elif selector.upper() == 'NAME':
            searchElement = By.NAME
        elif selector.upper() == 'TAG NAME':
            searchElement = By.TAG_NAME
        elif selector.upper() == 'CLASS NAME':
            searchElement = By.CLASS_NAME
        else:
            raise InvalidElementStateException(
                'Please select a valid selector: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME')

        eyes.check_window(tag=name, target=Target().ignore(IgnoreRegionBySelector(searchElement, selector_value)))
Exemplo n.º 11
0
    def check_eyes_region_by_selector(self, selector, value, name, includeEyesLog=False, httpDebugLog=False):
        """
        Takes a snapshot of the region of the element found by calling find_element(by, value) from the browser using the web driver
        and matches it with the expected output. With a choice from eight selectors, listed below to check by.

        Arguments:
                |  Selector (string)                | This will decide what element will be located. The supported selectors include: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME.    |
                |  Value (string)                   | The specific value of the selector. e.g. a CSS SELECTOR value .first.expanded.dropdown                                                                                |
                |  Name (string)                    | Name that will be given to region in Eyes.                                                                                                                            |
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                                                                              |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.                                                                        |
        Example:

        | *Keywords*                    |  *Parameters*                                                                                                            |
        | Open Browser                  |  http://www.navinet.net/  |  gc                       |                            |                    |        |       |
        | Open Eyes Session             |  http://www.navinet.net/  |  RobotAppEyes_Test        |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey |  1024  |  768  |
        | Check Eyes Region By Selector |  CSS SELECTOR             |  .first.expanded.dropdown |  NaviNetCssElement         |                    |        |       |
        | Close Eyes Session            |  False                    |                           |                            |                    |        |       |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        searchElement = None

        if selector.upper() == 'CSS SELECTOR':
            searchElement = By.CSS_SELECTOR
        elif selector.upper() == 'XPATH':
            searchElement = By.XPATH
        elif selector.upper() == 'ID':
            searchElement = By.ID
        elif selector.upper() == 'LINK TEXT':
            searchElement = By.LINK_TEXT
        elif selector.upper() == 'PARTIAL LINK TEXT':
            searchElement = By.PARTIAL_LINK_TEXT
        elif selector.upper() == 'NAME':
            searchElement = By.NAME
        elif selector.upper() == 'TAG NAME':
            searchElement = By.TAG_NAME
        elif selector.upper() == 'CLASS NAME':
            searchElement = By.CLASS_NAME
        else:
            raise InvalidElementStateException('Please select a valid selector: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME')

        eyes.check_region_by_selector(searchElement, value, name)
Exemplo n.º 12
0
    def check_eyes_region_by_element(self,
                                     selector,
                                     value,
                                     name,
                                     includeEyesLog=False,
                                     httpDebugLog=False):
        """
        Takes a snapshot of the region of the given selector and element value from the browser using the web driver
        and matches it with the expected output. With a choice from four selectors, listed below, to check by.

        Arguments:
                |  Selector (string)                | This will decide what element will be located. The supported selectors include: XPATH, ID, CLASS NAME, CSS SELECTOR  |
                |  Value (string)                   | The specific value of the selector. e.g. an xpath value //*[@id="navbar"]/div/div                                    |
                |  Name (string)                    | Name that will be given to region in Eyes.                                                                           |
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                             |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.                       |
        Example:

        | *Keywords*                    |  *Parameters*                                                                                                    |
        | Open Browser                  |  http://www.navinet.net/  |  gc                |                             |                    |       |      |
        | Open Eyes Session             |  http://www.navinet.net/  |  RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test  |  YourApplitoolsKey |  1024 |  768 |
        | Check Eyes Region By Element  |  CLASS NAME               |  container         |  NaviNetClassElement        |                    |       |      |
        | Close Eyes Session            |  False                    |                    |                             |                    |       |      |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        searchElement = None

        if selector.upper() == 'XPATH':
            searchElement = driver.find_element_by_xpath(value)
        elif selector.upper() == 'ID':
            searchElement = driver.find_element_by_id(value)
        elif selector.upper() == 'CLASS NAME':
            searchElement = driver.find_element_by_class_name(value)
        elif selector.upper() == 'CSS SELECTOR':
            searchElement = driver.find_element_by_css_selector(value)
        else:
            raise InvalidElementStateException(
                'Please select a valid selector: XPATH, ID, CLASS NAME, CSS SELECTOR'
            )
        eyes.check_region_by_element(searchElement, name)
Exemplo n.º 13
0
    def open(self, driver, app_name, test_name, viewport_size=None):
        """
        Starts a test.

        Args:
            params (dictionary):
                app_name (str): The name of the application under test.
                test_name (str): The test name.
                (Optional) viewport_size ({width, height}): The client's viewport size (i.e.,
                                                            the visible part of the document's
                                                            body) or None to allow any viewport
                                                            size.
        Returns:
            An updated web driver
        Raises:
            EyesError
        """
        logger.open_()
        if self.is_disabled:
            logger.debug('open(): ignored (disabled)')
            return driver

        if self.api_key is None:
            raise EyesError("API key not set! Log in to https://applitools.com to obtain your"
                            " API Key and use 'api_key' to set it.")

        if isinstance(driver, RemoteWebDriver):
            self._driver = EyesWebDriver(driver, self)
        elif isinstance(driver, EyesWebDriver):
            # If the driver is an EyesWebDriver (as might be the case when tests are ran
            # consecutively using the same driver object)
            self._driver = driver
        else:
            raise EyesError("driver is not a RemoteWebDriver ({0})".format(driver.__class__))

        logger.info("open(%s, %s, %s, %s)" % (app_name, test_name, viewport_size, self.failure_reports))

        if self.is_open():
            self.abort_if_not_closed()
            raise EyesError('a test is already running')
        self._app_name = app_name
        self._test_name = test_name
        self._viewport_size = viewport_size
        self._is_open = True
        return self._driver
Exemplo n.º 14
0
    def check_eyes_window_ignore_region_by_selector(
            self,
            selector,
            value,
            name,
            force_full_page_screenshot=False,
            includeEyesLog=False,
            httpDebugLog=False):
        """This is a new addition to test the latest functionality of ignoring regions"""

        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        searchElement = None

        if selector.upper() == 'CSS SELECTOR':
            searchElement = By.CSS_SELECTOR
        elif selector.upper() == 'XPATH':
            searchElement = By.XPATH
        elif selector.upper() == 'ID':
            searchElement = By.ID
        elif selector.upper() == 'LINK TEXT':
            searchElement = By.LINK_TEXT
        elif selector.upper() == 'PARTIAL LINK TEXT':
            searchElement = By.PARTIAL_LINK_TEXT
        elif selector.upper() == 'NAME':
            searchElement = By.NAME
        elif selector.upper() == 'TAG NAME':
            searchElement = By.TAG_NAME
        elif selector.upper() == 'CLASS NAME':
            searchElement = By.CLASS_NAME
        else:
            raise InvalidElementStateException(
                'Please select a valid selector: CSS SELECTOR, XPATH, ID, LINK TEXT, PARTIAL LINK TEXT, NAME, TAG NAME, CLASS NAME'
            )

        eyes.force_full_page_screenshot = force_full_page_screenshot
        eyes.check_window(name,
                          target=Target().ignore(
                              IgnoreRegionBySelector(searchElement, value)))
Exemplo n.º 15
0
    def compare_image(self, path, imagename=None, ignore_mismatch=False, includeEyesLog=False, httpDebugLog=False):
        """
        Select an image and send it to Eyes for comparison. A name can be used in place of the image's file name.

        Arguments:
                |  Path                             | Path of the image to send to eyes for visual comparison.                                                                   |
                |  imagename (default=None)         | Can manually set the name desired for the image passed in. If no name is passed in it will default file name of the image. |
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                                   |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.                             |

        Example:

        | *Keywords*         |  *Parameters*                                                                                                         |
        | Open Browser       |  http://www.navinet.net/   |  gc                   |                            |                    |        |       |
        | Open Eyes Session  |  http://www.navinet.net/   |  RobotAppEyes_Test    |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey |  1024  |  768  |
        | Compare Image      |  selenium-screenshot-1.png |  Image Name Example   |                            |                    |        |       |
        | Close Eyes Session |                            |                       |                            |                    |        |       |
        """
        if imagename is None:
            tag = os.path.basename(path)
        else:
            tag = imagename

        eyes._prepare_to_check()
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        with open(path, 'rb') as image_file:
            screenshot64 = image_file.read().encode('base64')
            screenshot = _image_utils.png_image_from_bytes(base64.b64decode(screenshot64))
            screenshotBytes = EyesScreenshot.create_from_image(screenshot, eyes._driver)
        title = eyes.get_title()
        app_output = {'title': title, 'screenshot64': None}
        user_inputs = []
        prepare_match_data = eyes._match_window_task._create_match_data_bytes(
            app_output, user_inputs, tag, ignore_mismatch, screenshotBytes)
        eyes._match_window_task._agent_connector.match_window(
            eyes._match_window_task._running_session, prepare_match_data)
Exemplo n.º 16
0
    def open(self, driver, app_name, test_name, viewport_size=None):
        """
        Starts a test.

        :param driver: The webdriver to use.
        :param app_name: The name of the application under test.
        :param test_name: The test name.
        :param viewport_size: The client's viewport size (i.e., the visible part of the document's body) or None to
                                allow any viewport size.
        :return: An updated web driver
        :raise EyesError: If the session was already open.
        """
        logger.open_()
        if self.is_disabled:
            logger.debug('open(): ignored (disabled)')
            return driver

        if self.api_key is None:
            raise EyesError("API key not set! Log in to https://applitools.com to obtain your"
                            " API Key and use 'api_key' to set it.")

        if isinstance(driver, EyesWebDriver):
            # If the driver is an EyesWebDriver (as might be the case when tests are ran
            # consecutively using the same driver object)
            self._driver = driver
        else:
            if not isinstance(driver, RemoteWebDriver):
                logger.info("WARNING: driver is not a RemoteWebDriver (class: {0})".format(driver.__class__))
            self._driver = EyesWebDriver(driver, self, self._stitch_mode)

        logger.info("open(%s, %s, %s, %s)" % (app_name, test_name, viewport_size, self.failure_reports))

        if self.is_open():
            self.abort_if_not_closed()
            raise EyesError('a test is already running')
        self._app_name = app_name
        self._test_name = test_name
        self._viewport_size = viewport_size
        self._is_open = True
        return self._driver
Exemplo n.º 17
0
    def check_eyes_region_by_element(self, selector, value, name, includeEyesLog=False, httpDebugLog=False):
        """
        Takes a snapshot of the region of the given selector and element value from the browser using the web driver
        and matches it with the expected output. With a choice from four selectors, listed below, to check by.

        Arguments:
                |  Selector (string)                | This will decide what element will be located. The supported selectors include: XPATH, ID, CLASS NAME, CSS SELECTOR  |
                |  Value (string)                   | The specific value of the selector. e.g. an xpath value //*[@id="navbar"]/div/div                                    |
                |  Name (string)                    | Name that will be given to region in Eyes.                                                                           |
                |  Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                             |
                |  HTTP Debug Log (default=False)   | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.                       |
        Example:

        | *Keywords*                    |  *Parameters*                                                                                                    |
        | Open Browser                  |  http://www.navinet.net/  |  gc                |                             |                    |       |      |
        | Open Eyes Session             |  http://www.navinet.net/  |  RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test  |  YourApplitoolsKey |  1024 |  768 |
        | Check Eyes Region By Element  |  CLASS NAME               |  container         |  NaviNetClassElement        |                    |       |      |
        | Close Eyes Session            |  False                    |                    |                             |                    |       |      |

        """
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1

        searchElement = None

        if selector.upper() == 'XPATH':
            searchElement = driver.find_element_by_xpath(value)
        elif selector.upper() == 'ID':
            searchElement = driver.find_element_by_id(value)
        elif selector.upper() == 'CLASS NAME':
            searchElement = driver.find_element_by_class_name(value)
        elif selector.upper() == 'CSS SELECTOR':
            searchElement = driver.find_element_by_css_selector(value)
        else:
            raise InvalidElementStateException('Please select a valid selector: XPATH, ID, CLASS NAME, CSS SELECTOR')
        eyes.check_region_by_element(searchElement, name)
Exemplo n.º 18
0
    def open_eyes_session(self,
                          appname,
                          testname,
                          apikey,
                          width=None,
                          height=None,
                          osname=None,
                          browsername=None,
                          matchlevel=None,
                          includeEyesLog=False,
                          httpDebugLog=False,
                          baselineName=None,
                          batchName=None,
                          branchname=None,
                          parentbranch=None):
        """
        Starts a session with the Applitools Eyes Website.

        Arguments:
                |  Application Name (string)            | The name of the application under test.                                                                     |
                |  Test Name (string)                   | The test name.                                                                                              |
                |  API Key (string)                     | User's Applitools Eyes key.                                                                                 |
                |  (Optional) Width (int)               | The width of the browser window e.g. 1280                                                                   |
                |  (Optional) Height (int)              | The height of the browser window e.g. 1000                                                                  |
                |  (Optional) Operating System (string) | The operating system of the test, can be used to override the OS name to allow cross OS verfication         |
                |  (Optional) Browser Name (string)     | The browser name for the test, can be used to override the browser name to allow cross browser verfication  |
                |  (Optional) Match Level (string)      | The match level for the comparison - can be STRICT, LAYOUT or CONTENT                                       |
                |  Include Eyes Log (default=False)     | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                    |
                |  HTTP Debug Log (default=False)       | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.              |
                |  Branch Name (default=False)          | The branch to use to check test                                                                             |
                |  Parent Branch (default=False)        | Parent Branch to base the new Branch on                                                                     |

        Creates an instance of the Selenium2Library webdriver.
        Defines a global driver and sets the Selenium2Library webdriver to the global driver.

        Checks if there has been a width or height value passed in.
        If there no are values passed in, eyes calls the method open without the width and height values.
        Otherwise eyes calls open with the width and height values defined.

        The Height resolution should not be greater than 1000, this is currently Applitools maximum setting.

        Starts a session with the Applitools Eyes Website. See https://eyes.applitools.com/app/sessions/

        Example:

        | *Keywords*         |  *Parameters*                                                                                                                                                                                                                    |
        | Open Browser       |  http://www.navinet.net/ | gc                |                            |                     |        |       |                  |                       |                      |                       |                     |
        | Open Eyes Session  |  RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey  |  1024  |  768  |  OSOverrideName  |  BrowserOverrideName  |  matchlevel=LAYOUT   |  includeEyesLog=True  |  httpDebugLog=True  |
        | Check Eyes Window  |  NaviNet Home            |                   |                            |                     |        |       |                  |                       |                      |                       |                     |
        | Close Eyes Session |  False                   |                   |                            |                     |        |       |                  |                       |                      |                       |                     |

        """
        global driver
        global eyes
        eyes = Eyes()
        eyes.api_key = apikey
        s2l = BuiltIn().get_library_instance('Selenium2Library')
        webdriver = s2l._current_browser()
        driver = webdriver

        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1
        if osname is not None:
            eyes.host_os = osname  # (str)
        if browsername is not None:
            eyes.host_app = browsername  # (str)
        if baselineName is not None:
            eyes.baseline_name = baselineName  # (str)
        if batchName is not None:
            batch = BatchInfo(batchName)
            eyes.batch = batch
        if matchlevel is not None:
            eyes.match_level = matchlevel
        if parentbranch is not None:
            eyes.parent_branch_name = parentbranch  # (str)
        if branchname is not None:
            eyes.branch_name = branchname  # (str)
        if width is None and height is None:
            eyes.open(driver, appname, testname)
        else:
            intwidth = int(width)
            intheight = int(height)
            eyes.open(driver, appname, testname, {
                'width': intwidth,
                'height': intheight
            })
Exemplo n.º 19
0
    def open_eyes_session(self,
                          appname,
                          testname,
                          apikey,
                          matchlevel=None,
                          includeEyesLog=False,
                          httpDebugLog=False,
                          use_css_transition=False,
                          baselineName=None,
                          batch=None):
        """
        Starts a session with the Applitools Eyes Website.
        Arguments:
                |  Application Name (string)            | The name of the application under test.                                                                     |
                |  Test Name (string)                   | The test name.                                                                                              |
                |  API Key (string)                     | User's Applitools Eyes key.                                                                                 |
                |  (Optional) Match Level (string)      | The match level for the comparison - can be STRICT, LAYOUT or CONTENT                                       |
                |  Include Eyes Log (default=False)     | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                    |
                |  HTTP Debug Log (default=False)       | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.              |
                |  Use CSS Transition (default=False)           | Uses CSS Transition instead of actual scrolling for full page screenshots. To activate, pass 'True' in the variable. |
                |  (Optional) Baseline Name (string)    | The name of the baseline to compare test to. Should be used for cross browser verification                  |
                |  (Optional) Batch (BatchInfo)         | The batch to place the test into. Should be a BatchInfo object                                              |
        Defines a global driver, and eyes.

        Starts a session with the Applitools Eyes Website. See https://eyes.applitools.com/app/sessions/
        Example:
        | *Keywords*         |  *Parameters*                                                                                                                                                                                                                                 |
        | Open Browser       |  http://www.navinet.net/ | gc                         |                     |                 |                      |                       |                     |                           |                           |                  |
        | ${batch}           |  Create Eyes Batch       | Batch Name                 |                     |                 |                      |                       |                     |                           |                           |                  |
        | Open Eyes Session  |  RobotAppEyes_Test       |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey  |  matchlevel=LAYOUT   |  includeEyesLog=True  |  httpDebugLog=True  |  use_css_transition=True  |  baselineName='Baseline'  |  batch=${batch}  |
        | Check Eyes Window  |  NaviNet Home            |                            |                     |                 |                      |                       |                     |                           |                           |                  |
        | Close Eyes Session |  False                   |                            |                     |                 |                      |                       |                     |                           |                           |                  |
        """
        global driver
        global eyes

        eyes = Eyes()
        eyes.api_key = apikey

        driver = self.get_webdriver_instance()

        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            http.client.HTTPConnection.debuglevel = 1
        if baselineName is not None:
            eyes.baseline_branch_name = baselineName  # (str)
        if batch is not None:
            eyes.batch = batch
        if matchlevel is not None:
            eyes.match_level = matchlevel

        stitch_mode = StitchMode.Scroll

        if isinstance(use_css_transition, bool):
            if use_css_transition == True:
                stitch_mode = StitchMode.CSS
        elif use_css_transition.lower() == 'true':
            stitch_mode = StitchMode.CSS

        eyes.stitch_mode = stitch_mode

        eyes.open(driver, appname, testname)
Exemplo n.º 20
0
    def open_eyes_session(self, url, appname, testname, apikey, width=None,
                          height=None, osname=None, browsername=None,
                          matchlevel=None, includeEyesLog=False, httpDebugLog=False):
        """
        Starts a session with the Applitools Eyes Website.

        Arguments:
                |  URL (string)                         | The URL to start the test on                                                                                |
                |  Application Name (string)            | The name of the application under test.                                                                     |
                |  Test Name (string)                   | The test name.                                                                                              |
                |  API Key (string)                     | User's Applitools Eyes key.                                                                                 |
                |  (Optional) Width (int)               | The width of the browser window e.g. 1280                                                                   |
                |  (Optional) Height (int)              | The height of the browser window e.g. 1000                                                                  |
                |  (Optional) Operating System (string) | The operating system of the test, can be used to override the OS name to allow cross OS verfication         |
                |  (Optional) Browser Name (string)     | The browser name for the test, can be used to override the browser name to allow cross browser verfication  |
                |  (Optional) Match Level (string)      | The match level for the comparison - can be STRICT, LAYOUT or CONTENT                                       |
                |  Include Eyes Log (default=False)     | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                    |
                |  HTTP Debug Log (default=False)       | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.              |

        Creates an instance of the Selenium2Library webdriver.
        Defines a global driver and sets the Selenium2Library webdriver to the global driver.

        Checks if there has been a width or height value passed in.
        If there no are values passed in, eyes calls the method open without the width and height values.
        Otherwise eyes calls open with the width and height values defined.

        The Height resolution should not be greater than 1000, this is currently Applitools maximum setting.

        The driver then gets the url that will be tested.

        Starts a session with the Applitools Eyes Website. See https://eyes.applitools.com/app/sessions/

        Example:

        | *Keywords*         |  *Parameters*                                                                                                                                                                                                                    |
        | Open Browser       |  http://www.navinet.net/ | gc                |                            |                     |        |       |                  |                       |                      |                       |                     |
        | Open Eyes Session  |  http://www.navinet.net/ | RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey  |  1024  |  768  |  OSOverrideName  |  BrowserOverrideName  |  matchlevel=LAYOUT   |  includeEyesLog=True  |  httpDebugLog=True  |
        | Check Eyes Window  |  NaviNet Home            |                   |                            |                     |        |       |                  |                       |                      |                       |                     |
        | Close Eyes Session |  False                   |                   |                            |                     |        |       |                  |                       |                      |                       |                     |

        """

        global driver
        global eyes
        eyes = Eyes()
        eyes.api_key = apikey
        s2l = BuiltIn().get_library_instance('Selenium2Library')
        webdriver = s2l._current_browser()
        driver = webdriver
        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1
        if osname is not None:
            eyes.host_os = osname  # (str)
        if browsername is not None:
            eyes.host_app = browsername  # (str)
        if matchlevel is not None:
            eyes.match_level = matchlevel
        if width is None and height is None:
            eyes.open(driver, appname, testname)
        else:
            intwidth = int(width)
            intheight = int(height)
            eyes.open(driver, appname, testname, {'width': intwidth, 'height': intheight})
            driver.get(url)
    def open_eyes_session(self,
                          appname,
                          testname,
                          apikey,
                          width=None,
                          height=None,
                          osname=None,
                          browsername=None,
                          matchlevel=None,
                          includeEyesLog=False,
                          httpDebugLog=False,
                          baselineName=None,
                          batchName=None,
                          ApplitoolsJenkinsPlugin=False,
                          branchname=None,
                          parentbranch=None,
                          hideScrollBar=False,
                          fullPageScreenshot=False,
                          matchTimeout=None,
                          cssStitch=None):
        """
        Starts a session with the Applitools Eyes Website.

        Arguments:
                |  Application Name (string)                     | The name of the application under test.                                                                                                  |
                |  Test Name (string)                            | The test name.                                                                                                                           |
                |  API Key (string)                              | User's Applitools Eyes key.                                                                                                              |
                |  (Optional) Width (int)                        | The width of the browser window e.g. 1280                                                                                                |
                |  (Optional) Height (int)                       | The height of the browser window e.g. 1000                                                                                               |
                |  (Optional) Operating System (string)          | The operating system of the test, can be used to override the OS name to allow cross OS verfication                                      |
                |  (Optional) Browser Name (string)              | The browser name for the test, can be used to override the browser name to allow cross browser verfication                               |
                |  (Optional) Match Level (string)               | The match level for the comparison - can be STRICT, LAYOUT or CONTENT                                                                    |
                |  Include Eyes Log (default=False)              | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                                                 |
                |  HTTP Debug Log (default=False)                | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.                                           |
                |  (Optional) Branch Name (default=None)         | The branch to use to check test                                                                                                          |   For further information - http://support.applitools.com/customer/portal/articles/2142886
                |  (Optional)Parent Branch (default=None)        | Parent Branch to base the new Branch on                                                                                                  |   For further information - http://support.applitools.com/customer/portal/articles/2142886
                |  (Optional) fullPageScrennshot (default=False) | Will force the browser to take a screenshot of whole page.                                                                               |
                |  (Optional) matchTimeout                       | The amount of time that Eyes will wait for an image to stabilize to a point that it is similar to the baseline image                     |   For further information - http://support.applitools.com/customer/portal/articles/2099488
                |  (Optional) ApplitoolsJenkinsPlugin (Boolean)  | Integration with Applitools Jenkins Plugin                                                                                               |   For further information - http://support.applitools.com/customer/portal/articles/2689601
                |  (Optional) cssStitch (string)                 | Scrolling option either Scroll or CSS                                                                                                    |   For further information - http://support.applitools.com/customer/portal/articles/2249374


        Creates an instance of the Selenium2Library webdriver.
        Defines a global driver and sets the Selenium2Library webdriver to the global driver.

        Checks if there has been a width or height value passed in.
        If there no are values passed in, eyes calls the method open without the width and height values.
        Otherwise eyes calls open with the width and height values defined.

        The Height resolution should not be greater than 1000, this is currently Applitools maximum setting.

        Starts a session with the Applitools Eyes Website. See https://eyes.applitools.com/app/sessions/

        Example:

        | *Keywords*         |  *Parameters*                                                                                                                                                                                                                    |
        | Open Browser       |  http://www.navinet.net/ | gc                |                            |                     |        |       |                  |                       |                      |                       |                     |
        | Open Eyes Session  |  RobotAppEyes_Test |  NaviNet_RobotAppEyes_Test |  YourApplitoolsKey  |  1024  |  768  |  OSOverrideName  |  BrowserOverrideName  |  matchlevel=LAYOUT   |  includeEyesLog=True  |  httpDebugLog=True  |
        | Check Eyes Window  |  NaviNet Home            |                   |                            |                     |        |       |                  |                       |                      |                       |                     |
        | Close Eyes Session |  False                   |                   |                            |                     |        |       |                  |                       |                      |                       |                     |

        """
        global driver
        global eyes
        eyes = Eyes()
        eyes.api_key = apikey
        self._eyes_set_batch(batchName,ApplitoolsJenkinsPlugin)
        eyes.force_full_page_screenshot = fullPageScreenshot
        eyes.hide_scrollbars = hideScrollBar
        if baselineName is not None:
            eyes.baseline_name = baselineName  # (str)

        s2l = BuiltIn().get_library_instance('Selenium2Library')
        webdriver = s2l._current_browser()
        driver = webdriver

        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1
        if osname is not None:
            eyes.host_os = osname  # (str)
        if browsername is not None:
            eyes.host_app = browsername  # (str)
        if matchTimeout is not None:
            eyes._match_timeout= int(matchTimeout)
        if baselineName is not None:
            eyes.baseline_name = baselineName  # (str)
        if matchlevel is not None:
            eyes.match_level = matchlevel
        if parentbranch is not None:
            eyes.parent_branch_name = parentbranch  # (str)
        if branchname is not None:
            eyes.branch_name = branchname  # (str)
        if cssStitch is not None:
            if cssStitch == 'CSS':
                eyes.stitch_mode = StitchMode.CSS
            elif cssStitch == 'Scroll':
                eyes.stitch_mode = StitchMode.Scroll
        if width is None and height is None:
            eyes.open(driver, appname, testname)
        else:
            intwidth = int(width)
            intheight = int(height)
            eyes.open(driver, appname, testname, {'width': intwidth, 'height': intheight})
Exemplo n.º 22
0
    def open_eyes_session(self,
                          appname,
                          testname,
                          apikey,
                          applitoolsurl='https://eyessdk.applitools.com',
                          library='Selenium2Library',
                          width=None,
                          height=None,
                          osname=None,
                          browsername=None,
                          matchlevel=None,
                          includeEyesLog=False,
                          httpDebugLog=False,
                          fullPageScreenshot=False,
                          baselineName=None,
                          batchName=None,
                          branchname=None,
                          parentbranch=None):
        """
        Starts a session with the Applitools Eyes Website.
        Arguments:
                |  Application Name (string)                    | The name of the application under test.                                                                     |
                |  Test Name (string)                           | The test name.                                                                                              |
                |  API Key (string)                             | User's Applitools Eyes key.
                |  library  (optional)                          | Standard:Selenium2Library. If you use another one, assign the right library.
                |  applitoolsurl (optional)                     | Standard:eyes.applitools.com. If you run in a cloud version, assign the right applitoolsurl.
                |  (Optional) Width (int)                       | The width of the browser window e.g. 1280                                                                   |
                |  (Optional) Height (int)                      | The height of the browser window e.g. 1000                                                                  |
                |  (Optional) Operating System (string)         | The operating system of the test, can be used to override the OS name to allow cross OS verfication         |
                |  (Optional) Browser Name (string)             | The browser name for the test, can be used to override the browser name to allow cross browser verfication  |
                |  (Optional) Match Level (string)              | The match level for the comparison - can be STRICT, LAYOUT or CONTENT                                       |
                |  Force Full Page Screenshot (default=False)   | Will force the browser to take a screenshot of whole page.                                      |
                |  Include Eyes Log (default=False)             | The Eyes logs will not be included by default. To activate, pass 'True' in the variable.                    |
                |  HTTP Debug Log (default=False)               | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable.              |
                |  baselineName (default=None)                  | New tests will be automatically saved as baseline.
                |  batchName (default=None)                     | Tests with the same batchname will be unified as one group in the Test Manager screen.
                |  Branch Name (default=False)                  | The branch to use to check test                                                                             |
                |  Parent Branch (default=False)                | Parent Branch to base the new Branch on
                |  Force full page screenshot (default=false)   | The whole page will be in the screen shot

        Creates an instance of the library webdriver.
        Defines a global driver and sets the library webdriver to the global driver.
        Checks if there has been a width or height value passed in.
        If there no are values passed in, eyes calls the method open without the width and height values.
        Otherwise eyes calls open with the width and height values defined.
        The Height resolution should not be greater than 1000, this is currently Applitools maximum setting.
        Starts a session with the Applitools Eyes Website. See https://eyes.applitools.com/app/sessions/
        Example:
        | *Keywords*         |  *Parameters*        |               |                  |                       |           |        |        |                  |                      |                     |                     |                       |
        | Open Browser       |  yourTestingUrl      |  gc           |                  |                       |           |        |        |                  |                      |                     |                     |                       |
        | Open Eyes Session  | yourAppName          |  yourTestName | YourApplitoolsKey|  cloudapplitoolsurl   | library   |  1024  |  768   |  OSOverrideName  |  BrowserOverrideName |  matchlevel=LAYOUT  | includeEyesLog=True |  httpDebugLog=True    |
        | Check Eyes Window  |  NaviNet Home        |               |                  |                       |           |        |        |                  |                      |                     |                     |                       |
        | Close Eyes Session |  False               |               |                  |                       |           |        |        |                  |                      |                     |                     |                       |
        """
        global driver
        global eyes
        eyes = Eyes(applitoolsurl)
        eyes.api_key = apikey
        eyes.force_full_page_screenshot = fullPageScreenshot in [
            True, 'True', 'true', '1', 1
        ]
        s2l = BuiltIn().get_library_instance(library)
        webdriver = s2l._current_browser()
        driver = webdriver

        if includeEyesLog is True:
            logger.set_logger(StdoutLogger())
            logger.open_()
        if httpDebugLog is True:
            httplib.HTTPConnection.debuglevel = 1
        if osname is not None:
            eyes.host_os = osname  # (str)
        if browsername is not None:
            eyes.host_app = browsername  # (str)
        if baselineName is not None:
            eyes.baseline_name = baselineName  # (str)
        if batchName is not None:
            batch = BatchInfo(batchName)
            eyes.batch = batch
        if matchlevel is not None:
            eyes.match_level = matchlevel
        if parentbranch is not None:
            eyes.parent_branch_name = parentbranch  # (str)
        if branchname is not None:
            eyes.branch_name = branchname  # (str)
        if width is None and height is None:
            eyes.open(driver, appname, testname)
        else:
            intwidth = int(width)
            intheight = int(height)
            eyes.open(driver, appname, testname, {
                'width': intwidth,
                'height': intheight
            })
Exemplo n.º 23
0
def check_logging(includeEyesLog, httpDebugLog):
    if includeEyesLog is True:
        logger.set_logger(StdoutLogger())
        logger.open_()
    if httpDebugLog is True:
        httplib.HTTPConnection.debuglevel = 1