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()
Ejemplo n.º 2
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       |  yourTestingUrl              | gc            |                   |                   |       |
        | Open Eyes Session  | yourAppName                  | yourTestName  | YourApplitoolsKey |  1024             |  768  |
        | Check Eyes Region  |  //*[@id="navbar"]/div/div   | 500           |  120              |  NaviNet Navbar   |       |
        | Close Eyes Session |  False                       |               |                   |                   |       |
        """
        check_logging(includeEyesLog, httpDebugLog)

        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)
Ejemplo n.º 3
0
    def ignore_region_by_coordinates(self, left, top, width, height, target=None):
        """
        Returns a Target object that ignores the region specified in the arguments.
        See `Defining Ignore and Floating Regions`.

            | =Arguments=     | =Description=                                                                                    |
            | Left (float)    | *Mandatory* - The left coordinate of the region to ignore e.g. 100                               |
            | Top (float)     | *Mandatory* - The top coordinate of the region to ignore e.g. 150                                |
            | Width (float)   | *Mandatory* - The width of the region to ignore e.g. 500                                         |
            | Height (float)  | *Mandatory* - The height of the region to ignore e.g. 120                                        |
            | Target (Target) | The previously existent Target, to be used if a ignore region or floating region was already set |
                
        *Example:*
            | ${target}=        | Ignore Region By Coordinates | 10               | 20 | 100 | 100 |
            | Check Eyes Window | Google Homepage              | target=${target} |

        """

        if target is None:
            target = Target()

        ignore_region = Region(float(left), float(top), float(width), float(height))
        target.ignore(ignore_region)

        return 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_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 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()
def test_quickstart_example(eyes, driver):
    required_viewport = {'width': 450, 'height': 300}
    eyes.set_viewport_size(driver, required_viewport)
    eyes.open(driver=driver, app_name='TestQuickstartExample', test_name='My first Selenium Python test!',
              viewport_size={'width': 800, 'height': 600})
    driver.get('https://applitools.com/helloworld')

    eyes.check_window('Hello!')

    driver.find_element_by_css_selector('button').click()
    eyes.check_window('Click!')

    eyes.check_region(Region(20, 20, 50, 50), "step")

    eyes.close()
Ejemplo n.º 8
0
    def floating_region_by_coordinates(
        self,
        left,
        top,
        width,
        height,
        max_left_offset=0,
        max_top_offset=0,
        max_right_offset=0,
        max_down_offset=0,
        target=None,
    ):
        """
        Returns a Target object that includes the floating region specified in the arguments.
        See `Defining Ignore and Floating Regions`

            | =Arguments=            | =Description=                                                                                    |
            | Left (float)           | *Mandatory* - The left coordinate of the floating region e.g. 100                                |
            | Top (float)            | *Mandatory* - The top coordinate of the floating region e.g. 150                                 |
            | Width (float)          | *Mandatory* - The width of the floating region e.g. 500                                          |
            | Height (float)         | *Mandatory* - The height of the floating region e.g. 120                                         |
            | Max Left Offset (int)  | The amount the floating region may move to the left. e.g. 10                                     |
            | Max Top Offset (int)   | The amount the floating region may moveupwards. e.g. 20                                          |
            | Max Right Offset (int) | The amount the floating region may move to the right. e.g. 10                                    |
            | Max Down Offset (int)  | The amount the floating region may move downwards. e.g. 50                                       |
            | Target (Target)        | The previously existent Target, to be used if a ignore region or floating region was already set |
                
        *Example:*
            | ${target}=    Floating Region By Coordinates |  10              | 10               | 200 | 150 | 10 | 0 | 50 | 50 | 
            | Check Eyes Window                            |  Google Homepage | target=${target} |
        """

        if target is None:
            target = Target()

        region = Region(float(left), float(top), float(width), float(height))
        floating_bounds = FloatingBounds(
            int(max_left_offset),
            int(max_top_offset),
            int(max_right_offset),
            int(max_down_offset),
        )
        floating_region = FloatingRegion(region, floating_bounds)
        target.floating(floating_region)

        return target
Ejemplo n.º 9
0
    def check_eyes_region(self,
                          element,
                          width,
                          height,
                          name,
                          includeEyesLog=False,
                          httpDebugLog=False,
                          force_full_page_screenshot=True):
        """
        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.                |
                |  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  |  //*[@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:
            http.client.HTTPConnection.debuglevel = 1

        eyes.force_full_page_screenshot = force_full_page_screenshot

        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)
Ejemplo n.º 10
0
 def test_check_region_with_ignore_region_fluent(self):
     self.eyes.check("Fluent - Region with Ignore region",
                     Target.region(By.ID, "overflowing-div")).ignore(
                         Region(left=50, top=50, width=100, height=100))
Ejemplo n.º 11
0
 def test_check_window_with_ignore_region_fluent(self):
     self.eyes.check("Fluent - Window with Ignore region",
                     Target.window()).fully().timeout(5000).ignore(
                         Region(left=50, top=50, width=100, height=100))