diff --git a/RobotAppEyes/RobotAppEyes.py b/RobotAppEyes/RobotAppEyes.py index f339e44..468c728 100644 --- a/RobotAppEyes/RobotAppEyes.py +++ b/RobotAppEyes/RobotAppEyes.py @@ -27,17 +27,33 @@ from applitools.eyes import Eyes, BatchInfo from applitools.utils import _image_utils from applitools._webdriver import EyesScreenshot +from applitools.target import Target, IgnoreRegionBySelector, FloatingRegionBySelector, FloatingBounds from version import VERSION _version_ = VERSION +ROBOT_LIBRARY_VERSION = VERSION + + +def get_search_element(selector): + try: + return getattr(By, selector.upper()) + except AttributeError: + raise InvalidElementStateException('Please select a valid selector: CSS_SELECTOR, XPATH, ID, LINK_TEXT,' + 'PARTIAL_LINK_TEXT, NAME, TAG_NAME, CLASS_NAME') + + +def check_logging(includeEyesLog, httpDebugLog): + if includeEyesLog is True: + logger.set_logger(StdoutLogger()) + logger.open_() + if httpDebugLog is True: + httplib.HTTPConnection.debuglevel = 1 class RobotAppEyes: """ Robot-AppEyes is a visual verfication library for Robot Framework that leverages - the Eyes-Selenium and Selenium2 libraries. - - + the Eyes-Selenium. *Before running tests* @@ -46,30 +62,26 @@ class RobotAppEyes: Example: | Library | RobotAppEyes | - - In order to run the Robot-AppEyes library and return results, you have to create a free account https://applitools.com/sign-up/ with Applitools. You can retreive your API key from the applitools website and that will need to be passed in your Open Eyes Session keyword. - - *Using Selectors* Using the keyword Check Eyes Region By Element. The first four strategies are supported: _CSS SELECTOR_, _XPATH_, _ID_ and _CLASS NAME_. - Using the keyword Check Eyes Region By Selector. *All* the following strategies are supported: | *Strategy* | *Example* | *Description* | - | CSS SELECTOR | Check Eyes Region By Selector `|` CSS SELECTOR `|` .first.expanded.dropdown `|` CssElement | Matches by CSS Selector | + | CSS_SELECTOR | Check Eyes Region By Selector `|` CSS_SELECTOR `|` .first.expanded.dropdown `|` CssElement | Matches by CSS Selector | | XPATH | Check Eyes Region By Selector `|` XPATH `|` //div[@id='my_element'] `|` XpathElement | Matches with arbitrary XPath expression | | ID | Check Eyes Region By Selector `|` ID `|` my_element `|` IdElement | Matches by @id attribute | - | CLASS NAME | Check Eyes Region By Selector `|` CLASS NAME `|` element-search `|` ClassElement | Matches by @class attribute | - | LINK TEXT | Check Eyes Region By Selector `|` LINK TEXT `|` My Link `|` LinkTextElement | Matches anchor elements by their link text | - | PARTIAL LINK TEXT | Check Eyes Region By Selector `|` PARTIAL LINK TEXT `|` My Li `|` PartialLinkTextElement | Matches anchor elements by partial link text | + | CLASS_NAME | Check Eyes Region By Selector `|` CLASS_NAME `|` element-search `|` ClassElement | Matches by @class attribute | + | LINK_TEXT | Check Eyes Region By Selector `|` LINK_TEXT `|` My Link `|` LinkTextElement | Matches anchor elements by their link text | + | PARTIAL_LINK_TEXT | Check Eyes Region By Selector `|` PARTIAL_LINK_TEXT `|` My Li `|` PartialLinkTextElement | Matches anchor elements by partial link text | | NAME | Check Eyes Region By Selector `|` NAME `|` my_element `|` NameElement | Matches by @name attribute | - | TAG NAME | Check Eyes Region By Selector `|` TAG NAME `|` div `|` TagNameElement | Matches by HTML tag name | + | TAG_NAME | Check Eyes Region By Selector `|` TAG_NAME `|` div `|` TagNameElement | Matches by HTML tag name | """ + ROBOT_LIBRARY_SCOPE = 'GLOBAL' ROBOT_LIBRARY_VERSION = VERSION @@ -77,6 +89,8 @@ def open_eyes_session(self, appname, testname, apikey, + applitoolsurl='https://eyessdk.applitools.com', + library='Selenium2Library', width=None, height=None, osname=None, @@ -84,52 +98,53 @@ def open_eyes_session(self, 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. | - | (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. - + | 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 | 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 | | | | | | | | | | | - + | *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() + eyes = Eyes(applitoolsurl) eyes.api_key = apikey - s2l = BuiltIn().get_library_instance('Selenium2Library') + eyes.force_full_page_screenshot = fullPageScreenshot + s2l = BuiltIn().get_library_instance(library) webdriver = s2l._current_browser() driver = webdriver @@ -145,7 +160,7 @@ def open_eyes_session(self, if baselineName is not None: eyes.baseline_name = baselineName # (str) if batchName is not None: - batch =BatchInfo(batchName) + batch = BatchInfo(batchName) eyes.batch = batch if matchlevel is not None: eyes.match_level = matchlevel @@ -160,35 +175,23 @@ def open_eyes_session(self, intheight = int(height) eyes.open(driver, appname, testname, {'width': intwidth, 'height': intheight}) - - def check_eyes_window(self, name, force_full_page_screenshot=False, - includeEyesLog=False, httpDebugLog=False): + def check_eyes_window(self, name, 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 | | | | | | - + | *Keywords* | *Parameters* | | | | | + | Open Browser | yourTestingUrl | gc | | | | + | Open Eyes Session | yourAppName | yourTestName | 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 + check_logging(includeEyesLog, httpDebugLog) - eyes.force_full_page_screenshot = force_full_page_screenshot eyes.check_window(name) def check_eyes_region(self, element, width, height, name, includeEyesLog=False, httpDebugLog=False): @@ -196,7 +199,6 @@ def check_eyes_region(self, element, width, height, name, includeEyesLog=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 | @@ -205,18 +207,13 @@ def check_eyes_region(self, element, width, height, name, includeEyesLog=False, | 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 | | | | | | + | *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 | | | | | """ - if includeEyesLog is True: - logger.set_logger(StdoutLogger()) - logger.open_() - if httpDebugLog is True: - httplib.HTTPConnection.debuglevel = 1 + check_logging(includeEyesLog, httpDebugLog) intwidth = int(width) intheight = int(height) @@ -230,7 +227,6 @@ def check_eyes_region_by_element(self, selector, value, name, includeEyesLog=Fal """ 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 | @@ -238,21 +234,13 @@ def check_eyes_region_by_element(self, selector, value, name, includeEyesLog=Fal | 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 | | | | | | - + | *Keywords* | *Parameters* | | | | | + | Open Browser | yourTestingUrl | gc | | | | + | Open Eyes Session | yourAppName | yourTestName | 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 + check_logging(includeEyesLog, httpDebugLog) if selector.upper() == 'XPATH': searchElement = driver.find_element_by_xpath(value) @@ -270,7 +258,6 @@ def check_eyes_region_by_selector(self, selector, value, name, includeEyesLog=Fa """ 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 | @@ -278,60 +265,31 @@ def check_eyes_region_by_selector(self, selector, value, name, includeEyesLog=Fa | 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 | | | | | | - + | *Keywords* | *Parameters* | | | | | + | Open Browser | yourTestingUrl | gc | | | | + | Open Eyes Session | yourAppName | yourTestName | 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') + check_logging(includeEyesLog, httpDebugLog) + searchElement = get_search_element(selector) eyes.check_region_by_selector(searchElement, value, name) 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 | | | | | | | + | *Keywords* | *Parameters* | | | | | + | Open Browser | yourTestingUrl | gc | | | | + | Open Eyes Session | yourAppName | yourTestName | YourApplitoolsKey | 1024 | 768 | + | Compare Image | selenium-screenshot-1.png | Image Name Example | | | | + | Close Eyes Session | | | | | | """ if imagename is None: tag = os.path.basename(path) @@ -339,11 +297,7 @@ def compare_image(self, path, imagename=None, ignore_mismatch=False, includeEyes tag = imagename eyes._prepare_to_check() - if includeEyesLog is True: - logger.set_logger(StdoutLogger()) - logger.open_() - if httpDebugLog is True: - httplib.HTTPConnection.debuglevel = 1 + check_logging(includeEyesLog, httpDebugLog) with open(path, 'rb') as image_file: screenshot64 = image_file.read().encode('base64') @@ -361,41 +315,86 @@ 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 | | | | | | | - + | *Keywords* | *Parameters* | | | | | + | Open Browser | yourTestingUrl | gc | | | | + | Open Eyes Session | yourAppName | yourTestName | 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 + check_logging(includeEyesLog, httpDebugLog) eyes.close() eyes.abort_if_not_closed() - def eyes_session_is_open(self): """ Returns True if an Applitools Eyes session is currently running, otherwise it will return False. - - | *Keywords* | *Parameters* | - | Open Browser | http://www.navinet.net/ | gc | | | | | - | Open Eyes Session | http://www.navinet.net/ | RobotAppEyes_Test | NaviNet_RobotAppEyes_Test | YourApplitoolsKey | 1024 | 768 | - | ${isOpen}= | Eyes Session Is Open | | | | | | - | Run Keyword If | ${isOpen}==True | Close Eyes Session | | | | | + | *Keywords* | *Parameters* | | | | | + | Open Browser | yourTestingUrl | gc | | | | + | Open Eyes Session | yourAppName | yourTestName | YourApplitoolsKey | 1024 | 768 | + | ${isOpen}= | Eyes Session Is Open | | | | | + | Run Keyword If | ${isOpen}==True | Close Eyes Session | | | | """ return eyes.is_open() + + 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 = Target().ignore(IgnoreRegionBySelector(searchElement, value)) + eyes.check_window(target=target) + + 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) + diff --git a/Tests/acceptance/RobotAppEyesTest.txt b/Tests/acceptance/RobotAppEyesTest.txt index 2fe864c..55320e1 100644 --- a/Tests/acceptance/RobotAppEyesTest.txt +++ b/Tests/acceptance/RobotAppEyesTest.txt @@ -5,40 +5,35 @@ Library RobotAppEyes *** Variables *** ### Selenium2Library Variables ### ${Timeout} 15 -${LoginButton} xpath=//*[@id="block-block-7"]/div/ul/li[1]/a -${SupportButton} xpath=//*[@id="block-block-7"]/div/ul/li[2]/a +${LoginButton} xpath=//*[@class="leaf menu-item-icon menu-item-icon-lock"] +${SupportButton} xpath=//*[@class="last leaf menu-item-icon menu-item-icon-phone"] -${SolutionsTab} xpath=//*[@id="navbar"]/div/div/div[2]/nav/ul/li[1]/a -${NaviNetOpen} xpath=//*[@id="node-1"]/div[2]/div/div/p[2]/a[1] -${TransformTab} xpath=//*[@id="block-menu-block-1"]/div/div/ul/li/ul/li[1]/a +${SolutionsTab} xpath=//*[@class="expanded menu-item-solutions"]/a +${CompanyTab} xpath=//*[@class="expanded menu-item-company"]/a +${HomeTab} xpath=//*[@class="first leaf"]/a -${SearchBox} xpath=//*[@id="edit-combine"] +${SearchBox} xpath=//*[@id="hs-search-module"] ### Css Variables ### -${SolutionsCss} li.first.expanded.dropdown a -${SolutionsTag} NaviNet Solutions +${LogoCss} logo +${LogoTag} NaviNet Logo ### Partial Link Text Variables ### -${Contact} CT +${Contact} Contact ${ContactTag} NaviNet Contact -### Xpath Variables ### -${Navbar} //*[@id="navbar"]/div/div -${NavbarWidth} 500 -${NavbarHeight} 120 -${NavbarTag} NaviNet Navbar - - ### Applitools Variables ### ${Applitools-url} http://www.navinet.net/ ${Applitools-AppName} RobotAppEyes_Test ${Applitools-TestName} NaviNet_RobotAppEyes_Test -${Applitools-Key} YourApplitoolsKey -${Width} 1024 -${Height} 768 +${Applitools-Key} 1nQlY4wJU9qmHO34BCTAzxbm106wNgyDxWc3RCVF9KR6I110 +${Applitoolscloud-url} yourCloudUrl # (only needed if you have an account in the Applitools cloud) +${RobotLibrary} yourSeleniumLibrary # (Only needed if you don't use Selenium2Library) +${Width} 1200 +${Height} 617 ${OSOverride} OSOverride ${BrowserOverride} BrowserOverride @@ -50,50 +45,48 @@ ${True} True *** Test Cases *** RobotAppEyes 1.0 Test - Open Browser ${Applitools-url} gc - Open Eyes Session ${Applitools-AppName} ${Applitools-TestName}1.0 ${Applitools-Key} width=${Width} height=${Height} includeEyesLog=${True} - Check Eyes Region ${Navbar} ${NavbarWidth} ${NavbarHeight} ${NavbarTag} + Open Browser ${Applitools-url} gc + Open Eyes Session ${Applitools-AppName} ${Applitools-TestName}1.0 ${Applitools-Key} width=${Width} height=${Height} NaviNet Home Page Check Check Eyes Window NaviNet Home NaviNet Solutions Check Check Eyes Window NaviNet Solutions + Check Eyes Region By Selector PARTIAL_LINK_TEXT ${Contact} ${ContactTag} + Check Eyes Region By Element ID ${LogoCss} ${LogoTag} Check Transform Payer-Provider Collaboration Check Eyes Window Transform Payer-Provider Collaboration - Search for Open - Check Eyes Window Quick Search - Check Eyes Region By Element CSS SELECTOR ${SolutionsCss} ${SolutionsTag} - Check Eyes Region By Selector PARTIAL LINK TEXT ${Contact} ${ContactTag} + Select Eyes Ignore Region By Selector ID block-search-form + Select Eyes Floating Region By Selector ID ${LogoCss} 10 15 10 15 [Teardown] Session Teardown ##### Examples of how to check the region by an element ##### # Check Eyes Region By Element XPATH ${Navbar} NaviNetXpathElement - # Check Eyes Region By Element CSS SELECTOR ${SolutionsCss} NaviNetCssElement + # Check Eyes Region By Element CSS_SELECTOR ${SolutionsCss} NaviNetCssElement # Check Eyes Region By Element ID navbar NaviNetIdElement - # Check Eyes Region By Element CLASS NAME container NaviNetClassElement + # Check Eyes Region By Element CLASS_NAME container NaviNetClassElement ##### Examples of how to check the region by a selector ##### - # Check Eyes Region By Selector CSS SELECTOR .first.expanded.dropdown NaviNetCssElement + # Check Eyes Region By Selector CSS_SELECTOR .first.expanded.dropdown NaviNetCssElement # Check Eyes Region By Selector XPATH //*[@id="navbar"]/div/div/a/img NaviNetXpathElement # Check Eyes Region By Selector ID navbar NaviNetIdElement - # Check Eyes Region By Selector LINK TEXT RESOURCES NaviNetLinkTextElement - # Check Eyes Region By Selector PARTIAL LINK TEXT CT NaviNetPartialLinkTextElement - # Check Eyes Region By Selector TAG NAME a NaviNetTagElement - # Check Eyes Region By Selector CLASS NAME navbar-search NaviNetClassElement + # Check Eyes Region By Selector LINK_TEXT RESOURCES NaviNetLinkTextElement + # Check Eyes Region By Selector PARTIAL_LINK_TEXT CT NaviNetPartialLinkTextElement + # Check Eyes Region By Selector TAG_NAME a NaviNetTagElement + # Check Eyes Region By Selector CLASS_NAME navbar-search NaviNetClassElement ##### NOTE: The NaviNet website had no NAME selector so https://www.google.co.uk/ was used for this example ##### # Check Eyes Region By Selector NAME gbqf NaviNetNameElement RobotAppEyes 1.1 Test Open Browser ${Applitools-url} gc - Open Eyes Session ${Applitools-AppName} ${Applitools-TestName}1.1 ${Applitools-Key} width=${Width} height=${Height} osname=${OSOverride} browsername=${BrowserOverride} matchlevel=${MatchLevel} includeEyesLog=${True} - ${isOpen}= Eyes Session Is Open + Open Eyes Session ${Applitools-AppName} ${Applitools-TestName}1.1 ${Applitools-Key} ${Applitoolscloud-url} ${RobotLibrary} width=${Width} height=${Height} force_full_page_screenshot=True osname=${OSOverride} browsername=${BrowserOverride} matchlevel=${MatchLevel} includeEyesLog=${True} + ${isOpen}= Eyes Session Is Open Log ${isOpen} Compare Image pictureOne.png Test Image Name includeEyesLog=${True} httpDebugLog=${True} - Check Eyes Region ${Navbar} ${NavbarWidth} ${NavbarHeight} ${NavbarTag} + Check Eyes Region By Selector PARTIAL_LINK_TEXT ${Contact} ${ContactTag} NaviNet Home Page Check Check Eyes Window NaviNet Home - Check Eyes Window NaviNet Home force_full_page_screenshot=${True} [Teardown] Session Teardown *** Keywords *** @@ -104,17 +97,11 @@ NaviNet Home Page Check NaviNet Solutions Check Click Element ${SolutionsTab} - Wait Until Page Contains Element ${NaviNetOpen} ${Timeout} - Wait Until Page Contains Let Us Help You Navigate the Future ${Timeout} + Wait Until Page Contains Element ${CompanyTab} ${Timeout} Check Transform Payer-Provider Collaboration - Click Element ${TransformTab} - Wait Until Page Contains Develop a New Network Technology Strategy ${Timeout} - -Search for Open - Wait Until Page Contains Element ${SearchBox} ${Timeout} - Input Text ${SearchBox} Open + Click Element ${HomeTab} Session Teardown Run Keyword And Continue On Failure Close Eyes Session - Close Browser \ No newline at end of file + Close Browser