def test_sample_script(eyes, driver):
    driver = eyes.open(
        driver, "Python app", "TestSampleScript", {"width": 600, "height": 400}
    )
    driver.get("https://www.google.com/")
    eyes.check_window(
        "Search page",
        target=(
            Target()
            .ignore(IgnoreRegionBySelector(By.CLASS_NAME, "fbar"))
            .send_dom()
            .use_dom()
            .floating(
                FloatingRegion(Region(10, 20, 30, 40), FloatingBounds(10, 0, 20, 10))
            )
        ),
    )

    hero = driver.find_element_by_id("body")
    eyes.check_region_by_element(
        hero,
        "Search",
        target=(Target().ignore(Region(20, 20, 50, 50), Region(40, 40, 10, 20))),
    )
    eyes.close()
Beispiel #2
0
    def select_eyes_ignore_region_by_selector(self,
                                              selector,
                                              value,
                                              includeEyesLog=False,
                                              httpDebugLog=False):
        """
        Selects the element, which should be ignored in the comparison. In the screenshot you can see a border around that element.
        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.                                                                               |                                                                                                                          |
                |  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                          |  yourTestingUrl   | gc             |                   |      |       |
        | Open Eyes Session                     | yourAppName       | yourTestName   | YourApplitoolsKey | 1024 |  768  |
        | Select Eyes Ignore Region By Selector |  ID               |  search-input  |                   |      |       |
        | Close Eyes Session                    |                   |                |                   |      |       |
        """

        check_logging(includeEyesLog, httpDebugLog)

        searchElement = get_search_element(selector)

        target = {}
        for i in value:
            target[i] = Target().ignore(
                IgnoreRegionBySelector(searchElement, value[i]))
        eyes.check_window(target=target)
def test_check_window_with_ignore_region_fluent(eyes, driver):
    eyes.open(driver, "Eyes Selenium SDK - Fluent API", "TestCheckWindowWithIgnoreRegion_Fluent",
              {'width': 800, 'height': 600})
    driver.get('http://applitools.github.io/demo/TestPages/FramesTestPage/')
    driver.find_element_by_tag_name('input').send_keys('My Input')
    eyes.check_window("Fluent - Window with Ignore region", target=Target().ignore(
        Region(left=50, top=50, width=100, height=100)))
    eyes.close()
def test_check_window_with_send_dom(eyes, driver):
    eyes.open(driver, "Eyes Selenium SDK - Fluent API", "TestCheckWindowWithSendDom",
              {'width': 800, 'height': 600})
    driver.get('http://applitools.github.io/demo/TestPages/FramesTestPage/')
    driver.find_element_by_tag_name('input').send_keys('My Input')
    eyes.check_window("Fluent - Window with Ignore region", target=Target().send_dom().use_dom())
    assert 'data-applitools-scroll' in driver.page_source
    assert 'data-applitools-original-overflow' in driver.page_source
    eyes.close()
def test_check_window_with_ignore_region_fluent(eyes, driver):
    eyes.force_full_page_screenshot = True
    eyes.open(driver, "Eyes Selenium SDK - Fluent API",
              "TestCheckWindowWithIgnoreRegion_Fluent", {
                  'width': 800,
                  'height': 600
              })
    driver.get('http://applitools.github.io/demo/TestPages/FramesTestPage/')
    eyes.check_window("Fluent - Window with Ignore region",
                      target=Target().ignore(
                          Region(left=50, top=50, width=100, height=100)))
    eyes.close()
    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)))
def test_sample_script(eyes, driver):
    eyes.force_full_page_screenshot = True
    eyes.stitch_mode = StitchMode.CSS

    driver = eyes.open(driver, "Python app", "applitools", {
        'width': 800,
        'height': 600
    })
    driver.get('http://www.applitools.com')
    eyes.check_window(
        "Home",
        target=(Target().ignore(
            IgnoreRegionBySelector(By.CLASS_NAME, 'hero-container')).floating(
                FloatingRegion(Region(10, 20, 30, 40),
                               FloatingBounds(10, 0, 20, 10)))))

    hero = driver.find_element_by_class_name("hero-container")
    eyes.check_region_by_element(hero,
                                 "Page Hero",
                                 target=(Target().ignore(
                                     Region(20, 20, 50, 50),
                                     Region(40, 40, 10, 20))))
    eyes.close()
Beispiel #8
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)))
Beispiel #9
0
    def select_eyes_floating_region_by_selector(self,
                                                selector,
                                                value,
                                                left,
                                                up,
                                                right,
                                                down,
                                                includeEyesLog=False,
                                                httpDebugLog=False):
        """
        Selects the element, which could be floating on the page. Then you have assign the floating area. In the screenshot you can see a border around that element and a second
        boarder which is the floating area.
        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.                                                                               |                                                                                                                          |
                |  up       (int)                   | These four variables are making the border around the element where the floating element can move.                                                                                       |
                |  down     (int)                   |                                                                                                                                                                       |
                |  Left     (int)                   |                                                                                                                                                                       |
                |  Right    (int)                   |                                                                                                                                                                       |
                |  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                              |  yourTestingUrl      | gc            |                   |       |       |    |
        | Open Eyes Session                         | yourAppName          | yourTestName  | YourApplitoolsKey |  1024 |  768  |    |
        | Select Eyes Floating Region By Selector   |  ID                  |  search-input |  20               | 10    | 20    | 10 |
        | Close Eyes Session                        |                      |               |                   |       |       |    |
        """

        check_logging(includeEyesLog, httpDebugLog)

        searchElement = get_search_element(selector)

        floating = Target().floating(
            FloatingRegionBySelector(searchElement, value,
                                     FloatingBounds(left, up, right, down)))
        eyes.check_window(target=floating)