コード例 #1
0
def userLogin():
    # Set options so that Chrome starts fullscreen
    logger.set_logger(StdoutLogger())
    options = webdriver.ChromeOptions()
    options.add_argument("--start-maximized")

    eyes = Eyes()
    eyes.api_key = "VOfLF4XBAbbMmsOLf0BxDx4APw7gCynQz7NjZwRG1076g110"
    eyes.force_full_page_screenshot = True

    # Get a selenium web driver object.
    # driver = webdriver.Chrome(chrome_options=options)
    driver = webdriver.Firefox()
    # driver = webdriver.Chrome()
    # Make sure to use the returned driver from this point on.
    # Use the following line for a specific viewport_size (WSVGA 16:9)
    eyes.open(
        driver=driver, app_name="Home Reach", test_name="Login to Dash", viewport_size={"width": 1136, "height": 640}
    )
    # No viewport size set - using fullscreen
    # driver = eyes.open(driver=driver, app_name='Home Reach', test_name='Login to Dash')
    # Work-around for eyes SDK issue
    # eyes.open(driver=driver, app_name='Home Reach', test_name='Login to Dash')

    try:
        driver.get("https://homereach.aminocom.com")

        # Visual validation point #1
        eyes.check_window("Login Page")

        driver.find_element_by_id("username").clear()
        driver.find_element_by_id("username").send_keys("rayres-prodlive1")
        driver.find_element_by_id("username").send_keys(u"\ue004")
        driver.find_element_by_id("userpassword").clear()
        driver.find_element_by_id("userpassword").send_keys("planet07")
        driver.find_element_by_id("cmdLogin").click()

        for i in range(10):
            try:
                if driver.find_element_by_id("flashImg1"):
                    # Visual validation point #2
                    # eyes.check_window('Dashboard')
                    driver.find_element_by_link_text("Logout").click()
                    print "Logging out"
                    break
            except Exception as e:
                print "Wait.."
                time.sleep(1)
        else:
            return "Element not found"

        # End visual testing. Validate visual correctness.
        eyes.close()

    except Exception as e:
        print e

    finally:
        driver.quit()
        eyes.abort_if_not_closed()
コード例 #2
0
ファイル: RobotAppEyes.py プロジェクト: kpn/Robot-AppEyes
    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
            })
コード例 #3
0
from applitools.logger import StdoutLogger
from applitools.eyes import Eyes
from applitools.common import StitchMode

import os
#os.environ['HTTPS_PROXY'] = "http://localhost:8888"

driver = webdriver.Chrome()

eyes = Eyes()
eyes.api_key = os.environ['APPLITOOLS_API_KEY']

logger.set_logger(StdoutLogger())

# Force Eyes to grab a full page screenshot.
eyes.force_full_page_screenshot = True
eyes.stitch_mode = StitchMode.CSS

try:
    driver = eyes.open(driver, "Python app", "applitools", {
        'width': 800,
        'height': 600
    })
    driver.get('http://www.applitools.com')
    eyes.check_window("Home")

    automated_paragraph = driver.find_element_by_class_name("automated")
    eyes.check_region_by_element(automated_paragraph,
                                 "Automated Testing Paragraph")

    eyes.close()
コード例 #4
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,
                          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})
コード例 #5
0
def main():

    customer="winterfest"
    url_file_name="book_url_to_be_checked.xlsx"
    protocol ="https://"

    # Initialize the eyes SDK and set your private API key.
    eyes = Eyes()
    eyes.api_key = <<<<<API key here>>>>>>
    mybatch = BatchInfo(customer)

    # Testing whole web page
    eyes.force_full_page_screenshot = True
    eyes.hide_scrollbars = True
    eyes.use_css_transition = True

    eyes.batch = mybatch

    print('Opening workbook...')
    wb = openpyxl.load_workbook(url_file_name)
    sheet = wb[customer]

    domain_live = sheet['A' + str(2)].value.split('//', 1)[1].split('/', 1)[0]
    domain_staging = sheet['B' + str(2)].value.split('//', 1)[1].split('/', 1)[0]
    username_staging = sheet['C' + str(2)].value
    password_staging = sheet['D' + str(2)].value

    print("Base data for the client:", customer, "\nLiveURL: ", domain_live, "\nStagingURL: "+ domain_staging,
          "\nStaging_username: "******"info" with two elements add into the list "url_list":

        if (sheet['F' + str(row)].value==None) or (sheet['E' + str(row)].value==None):
            print("Skiped empty row: ", row)
        else:
            info = {}
            info['menu_title'] = sheet['E' + str(row)].value
            #removing the domain from url
            info['menu_path'] = ''.join(sheet['F' + str(row)].value.split('//', 1)[1].split('/', 1)[1:])
            url_list.append(info)

    driver = webdriver.Chrome()

    for item in url_list:
        #domain_live

        print("Test Live: ", item['menu_title'], protocol+domain_live+"/"+item['menu_path'])

        driver.get(protocol+domain_live+"/"+item['menu_path'])

        eyes.open(driver=driver, app_name=customer, test_name=item['menu_title'], viewport_size={'width': 800, 'height': 600})
        try:
            eyes.check_window(item['menu_title'])
        finally:
            eyes.close()

        print("Test Staging: ", item['menu_title'], protocol + domain_staging + "/"+item['menu_path'])
        driver.get(protocol + domain_staging + "/" + item['menu_path'])

        eyes.open(driver=driver, app_name=customer, test_name=item['menu_title'], viewport_size={'width': 800, 'height': 600})
        try:
            eyes.check_window(item['menu_title'])
        finally:
            eyes.close()
コード例 #6
0
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from applitools import logger
from applitools.logger import StdoutLogger, FileLogger
from applitools.eyes import Eyes

import os
# os.environ['HTTPS_PROXY'] = "http://localhost:8888"

driver = webdriver.Chrome()

logger.set_logger(StdoutLogger())
eyes = Eyes("https://localhost.applitools.com")
eyes.api_key = os.environ['APPLITOOLS_API_KEY']
eyes.force_full_page_screenshot = True
eyes.save_new_tests = False

try:
    ## First test
    driver = eyes.open(driver, "Python app", "Python binary", {'width': 800, 'height': 600})

    driver.get('http://www.applitools.com')
    eyes.check_window("initial")

    pricing_element = driver.find_element_by_css_selector("li.pricing a")
    eyes.check_region_by_element(pricing_element, "pricing button")

    driver.find_element_by_css_selector("li.contact-us a").click()
    eyes.check_window("contact us page")

    ## Second test