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 })
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 })
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})
#!/usr/bin/env python -tt # -*- coding: utf-8 -*- import ConfigParser from selenium import webdriver from applitools.eyes import Eyes, BatchInfo # This is your api key, make sure you use it in all your tests. Eyes.api_key = '3Z1sOfalzP1QClQrzmHJaU5BbKiR0AFZlDsBPoVB3Uk110' eyes = Eyes() batch = BatchInfo("BackYard batch test") eyes.batch = batch # Read configs from file configParser = ConfigParser.RawConfigParser() configFilePath = r'config.cfg' configParser.read(configFilePath) baseurl = configParser.get('common', 'baseurl') username = configParser.get('common', 'admin') password = configParser.get('common', 'password') accountNameSearch = configParser.get('common', 'accountNameSearch') # assign xPath variables for web-forms under test xpaths = {'usernameTxtBox': "//input[@name='username']", 'passwordTxtBox': "//input[@name='password']", 'submitButton': "/html/body/div/form/div/div[1]/button", 'DashBoard_bckWOWPMain': "/html/body/div[1]/div/div[2]/div/ul/li[5]/a", 'bckWOWP_accountsPage': "/html/body/div[3]/div[16]/div/div[1]/ul/li[1]/a", 'bckWOWP_accounts_searchType': "/html/body/div[3]/div[17]/div/div/div/form/div[1]/fieldset[1]/div/select/" + "option[4]", 'bckWOWP_accounts_searchValue': "/html/body/div[3]/div[17]/div/div/div/form/div[1]/fieldset[1]/div/input", 'bckWOWP_accounts_searchStart': "/html/body/div[3]/div[17]/div/div/div/form/div[2]/button",
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()
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)