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()
class EightDays: def __init__(self, testname): self.eyes = Eyes() self.eyes.api_key = 'IlUcgRAO105BlmoORdtUxbK8CUKg3KRSa8q4f3iACoY1I110' desired_caps = { "platformName": 'Android', "platformVersion": '8.0.0', "deviceName": "Android Emulator", "automationName": "UiAutomator2", # "nativeWebScreenshot": "True", "app": 'C:/Users/Tea/Desktop/BCA/8Days/Automated/mobile.apk' } # need to start appium or this won't happen self.wd = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps) # 127.0.0.1 is your localhost and 4723 is the port # http://localhost:4723/wd/hub self.wd.implicitly_wait(10) # wait for the page to load self.eyes.open(driver=self.wd, app_name='8days', test_name=testname) # The string passed to checkWindow() is typically a descriptive name that identifies the checkpoint. def select_language(self): self.wd.find_element_by_id("kr.co.the8days.dev:id/radioEnglish").click() self.wd.find_element_by_id("kr.co.the8days.dev:id/btnNext").click() sleep(2) self.wd.hide_keyboard() def find_login_fields(self): self.userField = self.wd.find_element_by_id("kr.co.the8days.dev:id/edtSignInEmail") self.pwField = self.wd.find_element_by_id("kr.co.the8days.dev:id/edtSignInPassword") self.login_btn = self.wd.find_element_by_id("kr.co.the8days.dev:id/btnSignIn") def basic_login(self): self.find_login_fields() self.userField.send_keys("*****@*****.**") self.pwField.click() self.delete_field(self.pwField) self.pwField.send_keys("golden1") self.login_btn.click() '''general functions''' def delete_field(self, field): actions = TouchAction(self.wd) actions.long_press(field).release().perform() self.wd.press_keycode(67) def screenshot(self, name): self.eyes.check_window(name) def click_by_id(self, id): self.wd.find_element_by_id(id).click()
class Driver(object): def __init__(self, mode, path): self.eyes = Eyes() self.eyes.api_key = 'mHHQDYWEGS5AGbjfNoVO1h4oi15w3jiQ4q9DPagYJBA110' if mode == 'local': self.driver = webdriver.Chrome(path) elif mode == 'docker-chrome': self.driver = webdriver.Remote( command_executor='http://127.0.0.1:32768/wd/hub', desired_capabilities={'browserName': 'chrome'}, ) def open(self): self.eyes.open(driver=self.driver, app_name='Creative_Factory', test_name='Auto Regression Test') #viewport_size={'width': 800,'height': 600}) def check_window(self, text): self.eyes.check_window(text) def get_url(self, url): try: self.driver.get(url) except BaseException as e: print(e) def add_cookie(self, cookies): self.driver.add_cookie(cookie_dict=cookies) def find_by_class(self, classname): try: return self.driver.find_element_by_class_name(classname) except BaseException as e: print(e) def set_size(self): self.driver.set_window_size(800, 600) def click_elem(self, elem): try: elem.click() except BaseException as e: print(e) def close(self): self.driver.close() def eye_close(self): self.eyes.close()
class Test(unittest.TestCase): eyes = 0 driver = 0 def setUp(self): self.eyes = Eyes() self.eyes.api_key = APPLITOOLS_APIKEY self.driver = webdriver.Firefox() def tearDown(self): self.eyes.abort_if_not_closed() self.driver.quit() def test(self): # Start visual testing with browser viewport set to 1024x768. # Make sure to use the returned driver from this point on. self.driver = self.eyes.open(driver=self.driver, app_name='Applitools website', test_name='Example test', viewport_size={'width': 900, 'height': 600}) self.driver.get('http://www.applitools.com') # Visual validation point #1 self.eyes.check_window('Main Page') self.driver.find_element_by_css_selector('.read_more').click() # Visual validation point #2 self.eyes.check_window('Features Page') # End visual testing. Validate visual correctness. self.eyes.close()
class Test(unittest.TestCase): eyes = 0 driver = 0 def setUp(self): self.eyes = Eyes() self.eyes.api_key = APPLITOOLS_APIKEY self.driver = webdriver.Firefox() def tearDown(self): self.eyes.abort_if_not_closed() self.driver.quit() def test(self): # Start visual testing with browser viewport set to 1024x768. # Make sure to use the returned driver from this point on. self.driver = self.eyes.open(driver=self.driver, app_name='Applitools website', test_name='Example test', viewport_size={ 'width': 900, 'height': 600 }) self.driver.get('http://www.applitools.com') # Visual validation point #1 self.eyes.check_window('Main Page') self.driver.find_element_by_css_selector('.read_more').click() # Visual validation point #2 self.eyes.check_window('Features Page') # End visual testing. Validate visual correctness. self.eyes.close()
def test_server_connector(driver): eyes = Eyes('https://localhost.applitools.com') driver = eyes.open(driver, "Python SDK", "TestDelete", {'width': 800, 'height': 599}) driver.get("https://applitools.com/helloworld") eyes.check("Hello", Target.window()) results = eyes.close() results.delete() eyes.abort_if_not_closed()
def test_non_logged_in_users(): eyes = Eyes() eyes.api_key = 'u51qaFo104ruwwox0ewoWiFZQpijro9Z47fYTk1iQTozU110' driver = webdriver.Firefox() driver.maximize_window() try: eyes.open(driver=driver, app_name='Applitools', test_name='TpT Non Logged In Pages') driver.get('http://www.teacherspayteachers.com') eyes.check_window('Homepage') driver.get("https://www.teacherspayteachers.com/Product/Multi-Purpose-Graphic-Organizers-Bundle-576136") eyes.check_window("Product Page") driver.find_element_by_xpath(".//*[@id='content_layout']/div[1]/div[3]/div[5]/div/div[2]/div/a").click() eyes.check_window("Store Page") eyes.close() finally: driver.quit() eyes.abort_if_not_closed()
class SimpleCalculatorTests(unittest.TestCase): def setUp(self): desired_caps = {} desired_caps["app"] = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App" self.driver = webdriver.Remote( command_executor='http://127.0.0.1:4723', desired_capabilities=desired_caps) self.eyes = Eyes() self.eyes.api_key = "your_applitools_key" self.driver.set_window_size( 700, 700) #set size for responsive design testing... def tearDown(self): self.driver.quit() self.eyes.abort_if_not_closed() def test_initialize(self): self.eyes.open(driver=self.driver, app_name='Windows Calculator', test_name='Python Windows Calculator Test') self.driver.find_element_by_name("Clear").click() self.driver.find_element_by_name("Seven").click() self.eyes.check_window("Displays 7") self.eyes.close() def test_addition(self): self.eyes.open(driver=self.driver, app_name='Windows Calculator', test_name='Python Windows Calculator Test') self.driver.find_element_by_name("Clear").click() self.driver.find_element_by_name("One").click() self.driver.find_element_by_name("Plus").click() self.driver.find_element_by_name("Seven").click() self.driver.find_element_by_name("Equals").click() self.eyes.check_window("Displays 8") self.eyes.close()
class Unitest(unittest.TestCase): eyes = 0 driver = 0 def setUp(self): self.eyes = Eyes("https://localhost.applitools.com") self.eyes.api_key = os.environ['APPLITOOLS_API_KEY'] sauce_url = "http://%s:%[email protected]:80/wd/hub" caps = webdriver.DesiredCapabilities.CHROME caps['screen-resolution'] = "1280x1024" caps['platform'] = "Windows 8" sauce_user = os.environ['SAUCELABS_USER'] sauce_key = os.environ['SAUCELABS_KEY'] self.driver = webdriver.Remote(desired_capabilities=caps, command_executor=sauce_url % (sauce_user, sauce_key)) def tearDown(self): self.eyes.abort_if_not_closed() self.driver.quit() def test(self): # Start visual testing with browser viewport set to 1024x768. # Make sure to use the returned driver from this point on. self.driver = self.eyes.open(driver=self.driver, app_name='Saucelabs', test_name='Saucelabs test', viewport_size={ 'width': 1100, 'height': 600 }) self.driver.get('https://saucelabs.com') # Visual validation point self.eyes.check_window('Main Page') menu_items = ['Features', 'Pricing', 'Enterprise', 'Docs'] for item in menu_items: self.driver.find_element_by_xpath("//a[contains(.,'" + item + "')]").click() # Visual validation point self.eyes.check_window(item) # End visual testing. Validate visual correctness. self.eyes.close()
class Unitest(unittest.TestCase): eyes = 0 driver = 0 def setUp(self): self.eyes = Eyes("https://localhost.applitools.com") self.eyes.api_key = os.environ['APPLITOOLS_API_KEY'] sauce_url = "http://%s:%[email protected]:80/wd/hub" caps = webdriver.DesiredCapabilities.CHROME caps['screen-resolution'] = "1280x1024" caps['platform'] = "Windows 8" sauce_user = os.environ['SAUCELABS_USER'] sauce_key = os.environ['SAUCELABS_KEY'] self.driver = webdriver.Remote( desired_capabilities=caps, command_executor=sauce_url % (sauce_user, sauce_key)) def tearDown(self): self.eyes.abort_if_not_closed() self.driver.quit() def test(self): # Start visual testing with browser viewport set to 1024x768. # Make sure to use the returned driver from this point on. self.driver = self.eyes.open( driver=self.driver, app_name='Saucelabs', test_name='Saucelabs test', viewport_size={'width': 1100, 'height': 600}) self.driver.get('https://saucelabs.com') # Visual validation point self.eyes.check_window('Main Page') menu_items = ['Features', 'Pricing', 'Enterprise', 'Docs'] for item in menu_items: self.driver.find_element_by_xpath("//a[contains(.,'" + item + "')]").click() # Visual validation point self.eyes.check_window(item) # End visual testing. Validate visual correctness. self.eyes.close()
from applitools.eyes import Eyes eyes = Eyes() # This is your api key, make sure you use it in all your tests. eyes.api_key = APPLITOOLS_APIKEY # Get a selenium web driver object. driver = webdriver.Firefox() try: # Start visual testing with browser viewport set to 1024x768. # Make sure to use the returned driver from this point on. driver = eyes.open(driver=driver, app_name='Applitools website', test_name='Example test', viewport_size={ 'width': 900, 'height': 600 }) driver.get('http://www.applitools.com') # Visual validation point #1 eyes.check_window('Main Page') driver.find_element_by_css_selector('.read_more').click() # Visual validation point #2 eyes.check_window('Features Page') # End visual testing. Validate visual correctness. eyes.close()
from applitools.eyes import Eyes from selenium.webdriver.common.action_chains import ActionChains import time def hover_over_hamburger(driver): hamburger = driver.find_element_by_xpath("//div[@class='menu-bars-outer']/a/i") ActionChains(driver).move_to_element(hamburger).perform() eyes = Eyes() eyes.api_key = 'u51qaFo104ruwwox0ewoWiFZQpijro9Z47fYTk1iQTozU110' driver = webdriver.Firefox() driver.maximize_window() try: eyes.open(driver=driver, app_name='itailor', test_name='itailors') #homepage_new_arrivals driver.get('http://tailor.managedcoder.com/') eyes.check_window("homepage_new_arrivals") #homepage_hot_products driver.find_element_by_xpath("//div[@class='entry-content clearfix']/div[2]/div/div/div/div/div/ul/li[1]/a").click() eyes.check_window("homepage_hot_products") #homepage_best_Sellers driver.find_element_by_xpath("//div[@class='entry-content clearfix']/div[2]/div/div/div/div/div/ul/li[3]/a").click() eyes.check_window("homepage_best_Sellers") #suits/design tools driver.find_element_by_xpath("//div[@class='container']/nav/ul/li[2]/a")
'bckWOWP_gold_comment': "/html/body/div[3]/div[17]/div/form/fieldset/div[7]/div/div/textarea", 'bckWOWP_gold_submit': "/html/body/div[3]/div[17]/div/form/div/input" } # Get a selenium web driver object. driver = webdriver.Firefox() try: # Array of resolutions to test. Example : viewSizeArray = [[width, height],[...]...] # viewSizeArray = [[1920, 1080], [1600, 1200], [1280, 1024], [1024, 768], [800, 600]] viewSizeArray = [[1024, 768]] for viewSize in viewSizeArray: viewSizeForAppliTools = {'width': viewSize[0], 'height': viewSize[1]} driver = eyes.open(driver=driver, app_name='Applitools', test_name='Basic Backyard test: resolution - ' + str(viewSize[0]) + 'x' + str(viewSize[1]), viewport_size=viewSizeForAppliTools) driver.get(baseurl) eyes.check_window('Login page') # driver.maximize_window() # Clear Username, Password TextBoxs if already allowed "Remember Me". Fill with new values. Sign in driver.find_element_by_xpath(xpaths['usernameTxtBox']).clear() driver.find_element_by_xpath(xpaths['usernameTxtBox']).send_keys(username) driver.find_element_by_xpath(xpaths['passwordTxtBox']).clear() driver.find_element_by_xpath(xpaths['passwordTxtBox']).send_keys(password) driver.find_element_by_xpath(xpaths['submitButton']).click() eyes.check_window('Dashboard main') # Go to WOWP backyard driver.find_element_by_xpath(xpaths['DashBoard_bckWOWPMain']).click() eyes.check_window('Dashboard WOWP')
from applitools import logger from applitools.eyes import Eyes import os # Appium session configuration. from applitools.logger import StdoutLogger desired_capabilities = {'platformName': 'Android', 'platformVersion': '4.2', 'deviceName': 'Samsung Galaxy S5', 'app': os.environ['ANDROID_NOTES_LIST_APP'], 'app-package': 'com.example.android.notepad', 'app-activity': '.NotesList', 'newCommandTimeout': 300} # Assuming Appium is running on localhost. driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities) driver.orientation = 'LANDSCAPE' logger.set_logger(StdoutLogger()) eyes = Eyes("https://localhost.applitools.com") eyes.api_key = os.environ['APPLITOOLS_API_KEY'] eyes.baseline_name = "NotesList 1080x1794" try: eyes.open(driver, 'Appium', 'Notes list') eyes.check_window('Opening screen') eyes.close() finally: driver.quit() eyes.abort_if_not_closed()
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})
class EventScheduler_FrontEndTest: def setup(self, test_registration=False): self.eyes = Eyes() self.eyes.api_key = 'IlUcgRAO105BlmoORdtUxbK8CUKg3KRSa8q4f3iACoY1I110' self.driver = webdriver.Chrome(r"C:\Users\Tea\Desktop\chromedriver_win32 (1)\chromedriver.exe") self.eyes.open(driver=self.driver, app_name='Hello World!', test_name='eventScheduler') self.driver.get('http://*****:*****@mymail.sutd.edu.sg' def test_redirection(self): self.driver.find_element_by_xpath("//a[text()='Home']").click() self.eyes.check_window('Redirected to login') # show dropdown menu self.driver.find_element_by_xpath("//a[contains(text(),'Forms')]").click() self.eyes.check_window('Dropdown menu') self.driver.find_element_by_xpath("//a[contains(text(),'Schedule R')]").click() self.eyes.check_window('Redirected to login') assert(self.driver.current_url == "http://*****:*****@name="username"]') username.send_keys(self.ran_name) email = self.driver.find_element_by_xpath('//input[@name="email"]').click() self.eyes.check_window('Focused textbox') self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email) pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]') pw1.send_keys(self.LEGAL_PASSWORD) pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]') pw2.send_keys(self.LEGAL_PASSWORD) pw2.send_keys(Keys.RETURN) self.eyes.check_window("Submitted") # re-registering with the same username def test_registration_repeatUser(self): self.driver.find_element_by_xpath("//a[text()='Register']").click() username = self.driver.find_element_by_xpath('//input[@name="username"]') username.send_keys(self.ran_name) email = self.driver.find_element_by_xpath('//input[@name="email"]').click() self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email) pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]') pw1.send_keys(self.LEGAL_PASSWORD) pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]') pw2.send_keys(self.LEGAL_PASSWORD) pw2.send_keys(Keys.RETURN) assert('A user with that username already exists.' in self.driver.page_source) self.eyes.check_window("same user error message") # weak passwords def test_registration_fail(self): self.driver.find_element_by_xpath("//a[text()='Register']").click() # test weakpasswords username = self.driver.find_element_by_xpath('//input[@name="username"]') username.send_keys(self.RANDOM_NAME) email = self.driver.find_element_by_xpath('//input[@name="email"]').click() self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email) pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]') pw1.send_keys(self.WEAK_PASSWORD) pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]') pw2.send_keys(self.WEAK_PASSWORD) pw2.send_keys(Keys.RETURN) self.driver.find_element_by_xpath("//a[text()='Register']").click() username = self.driver.find_element_by_xpath('//input[@name="username"]') username.send_keys(self.RANDOM_NAME) email = self.driver.find_element_by_xpath('//input[@name="email"]').click() self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email) pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]') pw1.send_keys("fakestrongpassword091") pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]') pw2.send_keys('fakestrongpassword091') pw2.send_keys(Keys.RETURN) self.driver.find_element_by_xpath("//a[text()='Register']").click() username = self.driver.find_element_by_xpath('//input[@name="username"]') username.send_keys(self.RANDOM_NAME) email = self.driver.find_element_by_xpath('//input[@name="email"]').click() self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email) pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]') pw1.send_keys("fakestrongpassword091!") pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]') pw2.send_keys('fakestrongpassword091!') pw2.send_keys(Keys.RETURN) self.driver.find_element_by_xpath("//a[text()='Register']").click() username = self.driver.find_element_by_xpath('//input[@name="username"]') username.send_keys(self.RANDOM_NAME) email = self.driver.find_element_by_xpath('//input[@name="email"]').click() self.driver.find_element_by_xpath('//input[@name="email"]').send_keys(self.Email) pw1 = self.driver.find_element_by_xpath('//input[@name="password1"]') pw1.send_keys("100091") pw2 = self.driver.find_element_by_xpath('//input[@name="password2"]') pw2.send_keys('100091') pw2.send_keys(Keys.RETURN) def test_login_wrong_username(self): self.driver.find_element_by_xpath('//a[text()="Login"]').click() self.driver.find_element_by_xpath('//input[@name="username"]').send_keys("WRONG NAME") self.driver.find_element_by_xpath('//input[@name = "password"]').send_keys(self.LEGAL_PASSWORD) self.driver.find_element_by_xpath('//button[text()="Login"]').click() self.eyes.check_window("error") assert("Please enter a correct username and password. Note that both fields may be case-sensitive." in self.driver.page_source) def test_login_wrong_pw(self): self.driver.find_element_by_xpath('//a[text()="Login"]').click() self.driver.find_element_by_xpath('//input[@name="username"]').send_keys(self.ran_name) self.driver.find_element_by_xpath('//input[@name = "password"]').send_keys("self.LEGAL_PASSWORD") self.driver.find_element_by_xpath('//button[text()="Login"]').click() assert("Please enter a correct username and password. Note that both fields may be case-sensitive." in self.driver.page_source) def test_login_pass(self): self.driver.find_element_by_xpath('//a[text()="Login"]').click() self.driver.find_element_by_xpath('//input[@name="username"]').send_keys(self.ran_name) self.driver.find_element_by_xpath('//input[@name = "password"]').send_keys(self.LEGAL_PASSWORD) self.driver.find_element_by_xpath('//button[text()="Login"]').click() self.eyes.check_window("Login-ed") # right = self.driver.find_element_by_xpath('//button[@class="fc-next-button fc-button fc-state-default fc-corner-right"]') # right.click() # self.eyes.check_window("today button lit up") # left=self.driver.find_element_by_xpath(' //button[@class="fc-prev-button fc-button fc-state-default fc-corner-left"]') # left.click() # self.eyes.check_window("today not lit") # self.driver.find_element_by_xpath(' //button[@class="fc-prev-button fc-button fc-state-default fc-corner-left"]').click() def test_collapse(self): self.driver.set_window_size(300, 800) self.driver.set_window_position(0, 0) self.eyes.check_window("check collapse") self.driver.set_window_size(1536, 673) self.driver.set_window_position(0, 0) def test_dropdown(self): # show dropdown menu self.driver.find_element_by_xpath("//a[contains(text(),'Forms')]").click() self.eyes.check_window('Dropdown menu') def test_links(self): self.driver.find_element_by_xpath("//a[contains(text(),'Schedule R')]").click() assert(self.driver.current_url == "http://localhost:8000/requestform/") self.driver.find_element_by_xpath("//a[contains(text(),'Forms')]").click() self.eyes.check_window('Dropdown menu') self.driver.find_element_by_xpath("//a[contains(text(),'Input M')]").click() assert(self.driver.current_url == "http://localhost:8000/requestform/input-module-info") self.driver.find_element_by_xpath("//a[contains(text(),'Forms')]").click() self.eyes.check_window('Dropdown menu') self.driver.find_element_by_xpath("//a[contains(text(),'In-vivo')]").click() assert(self.driver.current_url == "http://localhost:8000/requestform/add-event") self.driver.find_element_by_xpath("//a[contains(text(),'View R')]").click() assert(self.driver.current_url == "http://localhost:8000/requestform/view-requests") def logout(self): self.driver.find_element_by_xpath('//a[text()="Logout"]').click() self.eyes.check_window("logged out") def end(self): self.eyes.close() self.driver.quit() # If the test was aborted before self.eyes.close was called, ends the test as aborted. self.eyes.abort_if_not_closed()
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from applitools import logger from applitools.logger import StdoutLogger import time delay1 = 5 delay2 = 15 delay3 = 30 delay4 = 35 eyes = Eyes() eyes.api_key = 'VOfLF4XBAbbMmsOLf0BxDx4APw7gCynQz7NjZwRG1076g110' logger.set_logger(StdoutLogger()) driver = webdriver.Firefox() driver.implicitly_wait(delay2) driver = eyes.open(driver=driver, app_name='Home Reach', test_name='Dashboard Navigation v2', viewport_size={'width': 1366, 'height': 768}) target = "https://homereach.aminocom.com" def dashNav(): try: driver.get(target) 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() element = WebDriverWait(driver, delay3).until(EC.invisibility_of_element_located((By.ID, "divFlashVersion"))) element = WebDriverWait(driver, 0).until(EC.presence_of_element_located((By.ID, "flashImg1")))
from applitools.eyes import Eyes from applitools.logger import StdoutLogger # os.environ['HTTPS_PROXY'] = "http://localhost:8888" driver = webdriver.Chrome() logger.set_logger(StdoutLogger()) eyes = Eyes() eyes.api_key = os.environ['APPLITOOLS_API_KEY'] eyes.force_full_page_screenshot = True eyes.hide_scrollbars = True try: ## First test driver = eyes.open(driver, "Python app", "Github Website", {'width': 800, 'height': 600}) driver.get('http://www.github.com') eyes.check_window("initial") results = eyes.close(False) print(results) ## Second test driver = eyes.open(driver, "Python app", "Applitools Website", {'width': 900, 'height': 600}) driver.get('http://www.applitools.com') eyes.check_window("initial") results = eyes.close(False) print(results) finally: driver.quit() eyes.abort_if_not_closed()
def test_non_logged_in_users(): eyes = Eyes() eyes.api_key = 'u51qaFo104ruwwox0ewoWiFZQpijro9Z47fYTk1iQTozU110' driver = webdriver.Firefox() driver.maximize_window() try: eyes.open(driver=driver, app_name='Applitools', test_name='TpT Non Logged In Pages') # Check HomePage driver.get('http://www.teacherspayteachers.com') eyes.check_window('Homepage') # Check Empty Cart Page driver.find_element_by_xpath("//div[@class='drop_down my_cart']/a").click() eyes.check_window("Empty Cart Page") driver.find_element_by_xpath("//a[@class='common_button green small continue_shopping_button']").click() # Check Product Page driver.get("https://www.teacherspayteachers.com/Product/Informational-Text-Structures-Task-Cards-1057257") eyes.check_window("Product Page") # Check cart page with products driver.find_element_by_xpath("//div[@class='prod_price_box_wrap']/div[1]/div[2]/div[1]/a").click() eyes.check_window("Cart Page") driver.find_element_by_xpath("//div[@class='checkout_flow_pages cart_page']/div[1]/div[1]/div[1]/a").click() # Check Store Page driver.find_element_by_xpath("//div[@class='r_side']/div[3]/div[1]/div[1]/a").click() eyes.check_window("Store Page") # Check Ratings & Comment Tab on store page driver.find_element_by_xpath("//a[@id='ui-id-2']").click() time.sleep(2) eyes.check_window("Store Page >> Ratings & Comment Tab") # Check Gift Cards Page driver.find_element_by_xpath("//div[@class='header_user_menu']/a[3]").click() eyes.check_window("Gift Card Page") # Check Login Page driver.find_element_by_class_name("js-login").click() eyes.check_window("Login Page") # Check Signup Page driver.find_element_by_xpath("//div[@class='btns']/a[2]").click() eyes.check_window("Signup Page") # Check publisher signup page driver.find_element_by_xpath("//div[@class='seller_publisher_block']/a").click() eyes.check_window("Publisher Signup Page") # Terms of Service driver.find_element_by_xpath("//div[@class='centered']/a[2]").click() eyes.check_window("Terms of service") # Privacy Policy driver.find_element_by_xpath("//div[@class='centered']/a[3]").click() eyes.check_window("Privacy policy") # Press driver.find_element_by_xpath("//div[@class='block left']/a[4]").click() eyes.check_window("Press") # Blog driver.find_element_by_xpath("//div[@class='block left']/a[5]").click() eyes.check_window("Blog") driver.back() # How to sell items driver.find_element_by_xpath("//div[@class='block left']/a[6]").click() eyes.check_window("How to sell items") # Copyright and trademark policies driver.find_element_by_xpath("//div[@class='centered']/a[4]").click() eyes.check_window("Copyright and trademark policies") # About us driver.find_element_by_xpath("//div[@class='centered']/a[5]").click() eyes.check_window("About us") # Contact us driver.find_element_by_xpath("//div[@class='centered']/a[6]").click() eyes.check_window("Contact us") # Careers driver.find_element_by_xpath("//div[@class='centered']/a[7]").click() eyes.check_window("Careers") #FAQ's and Helps driver.find_element_by_xpath("//div[@class='centered']/a[8]").click() eyes.check_window("FAQ's and Helps") driver.back() # Schools driver.find_element_by_xpath("//div[@class='header_user_menu']/a[2]").click() eyes.check_window("Schools") eyes.close() finally: driver.quit() eyes.abort_if_not_closed()
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() finally: driver.quit() eyes.abort_if_not_closed()
class TestAdminPages(BaseTest): def __init__(self, *args, **kwargs): super(TestAdminPages, self).__init__(*args, **kwargs) self.__data = DataGenerateUtils() self.__login = LoginPage() self.__create_bot = CreateBotPage() self.__register = RegisterPage() self.__dashboard = DashboardPage() self.__appearance = AppearancePage() self.__create_bot_validation = CreateBotValidation() self.__drop_down_list = DropDownList() self.__change_password = ChangePasswordPage() self.__knowledge = KnowledgePage() self.__data_set = DataUtils() self.__faq_knowledge_data_table_component = FaqKnowledgeDataTableComponent( ) self.valid_email = self.__data.create_email() self.valid_username = self.__data.create_name() self.valid_password = self.__data.create_password() self.bot_name = "Test" self.invalid_faq = "google.com" self.eyes = Eyes() self.eyes.api_key = YAML_CONFIG.get("eyes_api_key") self.eyes.force_full_page_screenshot = True self.eyes.stitch_mode = StitchMode.CSS def setUp(self): super().setUp() self.sign_in_for_ui_test( email=YAML_CONFIG.get("visual_test_user"), password=YAML_CONFIG.get("visual_test_password"), # Use is_debugging flag to login instead of register new account is_debugging=True) def test_for_bot_knowledge_appearance(self): try: self.eyes.open(driver=self.__login.driver.core_driver, app_name='sample_app', test_name='Bot Knowledge Page', viewport_size={ 'width': 1440, 'height': 887 }) self.__knowledge.open_knowledge_page() self.__knowledge.wait_for_create_page() # self.eyes.check_window("Default state of Knowledge Page") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div", "Default state") self.__knowledge.btn_add_knowledge.click() self.eyes.check_region_by_selector( by=By.CSS_SELECTOR, value="#add-knowledge-dropdown > div", tag="Add knowledge dropdown") self.__knowledge.btn_from_faq_url.click() # self.eyes.check_window("Knowledge page when adding faq url") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div", "Adding FAQ URL") self.__knowledge.init_manual_question_pair_table() # self.eyes.check_window("Knowledge page when init manual faq table") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div", "Initiated manual FAQ") manual_section = FaqKnowledgeDataTableComponent.get_table_component_with_group_faqs( "Manual Q&A") manual_section.collapse_section() self.eyes.check_region_by_element( manual_section.base_component_element( SeleniumElement).get_wrapper_element, "Manual section after collapsing") web_content_section = FaqKnowledgeDataTableComponent.get_table_component_with_group_faqs( "Web Content") web_content_section.open_section() # TODO(namndoan): capture full element self.eyes.check_region_by_element( web_content_section.base_component_element( SeleniumElement).get_wrapper_element, "Web content section after open") web_content_section.collapse_section() # self.eyes.check_window("Knowledge page after closing Web Content section") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div", "Closed Web Content section") self.eyes.check_region_by_selector( By.XPATH, "//*[contains(@class,'two')]/div[2]", "Chat box in knowledge") finally: res = self.eyes.close(raise_ex=True) print(res) self.eyes.abort_if_not_closed() def tearDown(self): super().tearDown()
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)
def setUp(self): self.driver = webdriver.Firefox() Eyes.api_key = '8PN69qEtrGKMMYrzyThC8wWXLlFmqyPMH1YLurYcxp8110' eyes = Eyes() self.driver = eyes.open(driver=self.driver, app_name='Applitools', test_name='Test Web Page', viewport_size={'width': 1024, 'height': 768})
__author__ = 'Yanir Taflev' from selenium import webdriver from applitools.eyes import Eyes eyes = Eyes() # This is your api key, make sure you use it in all your tests. eyes.api_key = APPLITOOLS_APIKEY # Get a selenium web driver object. driver = webdriver.Firefox() try: # Start visual testing with browser viewport set to 1024x768. # Make sure to use the returned driver from this point on. driver = eyes.open(driver=driver, app_name='Applitools website', test_name='Example test', viewport_size={'width': 900, 'height': 600}) driver.get('http://www.applitools.com') # Visual validation point #1 eyes.check_window('Main Page') driver.find_element_by_css_selector('.read_more').click() # Visual validation point #2 eyes.check_window('Features Page') # End visual testing. Validate visual correctness. eyes.close() finally: driver.quit() eyes.abort_if_not_closed()
'browserName': 'Chrome', 'platform': 'Windows 10', 'screenResolution': '1366x768' } # open a remote webdriver connected to cbt's hub driver = webdriver.Remote( desired_capabilities=caps, command_executor="http://%s:%[email protected]:80/wd/hub" % (username, authkey)) # Start the test and set the browser's viewport size to 800x600. eyes.open(driver=driver, app_name='CrossBrowserTesting', test_name='My first Applitools test with Python!', viewport_size={ 'width': 800, 'height': 600 }) # We want to take a full page screenshot eyes.force_full_page_screenshot = True driver.get('https://crossbrowsertesting.com/visual-testing') # Visual checkpoint eyes.check_window('Visual Testing') # End the test. eyes.close() test_result = 'pass'
from applitools import logger from applitools.eyes import Eyes import os # Appium session configuration. from applitools.logger import StdoutLogger desired_capabilities = { 'platformName': 'Android', 'platformVersion': '4.2', 'deviceName': 'Samsung Galaxy S5', 'app': os.environ['ANDROID_NOTES_LIST_APP'], 'app-package': 'com.example.android.notepad', 'app-activity': '.NotesList', 'newCommandTimeout': 300 } # Assuming Appium is running on localhost. driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities) driver.orientation = 'LANDSCAPE' logger.set_logger(StdoutLogger()) eyes = Eyes() eyes.api_key = os.environ['APPLITOOLS_API_KEY'] try: eyes.open(driver, 'Appium', 'Notes list') eyes.check_window('Opening screen') eyes.close() finally: driver.quit() eyes.abort_if_not_closed()
from applitools.logger import StdoutLogger # os.environ['HTTPS_PROXY'] = "http://localhost:8888" driver = webdriver.Chrome() logger.set_logger(StdoutLogger()) eyes = Eyes() eyes.api_key = os.environ['APPLITOOLS_API_KEY'] eyes.force_full_page_screenshot = True eyes.hide_scrollbars = True try: ## First test driver = eyes.open(driver, "Python app", "Github Website", { 'width': 800, 'height': 600 }) driver.get('http://www.github.com') eyes.check_window("initial") results = eyes.close(False) print(results) ## Second test driver = eyes.open(driver, "Python app", "Applitools Website", { 'width': 900, 'height': 600 }) driver.get('http://www.applitools.com') eyes.check_window("initial") results = eyes.close(False) print(results)
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) driver = eyes.open(driver=driver, app_name='Home Reach', test_name='Login to Dash', viewport_size={'width': 1024, 'height': 600}) # 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') 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-trialsbeta1") 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() #selenium.webdriver.support.expected_conditions.invisibility_of_element_located(locator) #element = WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.ID, "divFlashVersion")) element = WebDriverWait(driver, 15).until(EC.invisibility_of_element_located((By.ID, "divFlashVersion"))) try: for i in range(20): try: flashCheck = driver.find_element_by_id("divFlashVersion") print flashCheck if flashCheck != driver.find_element_by_id("divFlashVersion"): print "Flash version check" print flashCheck time.sleep(1) continue elif flashCheck == driver.find_element_by_id("divFlashVersion"): print "No Flash check" print flashCheck if driver.find_element_by_id("flashImg1"): # Visual validation point #2 #eyes.check_window('Dashboard') print "Found flashImg1" driver.find_element_by_link_text("Logout").click() print 'Logging out' break except Exception as e: print e print 'Wait..' time.sleep(1) # End visual testing. Validate visual correctness. eyes.close() except Exception as e: print e finally: driver.quit() eyes.abort_if_not_closed()
def open_eyes_session(self, url, appname, testname, apikey, width=None, height=None, osname=None, browsername=None, matchlevel=None, includeEyesLog=False, httpDebugLog=False): """ Starts a session with the Applitools Eyes Website. Arguments: | URL (string) | The URL to start the test on | | 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. | 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. The driver then gets the url that will be tested. 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 | http://www.navinet.net/ | 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 matchlevel is not None: eyes.match_level = matchlevel 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}) driver.get(url)
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 # driver.find_element_by_class_name("input-name").send_keys("my name is what?") # eyes.check_window("name input") # results = eyes.close(False) # print(results)
from selenium import webdriver from applitools.eyes import Eyes from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from applitools import logger from applitools.logger import StdoutLogger eyes = Eyes() Eyes.api_key = 'VOfLF4XBAbbMmsOLf0BxDx4APw7gCynQz7NjZwRG1076g110' logger.set_logger(StdoutLogger()) driver = webdriver.Firefox() driver.implicitly_wait(10) driver = eyes.open(driver=driver, app_name='Home Reach', test_name='Login to Dash', viewport_size={'width': 1024, 'height': 600}) def userLogin(): driver.get("https://homereach.aminocom.com") # Visual validation point #2 eyes.check_window('Login') driver.find_element_by_id("username").clear() driver.find_element_by_id("username").send_keys("rayres-trialsbeta1") 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() try: element = WebDriverWait(driver, 15).until(EC.invisibility_of_element_located((By.ID, "divFlashVersion")))
import os #os.environ['HTTPS_PROXY'] = "http://localhost:8888" driver = webdriver.Chrome() logger.set_logger(StdoutLogger()) eyes = Eyes() eyes.api_key = os.environ['APPLITOOLS_API_KEY'] eyes.hide_scrollbars = True # For browser which only take screenshot of the viewport, you can uncomment the setting below, and # eyes will automatically create a full page screenshot. # eyes.force_full_page_screenshot = True try: driver = eyes.open(driver, "Python app", "applitools", {'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") pricing_element.click() eyes.check_window("pricing page") driver.find_element_by_css_selector("li.contact-us a").click() eyes.check_window("contact us page") driver.find_element_by_class_name("input-name").send_keys("my name is what?") eyes.check_window("name input") eyes.close() finally:
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 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 hover_over_recreational_leasing_gallery_second_drop_down(driver): time.sleep(5) second_dropdown_1 = driver.find_element_by_xpath("//ul[@class='super-menu mobile-menu menu-table']/li[4]/a/span") ActionChains(driver).move_to_element(second_dropdown_1).perform() time.sleep(5) second_dropdown_2 = driver.find_element_by_xpath("//ul[@class='super-menu mobile-menu menu-table']/li[4]/ul/li[6]/a") ActionChains(driver).move_to_element(second_dropdown_2).perform() eyes = Eyes() eyes.api_key = 'u51qaFo104ruwwox0ewoWiFZQpijro9Z47fYTk1iQTozU110' driver = webdriver.Firefox() #driver.maximize_window() try: eyes.open(driver=driver, app_name='hullforest1', test_name='hullforestwhole') #Homepage driver.get('http://hullforest.managedcoder.com/') #eyes.check_window('Homepage') #register driver.find_element_by_xpath("//a[@class='secondary-menu-item-2']/span").click() #eyes.check_window("register") # Login driver.find_element_by_xpath("//a[@class='secondary-menu-item-1']/span").click() # eyes.check_window("login") #forgotten password driver.find_element_by_xpath("//div[@class='form-group'][2]/a").click()
class TestAuthenticationPages(BaseTest): def __init__(self, *args, **kwargs): super(TestAuthenticationPages, self).__init__(*args, **kwargs) self.__login = LoginPage() self.__register = RegisterPage() self.__forgot_password = ForgotPasswordPage() self.__data = DataGenerateUtils() self.valid_email = self.__data.create_email() self.valid_username = self.__data.create_name() self.valid_password = self.__data.create_password() self.bot_name = "Test" self.invalid_faq = "google.com" self.eyes = Eyes() self.eyes.api_key = YAML_CONFIG.get("eyes_api_key") def setUp(self): super().setUp() def test_login_page_appearance(self): try: self.eyes.open(driver=self.__login.driver.core_driver, app_name='sample_app', test_name='Login Page', viewport_size={'width': 1440, 'height': 887}) self.__login.open_login_page() self.__login.wait_for_log_in_page() self.eyes.check_window("Default Login Page") self.__login.check_remember_me(False) self.eyes.check_window("Login Page without remember me") self.__login.login_with_account("", "") self.eyes.check_window("Login Page with error message") finally: res = self.eyes.close(raise_ex=True) print(res) self.eyes.abort_if_not_closed() def test_register_page_appearance(self): try: self.eyes.open(driver=self.__login.driver.core_driver, app_name='sample_app', test_name='Register Page', viewport_size={'width': 1440, 'height': 887}) self.__register.open_register_page() self.__register.wait_for_register_page() self.eyes.check_window("Default Register Page") self.__register.txt_email.click() self.eyes.check_window("Register with tips for email") self.__register.txt_password.click() self.eyes.check_window("Register with tips for password") self.__register.login_with_new_account("", "", "") self.eyes.check_window("Register with error message") finally: res = self.eyes.close(raise_ex=True) print(res) self.eyes.abort_if_not_closed() def test_forgot_password_page_appearance(self): try: self.eyes.open(driver=self.__login.driver.core_driver, app_name='sample_app', test_name='Forgot Password Page', viewport_size={'width': 1440, 'height': 887}) self.__forgot_password.open_forgot_password_page() self.__forgot_password.wait_for_forgot_password_page() self.eyes.check_window("Default Forgot password page") self.__forgot_password.submit_email("") self.eyes.check_window("Submit empty email") self.__forgot_password.submit_email("*****@*****.**") self.eyes.check_window("Submit with wrong email format") self.__forgot_password.submit_email(YAML_CONFIG.get("sample_app_user")) self.eyes.check_window("Submit successfully") finally: res = self.eyes.close(raise_ex=True) print(res) self.eyes.abort_if_not_closed() def tearDown(self): super().tearDown()
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 })
eyes.api_key = 'YOUR_API_KEY' # Get a selenium web driver object. desired_cap = webdriver.DesiredCapabilities.FIREFOX driver = webdriver.Remote( command_executor= 'http://*****:*****@ondemand.saucelabs.com:80/wd/hub', desired_capabilities=desired_cap) try: # Start visual testing with browser viewport set to 1024x768. # Make sure to use the returned driver from this point on. driver = eyes.open(driver=driver, app_name='Applitools', test_name='Test Web Page', viewport_size={ 'width': 1024, 'height': 768 }) driver.get('http://www.applitools.com') # Visual validation point #1 eyes.check_window('Main Page') driver.find_element_by_css_selector('.features>a').click() # Visual validation point #2 eyes.check_window('Features Page') # End visual testing. Validate visual correctness. eyes.close()